* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2020-01-08 22:14 Stephen Rothwell
0 siblings, 0 replies; 23+ messages in thread
From: Stephen Rothwell @ 2020-01-08 22:14 UTC (permalink / raw)
To: David Sterba
Cc: Linux Next Mailing List, Linux Kernel Mailing List, Josef Bacik
[-- Attachment #1: Type: text/plain, Size: 779 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/inode.c
between commit:
045d3967b692 ("btrfs: rework arguments of btrfs_unlink_subvol")
from the btrfs-fixes tree and commit:
f8b3030e0807 ("btrfs: rework arguments of btrfs_unlink_subvol")
from the btrfs tree.
I fixed it up (just different version of the same patch - I used the
former) and can carry the fix as necessary. This is now fixed as far as
linux-next is concerned, but any non trivial conflicts should be mentioned
to your upstream maintainer when your tree is submitted for merging.
You may also want to consider cooperating with the maintainer of the
conflicting tree to minimise any particularly complex conflicts.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2020-05-01 0:24 Stephen Rothwell
2020-05-01 1:05 ` Stephen Rothwell
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Rothwell @ 2020-05-01 0:24 UTC (permalink / raw)
To: David Sterba
Cc: Linux Next Mailing List, Linux Kernel Mailing List, Qu Wenruo,
Josef Bacik
[-- Attachment #1: Type: text/plain, Size: 1826 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/transaction.c
between commit:
fcc99734d1d4 ("btrfs: transaction: Avoid deadlock due to bad initialization timing of fs_info::journal_info")
from the btrfs-fixes tree and commit:
f12ca53a6fd6 ("btrfs: force chunk allocation if our global rsv is larger than metadata")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc fs/btrfs/transaction.c
index 2d5498136e5e,e4dbd8e3c641..000000000000
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@@ -666,15 -674,17 +672,26 @@@ got_it
current->journal_info = h;
/*
+ * btrfs_record_root_in_trans() needs to alloc new extents, and may
+ * call btrfs_join_transaction() while we're also starting a
+ * transaction.
+ *
+ * Thus it need to be called after current->journal_info initialized,
+ * or we can deadlock.
+ */
+ btrfs_record_root_in_trans(h, root);
+
+ * If the space_info is marked ALLOC_FORCE then we'll get upgraded to
+ * ALLOC_FORCE the first run through, and then we won't allocate for
+ * anybody else who races in later. We don't care about the return
+ * value here.
+ */
+ if (do_chunk_alloc && num_bytes) {
+ u64 flags = h->block_rsv->space_info->flags;
+ btrfs_chunk_alloc(h, btrfs_get_alloc_profile(fs_info, flags),
+ CHUNK_ALLOC_NO_FORCE);
+ }
+
return h;
join_fail:
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2020-05-01 0:28 Stephen Rothwell
2020-05-03 21:40 ` David Sterba
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Rothwell @ 2020-05-01 0:28 UTC (permalink / raw)
To: David Sterba
Cc: Linux Next Mailing List, Linux Kernel Mailing List, Filipe Manana
[-- Attachment #1: Type: text/plain, Size: 785 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/tree-log.c
between commit:
f135cea30de5 ("btrfs: fix partial loss of prealloc extent past i_size after fsync")
from the btrfs-fixes tree and commit:
e94d318f12cd ("btrfs: fix partial loss of prealloc extent past i_size after fsync")
from the btrfs tree.
I fixed it up (I just used the latter) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging. You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
2020-05-01 0:24 Stephen Rothwell
@ 2020-05-01 1:05 ` Stephen Rothwell
2020-05-01 2:06 ` Qu Wenruo
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Rothwell @ 2020-05-01 1:05 UTC (permalink / raw)
To: David Sterba
Cc: Linux Next Mailing List, Linux Kernel Mailing List, Qu Wenruo,
Josef Bacik
[-- Attachment #1: Type: text/plain, Size: 2115 bytes --]
Hi all,
On Fri, 1 May 2020 10:24:53 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the btrfs tree got a conflict in:
>
> fs/btrfs/transaction.c
>
> between commit:
>
> fcc99734d1d4 ("btrfs: transaction: Avoid deadlock due to bad initialization timing of fs_info::journal_info")
>
> from the btrfs-fixes tree and commit:
>
> f12ca53a6fd6 ("btrfs: force chunk allocation if our global rsv is larger than metadata")
>
> from the btrfs tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
>
> --
> Cheers,
> Stephen Rothwell
>
> diff --cc fs/btrfs/transaction.c
> index 2d5498136e5e,e4dbd8e3c641..000000000000
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@@ -666,15 -674,17 +672,26 @@@ got_it
> current->journal_info = h;
>
> /*
> + * btrfs_record_root_in_trans() needs to alloc new extents, and may
> + * call btrfs_join_transaction() while we're also starting a
> + * transaction.
> + *
> + * Thus it need to be called after current->journal_info initialized,
> + * or we can deadlock.
> + */
> + btrfs_record_root_in_trans(h, root);
> +
> + * If the space_info is marked ALLOC_FORCE then we'll get upgraded to
> + * ALLOC_FORCE the first run through, and then we won't allocate for
> + * anybody else who races in later. We don't care about the return
> + * value here.
> + */
> + if (do_chunk_alloc && num_bytes) {
> + u64 flags = h->block_rsv->space_info->flags;
> + btrfs_chunk_alloc(h, btrfs_get_alloc_profile(fs_info, flags),
> + CHUNK_ALLOC_NO_FORCE);
> + }
> +
> return h;
>
> join_fail:
I fixed the missing comment start in my resolution ...
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
2020-05-01 1:05 ` Stephen Rothwell
@ 2020-05-01 2:06 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2020-05-01 2:06 UTC (permalink / raw)
To: Stephen Rothwell, David Sterba
Cc: Linux Next Mailing List, Linux Kernel Mailing List, Josef Bacik
[-- Attachment #1.1: Type: text/plain, Size: 2424 bytes --]
On 2020/5/1 上午9:05, Stephen Rothwell wrote:
> Hi all,
>
> On Fri, 1 May 2020 10:24:53 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>>
>> Today's linux-next merge of the btrfs tree got a conflict in:
>>
>> fs/btrfs/transaction.c
>>
>> between commit:
>>
>> fcc99734d1d4 ("btrfs: transaction: Avoid deadlock due to bad initialization timing of fs_info::journal_info")
>>
>> from the btrfs-fixes tree and commit:
>>
>> f12ca53a6fd6 ("btrfs: force chunk allocation if our global rsv is larger than metadata")
>>
>> from the btrfs tree.
>>
>> I fixed it up (see below) and can carry the fix as necessary. This
>> is now fixed as far as linux-next is concerned, but any non trivial
>> conflicts should be mentioned to your upstream maintainer when your tree
>> is submitted for merging. You may also want to consider cooperating
>> with the maintainer of the conflicting tree to minimise any particularly
>> complex conflicts.
>>
>> --
>> Cheers,
>> Stephen Rothwell
>>
>> diff --cc fs/btrfs/transaction.c
>> index 2d5498136e5e,e4dbd8e3c641..000000000000
>> --- a/fs/btrfs/transaction.c
>> +++ b/fs/btrfs/transaction.c
>> @@@ -666,15 -674,17 +672,26 @@@ got_it
>> current->journal_info = h;
>>
>> /*
>> + * btrfs_record_root_in_trans() needs to alloc new extents, and may
>> + * call btrfs_join_transaction() while we're also starting a
>> + * transaction.
>> + *
>> + * Thus it need to be called after current->journal_info initialized,
>> + * or we can deadlock.
>> + */
>> + btrfs_record_root_in_trans(h, root);
>> +
>> + * If the space_info is marked ALLOC_FORCE then we'll get upgraded to
>> + * ALLOC_FORCE the first run through, and then we won't allocate for
>> + * anybody else who races in later. We don't care about the return
>> + * value here.
>> + */
>> + if (do_chunk_alloc && num_bytes) {
>> + u64 flags = h->block_rsv->space_info->flags;
>> + btrfs_chunk_alloc(h, btrfs_get_alloc_profile(fs_info, flags),
>> + CHUNK_ALLOC_NO_FORCE);
>> + }
>> +
>> return h;
The proper fix has landed in David's misc-next branch, which puts
btrfs_record_root_in_trans(); after the if () {} code block.
By that, btrfs_record_root_in_trans() has lesser chance to hit ENOSPC.
Thanks,
Qu
>>
>> join_fail:
>
>
> I fixed the missing comment start in my resolution ...
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
2020-05-01 0:28 Stephen Rothwell
@ 2020-05-03 21:40 ` David Sterba
0 siblings, 0 replies; 23+ messages in thread
From: David Sterba @ 2020-05-03 21:40 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Linux Next Mailing List, Linux Kernel Mailing List, Filipe Manana
On Fri, May 01, 2020 at 10:28:25AM +1000, Stephen Rothwell wrote:
> Hi all,
>
> Today's linux-next merge of the btrfs tree got a conflict in:
>
> fs/btrfs/tree-log.c
>
> between commit:
>
> f135cea30de5 ("btrfs: fix partial loss of prealloc extent past i_size after fsync")
>
> from the btrfs-fixes tree and commit:
>
> e94d318f12cd ("btrfs: fix partial loss of prealloc extent past i_size after fsync")
Conflicts in the above commit and "btrfs: force chunk allocation if our
global rsv is larger than metadata" should be gone now. Both patches
have been merged to master and fresh for-next branch pushed to k.org.
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2021-01-10 22:29 Stephen Rothwell
0 siblings, 0 replies; 23+ messages in thread
From: Stephen Rothwell @ 2021-01-10 22:29 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Filipe Manana, Josef Bacik,
Linux Kernel Mailing List, Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got conflicts in:
fs/btrfs/inode.c
fs/btrfs/space-info.c
between commits:
3d45f221ce62 ("btrfs: fix deadlock when cloning inline extent and low on free metadata space")
e076ab2a2ca7 ("btrfs: shrink delalloc pages instead of full inodes")
from the btrfs-fixes tree and commits:
50f2ad0e64bd ("btrfs: fix deadlock when cloning inline extent and low on free metadata space")
123b5509410e ("btrfs: track ordered bytes instead of just dio ordered bytes")
from the btrfs tree.
I fixed it up (I used the former version of the conflicts in inode.c
and see below) and can carry the fix as necessary. This is now fixed as
far as linux-next is concerned, but any non trivial conflicts should be
mentioned to your upstream maintainer when your tree is submitted for
merging. You may also want to consider cooperating with the maintainer
of the conflicting tree to minimise any particularly complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc fs/btrfs/inode.c
index a8e0a6b038d3,070716650df8..000000000000
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
diff --cc fs/btrfs/space-info.c
index e8347461c8dd,80f3edd6a391..000000000000
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@@ -531,10 -527,8 +527,10 @@@ static void shrink_delalloc(struct btrf
wait_ordered = true;
loops = 0;
- while ((delalloc_bytes || dio_bytes) && loops < 3) {
+ while ((delalloc_bytes || ordered_bytes) && loops < 3) {
- btrfs_start_delalloc_roots(fs_info, items, true);
+ u64 nr_pages = min(delalloc_bytes, to_reclaim) >> PAGE_SHIFT;
+
+ btrfs_start_delalloc_roots(fs_info, nr_pages, true);
loops++;
if (wait_ordered && !trans) {
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2022-02-24 13:44 broonie
2022-02-25 11:59 ` David Sterba
0 siblings, 1 reply; 23+ messages in thread
From: broonie @ 2022-02-24 13:44 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
Qu Wenruo, Dāvis Mosāns
Hi all,
Today's linux-next merge of the btrfs tree got conflicts in:
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/lzo.c
between commit:
2ac3e062af024 ("btrfs: reduce extent threshold for autodefrag")
741b23a970a79 ("btrfs: prevent copying too big compressed lzo segment")
26fbac2517fca ("btrfs: autodefrag: only scan one inode once")
966d879bafaaf ("btrfs: defrag: allow defrag_one_cluster() to skip large extent which is not a target")
d5633b0dee02d ("btrfs: defrag: bring back the old file extent search behavior")
from the btrfs-fixes tree and commit:
13b2f7ab699a5 ("btrfs: close the gap between inode_should_defrag() and autodefrag extent size threshold")
48b433a2ef82a ("btrfs: add lzo workspace buffer length constants")
db360c49d476f ("btrfs: autodefrag: only scan one inode once")
e6c69fcbee7ef ("btrfs: defrag: use control structure in btrfs_defrag_file()")
6b17743d934ec ("btrfs: defrag: bring back the old file extent search behavior")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --cc fs/btrfs/ctree.h
index 947f04789389e,5a569bc756c3c..0000000000000
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
diff --cc fs/btrfs/file.c
index 01111ee06e1ef,8815981447034..0000000000000
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
diff --cc fs/btrfs/inode.c
index 76e530f76e3cf,44e8d28182b7f..0000000000000
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
diff --cc fs/btrfs/ioctl.c
index 8d47ec5fc4f44,998bf48e5ce29..0000000000000
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@@ -1435,16 -1460,16 +1461,23 @@@ static int defrag_collect_targets(struc
goto add;
/* Skip too large extent */
- if (range_len >= extent_thresh)
+ if (range_len >= ctrl->extent_thresh)
+ goto next;
+
+ /*
+ * Skip extents already at its max capacity, this is mostly for
+ * compressed extents, which max cap is only 128K.
+ */
+ if (em->len >= get_extent_max_capacity(em))
goto next;
+ /*
+ * Skip extents already at its max capacity, this is mostly for
+ * compressed extents, which max cap is only 128K.
+ */
+ if (em->len >= get_extent_max_capacity(em))
+ goto next;
+
next_mergeable = defrag_check_next_extent(&inode->vfs_inode, em,
locked);
if (!next_mergeable) {
@@@ -1683,19 -1715,11 +1723,20 @@@ static int defrag_one_cluster(struct bt
break;
}
- if (max_sectors)
+ if (ctrl->max_sectors_to_defrag)
range_len = min_t(u32, range_len,
- (max_sectors - *sectors_defragged) * sectorsize);
+ (ctrl->max_sectors_to_defrag -
+ ctrl->sectors_defragged) * sectorsize);
+ /*
+ * If defrag_one_range() has updated last_scanned_ret,
+ * our range may already be invalid (e.g. hole punched).
+ * Skip if our range is before last_scanned_ret, as there is
+ * no need to defrag the range anymore.
+ */
+ if (entry->start + range_len <= *last_scanned_ret)
+ continue;
+
if (ra)
page_cache_sync_readahead(inode->vfs_inode.i_mapping,
ra, NULL, entry->start >> PAGE_SHIFT,
@@@ -1834,13 -1879,11 +1898,10 @@@ int btrfs_defrag_file(struct inode *ino
break;
}
if (do_compress)
- BTRFS_I(inode)->defrag_compress = compress_type;
- ret = defrag_one_cluster(BTRFS_I(inode), ra, cur,
- cluster_end + 1 - cur, extent_thresh,
- newer_than, do_compress, §ors_defragged,
- max_to_defrag, &last_scanned);
- BTRFS_I(inode)->defrag_compress = ctrl->compress;
+ ret = defrag_one_cluster(BTRFS_I(inode), ra, ctrl, cur,
+ cluster_end + 1 - cur);
- if (sectors_defragged > prev_sectors_defragged)
+ if (ctrl->sectors_defragged > prev_sectors_defragged)
balance_dirty_pages_ratelimited(inode->i_mapping);
btrfs_inode_unlock(inode, 0);
diff --cc fs/btrfs/lzo.c
index e6e28a9c79877,430ad36b8b080..0000000000000
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7d3542893a165..5ef7c08b24b89 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1734,7 +1734,7 @@ static int defrag_one_cluster(struct btrfs_inode *inode,
* Skip if our range is before last_scanned_ret, as there is
* no need to defrag the range anymore.
*/
- if (entry->start + range_len <= *last_scanned_ret)
+ if (entry->start + range_len <= ctrl->last_scanned)
continue;
if (ra)
@@ -1760,7 +1760,7 @@ static int defrag_one_cluster(struct btrfs_inode *inode,
kfree(entry);
}
if (ret >= 0)
- *last_scanned_ret = max(*last_scanned_ret, start + len);
+ ctrl->last_scanned = max(ctrl->last_scanned, start + len);
return ret;
}
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
2022-02-24 13:44 broonie
@ 2022-02-25 11:59 ` David Sterba
0 siblings, 0 replies; 23+ messages in thread
From: David Sterba @ 2022-02-25 11:59 UTC (permalink / raw)
To: broonie
Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
Qu Wenruo, Dāvis Mosāns
On Thu, Feb 24, 2022 at 01:44:27PM +0000, broonie@kernel.org wrote:
> Hi all,
>
> Today's linux-next merge of the btrfs tree got conflicts in:
>
> fs/btrfs/ctree.h
> fs/btrfs/file.c
> fs/btrfs/inode.c
> fs/btrfs/ioctl.c
> fs/btrfs/lzo.c
>
> between commit:
>
> 2ac3e062af024 ("btrfs: reduce extent threshold for autodefrag")
> 741b23a970a79 ("btrfs: prevent copying too big compressed lzo segment")
> 26fbac2517fca ("btrfs: autodefrag: only scan one inode once")
> 966d879bafaaf ("btrfs: defrag: allow defrag_one_cluster() to skip large extent which is not a target")
> d5633b0dee02d ("btrfs: defrag: bring back the old file extent search behavior")
>
> from the btrfs-fixes tree and commit:
>
> 13b2f7ab699a5 ("btrfs: close the gap between inode_should_defrag() and autodefrag extent size threshold")
> 48b433a2ef82a ("btrfs: add lzo workspace buffer length constants")
> db360c49d476f ("btrfs: autodefrag: only scan one inode once")
> e6c69fcbee7ef ("btrfs: defrag: use control structure in btrfs_defrag_file()")
> 6b17743d934ec ("btrfs: defrag: bring back the old file extent search behavior")
>
> from the btrfs tree.
The fixes and for-next snapshot branches got out of sync a bit, I've
checked that they merge without conflicts as of yesterday.
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2022-03-24 23:48 Stephen Rothwell
0 siblings, 0 replies; 23+ messages in thread
From: Stephen Rothwell @ 2022-03-24 23:48 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Johannes Thumshirn, Linux Kernel Mailing List,
Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 975 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/zoned.c
between commits:
0b9e66762aa0 ("btrfs: zoned: traverse devices under chunk_mutex in btrfs_can_activate_zone")
62ed0bf7315b ("btrfs: zoned: remove left over ASSERT checking for single profile")
from the btrfs-fixes tree and commits:
71f3883a5968 ("btrfs: zoned: use RCU list in btrfs_can_activate_zone")
7d5e73a6ef6c ("btrfs: zoned: remove left over ASSERT checking for single profile")
from the btrfs tree.
I fixed it up (I just (arbitrarily) chose the former version) and can
carry the fix as necessary. This is now fixed as far as linux-next is
concerned, but any non trivial conflicts should be mentioned to your
upstream maintainer when your tree is submitted for merging. You may
also want to consider cooperating with the maintainer of the conflicting
tree to minimise any particularly complex conflicts.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2022-09-05 23:50 Stephen Rothwell
2022-09-06 0:15 ` Stephen Rothwell
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Rothwell @ 2022-09-05 23:50 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Johannes Thumshirn, Josef Bacik,
Linux Kernel Mailing List, Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/zoned.c
between commit:
6ca64ac27631 ("btrfs: zoned: fix mounting with conventional zones")
from the btrfs-fixes tree and commit:
e5182af66852 ("btrfs: convert block group bit field to use bit helpers")
from the btrfs tree.
I fixed it up (the former removed some of the code modified by the latter)
and can carry the fix as necessary. This is now fixed as far as linux-next
is concerned, but any non trivial conflicts should be mentioned to your
upstream maintainer when your tree is submitted for merging. You may
also want to consider cooperating with the maintainer of the conflicting
tree to minimise any particularly complex conflicts.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
2022-09-05 23:50 Stephen Rothwell
@ 2022-09-06 0:15 ` Stephen Rothwell
2022-09-06 19:41 ` David Sterba
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Rothwell @ 2022-09-06 0:15 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Johannes Thumshirn, Josef Bacik,
Linux Kernel Mailing List, Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 3056 bytes --]
Hi all,
On Tue, 6 Sep 2022 09:50:55 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the btrfs tree got a conflict in:
>
> fs/btrfs/zoned.c
>
> between commit:
>
> 6ca64ac27631 ("btrfs: zoned: fix mounting with conventional zones")
>
> from the btrfs-fixes tree and commit:
>
> e5182af66852 ("btrfs: convert block group bit field to use bit helpers")
>
> from the btrfs tree.
>
> I fixed it up (the former removed some of the code modified by the latter)
> and can carry the fix as necessary. This is now fixed as far as linux-next
> is concerned, but any non trivial conflicts should be mentioned to your
> upstream maintainer when your tree is submitted for merging. You may
> also want to consider cooperating with the maintainer of the conflicting
> tree to minimise any particularly complex conflicts.
Actually the fix up is below ...
--
Cheers,
Stephen Rothwell
diff --cc fs/btrfs/zoned.c
index 62e7007a7e46,dc96b3331bfb..000000000000
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@@ -1426,17 -1402,32 +1426,16 @@@ int btrfs_load_block_group_zone_info(st
cache->seq_zone = true;
if (num_conventional > 0) {
- /*
- * Avoid calling calculate_alloc_pointer() for new BG. It
- * is no use for new BG. It must be always 0.
- *
- * Also, we have a lock chain of extent buffer lock ->
- * chunk mutex. For new BG, this function is called from
- * btrfs_make_block_group() which is already taking the
- * chunk mutex. Thus, we cannot call
- * calculate_alloc_pointer() which takes extent buffer
- * locks to avoid deadlock.
- */
-
/* Zone capacity is always zone size in emulation */
cache->zone_capacity = cache->length;
- if (new) {
- cache->alloc_offset = 0;
- goto out;
- }
- ret = calculate_alloc_pointer(cache, &last_alloc);
- if (ret || map->num_stripes == num_conventional) {
- if (!ret)
- cache->alloc_offset = last_alloc;
- else
- btrfs_err(fs_info,
+ ret = calculate_alloc_pointer(cache, &last_alloc, new);
+ if (ret) {
+ btrfs_err(fs_info,
"zoned: failed to determine allocation offset of bg %llu",
- cache->start);
+ cache->start);
+ goto out;
+ } else if (map->num_stripes == num_conventional) {
+ cache->alloc_offset = last_alloc;
- cache->zone_is_active = 1;
goto out;
}
}
@@@ -1528,16 -1529,10 +1530,16 @@@ out
ret = -EIO;
}
- if (!ret)
+ if (!ret) {
cache->meta_write_pointer = cache->alloc_offset + cache->start;
- if (cache->zone_is_active) {
-
- if (ret) {
++ if (test_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &cache->runtime_flags)) {
+ btrfs_get_block_group(cache);
+ spin_lock(&fs_info->zone_active_bgs_lock);
+ list_add_tail(&cache->active_bg_list,
+ &fs_info->zone_active_bgs);
+ spin_unlock(&fs_info->zone_active_bgs_lock);
+ }
+ } else {
kfree(cache->physical_map);
cache->physical_map = NULL;
}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
2022-09-06 0:15 ` Stephen Rothwell
@ 2022-09-06 19:41 ` David Sterba
0 siblings, 0 replies; 23+ messages in thread
From: David Sterba @ 2022-09-06 19:41 UTC (permalink / raw)
To: Stephen Rothwell
Cc: David Sterba, Johannes Thumshirn, Josef Bacik,
Linux Kernel Mailing List, Linux Next Mailing List
On Tue, Sep 06, 2022 at 10:15:49AM +1000, Stephen Rothwell wrote:
> Hi all,
>
> On Tue, 6 Sep 2022 09:50:55 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >
> > Today's linux-next merge of the btrfs tree got a conflict in:
> >
> > fs/btrfs/zoned.c
> >
> > between commit:
> >
> > 6ca64ac27631 ("btrfs: zoned: fix mounting with conventional zones")
> >
> > from the btrfs-fixes tree and commit:
> >
> > e5182af66852 ("btrfs: convert block group bit field to use bit helpers")
> >
> > from the btrfs tree.
> >
> > I fixed it up (the former removed some of the code modified by the latter)
> > and can carry the fix as necessary. This is now fixed as far as linux-next
> > is concerned, but any non trivial conflicts should be mentioned to your
> > upstream maintainer when your tree is submitted for merging. You may
> > also want to consider cooperating with the maintainer of the conflicting
> > tree to minimise any particularly complex conflicts.
>
> Actually the fix up is below ...
Thanks, looks correct to me. I've pushed a new for-next snapshot that
has the conflict resolved too.
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2022-10-31 23:28 Stephen Rothwell
0 siblings, 0 replies; 23+ messages in thread
From: Stephen Rothwell @ 2022-10-31 23:28 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Filipe Manana, Josef Bacik,
Linux Kernel Mailing List, Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/ctree.h
between commit:
8184620ae212 ("btrfs: fix lost file sync on direct IO write with nowait and dsync iocb")
from the btrfs-fixes tree and commit:
d98f802c975e ("btrfs: move inode prototypes to btrfs_inode.h")
from the btrfs tree.
I fixed it up (I used the latter version of this file and applied the
following merge fix patch) and can carry the fix as necessary. This is
now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your
tree is submitted for merging. You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.
From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Tue, 1 Nov 2022 10:24:24 +1100
Subject: [PATCH] fix up for "btrfs: fix lost file sync on direct IO write with nowait and dsync iocb"
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
fs/btrfs/btrfs_inode.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 79a9f06c2434..d21c30bf7053 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -526,7 +526,10 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
const struct btrfs_ioctl_encoded_io_args *encoded);
-ssize_t btrfs_dio_rw(struct kiocb *iocb, struct iov_iter *iter, size_t done_before);
+ssize_t btrfs_dio_read(struct kiocb *iocb, struct iov_iter *iter,
+ size_t done_before);
+struct iomap_dio *btrfs_dio_write(struct kiocb *iocb, struct iov_iter *iter,
+ size_t done_before);
extern const struct dentry_operations btrfs_dentry_operations;
--
2.35.1
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply related [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2023-10-04 23:09 Stephen Rothwell
0 siblings, 0 replies; 23+ messages in thread
From: Stephen Rothwell @ 2023-10-04 23:09 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Filipe Manana, Linux Kernel Mailing List,
Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 1636 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/transaction.h
between commit:
f8d1b011ca8c ("btrfs: always print transaction aborted messages with an error level")
from the btrfs-fixes tree and commit:
5483af73c851 ("btrfs: rename errno identifiers to error")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc fs/btrfs/transaction.h
index 93869cda6af9,de58776de307..000000000000
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@@ -213,15 -216,15 +216,15 @@@ do {
if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \
&((trans)->fs_info->fs_state))) { \
first = true; \
- if (WARN(abort_should_print_stack(errno), \
+ if (WARN(abort_should_print_stack(error), \
KERN_ERR \
"BTRFS: Transaction aborted (error %d)\n", \
- (errno))) { \
+ (error))) { \
/* Stack trace printed. */ \
} else { \
- btrfs_debug((trans)->fs_info, \
- "Transaction aborted (error %d)", \
+ btrfs_err((trans)->fs_info, \
+ "Transaction aborted (error %d)", \
- (errno)); \
+ (error)); \
} \
} \
__btrfs_abort_transaction((trans), __func__, \
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2024-06-06 22:55 Stephen Rothwell
2024-06-06 23:12 ` Qu Wenruo
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Rothwell @ 2024-06-06 22:55 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
Qu Wenruo
[-- Attachment #1: Type: text/plain, Size: 787 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/extent_io.c
between commit:
d202776a44d5 ("btrfs: protect folio::private when attaching extent buffer folios")
from the btrfs-fixes tree and commit:
46cda5a0ef68 ("btrfs: fix a possible race window when allocating new extent buffers")
from the btrfs tree.
I fixed it up (I just used the latter) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging. You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
2024-06-06 22:55 Stephen Rothwell
@ 2024-06-06 23:12 ` Qu Wenruo
0 siblings, 0 replies; 23+ messages in thread
From: Qu Wenruo @ 2024-06-06 23:12 UTC (permalink / raw)
To: Stephen Rothwell, David Sterba
Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List
在 2024/6/7 08:25, Stephen Rothwell 写道:
> Hi all,
>
> Today's linux-next merge of the btrfs tree got a conflict in:
>
> fs/btrfs/extent_io.c
>
> between commit:
>
> d202776a44d5 ("btrfs: protect folio::private when attaching extent buffer folios")
>
> from the btrfs-fixes tree and commit:
>
> 46cda5a0ef68 ("btrfs: fix a possible race window when allocating new extent buffers")
>
> from the btrfs tree.
>
> I fixed it up (I just used the latter) and can carry the fix as
> necessary.
Please use the one titled "btrfs: protect folio::private when attaching
extent buffer folios" instead.
The one titled "btrfs: fix a possible race window when allocating new
extent buffers" has a bug that would lead to a crash when a race happens.
> This is now fixed as far as linux-next is concerned, but any
> non trivial conflicts should be mentioned to your upstream maintainer
> when your tree is submitted for merging. You may also want to consider
> cooperating with the maintainer of the conflicting tree to minimise any
> particularly complex conflicts.
>
The "fix a possible race" one is originally a RFC without proper root
cause pinned down, nor enough determining tests.
Considering it's an urgent bug we're pushing that RFC fix for testing.
But now we have pinned down the root cause and have done enough tests,
the older RFC one can be gone.
Sorry for the inconvenience.
Thanks,
Qu
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2025-09-18 11:26 Mark Brown
0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2025-09-18 11:26 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
Qu Wenruo
[-- Attachment #1: Type: text/plain, Size: 835 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/compression.c
between commit:
4b63a8a8330e2 ("btrfs: reject invalid compression level")
from the btrfs-fixes tree and commit:
6e8a10e90f2d4 ("btrfs: reject invalid compression level")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --cc fs/btrfs/compression.c
index 5329712d5dfb0,c865e0f2a7e87..0000000000000
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2026-03-17 13:48 Mark Brown
0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2026-03-17 13:48 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Linux Kernel Mailing List, Linux Next Mailing List,
Qu Wenruo
[-- Attachment #1: Type: text/plain, Size: 2357 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/compression.c
between commits:
65ee6061388b3 ("btrfs: fix a bug that makes encoded write bio larger than expected")
3adf8f14152fb ("btrfs: do not touch page cache for encoded writes")
from the btrfs-fixes tree and commits:
c18bcdc0422e9 ("btrfs: reduce the size of compressed_bio")
d634a62ed907c ("btrfs: do not touch page cache for encoded writes")
bd2e495aacd58 ("btrfs: fix a bug that makes encoded write bio larger than expected")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined fs/btrfs/compression.c
index 85199944c1ebe,192f133d9eb58..0000000000000
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@@ -224,7 -224,6 +224,6 @@@ void btrfs_free_compr_folio(struct foli
return;
free:
- ASSERT(folio_ref_count(folio) == 1);
folio_put(folio);
}
@@@ -292,7 -291,7 +291,7 @@@ static void end_bbio_compressed_write(s
struct compressed_bio *cb = to_compressed_bio(bbio);
struct folio_iter fi;
- btrfs_finish_ordered_extent(cb->bbio.ordered, NULL, cb->start, cb->len,
+ btrfs_finish_ordered_extent(cb->bbio.ordered, cb->start, cb->len,
cb->bbio.bio.bi_status == BLK_STS_OK);
if (cb->writeback)
@@@ -330,7 -329,6 +329,6 @@@ void btrfs_submit_compressed_write(stru
cb->start = ordered->file_offset;
cb->len = ordered->num_bytes;
ASSERT(cb->bbio.bio.bi_iter.bi_size == ordered->disk_num_bytes);
- cb->compressed_len = ordered->disk_num_bytes;
cb->bbio.bio.bi_iter.bi_sector = ordered->disk_bytenr >> SECTOR_SHIFT;
cb->bbio.ordered = ordered;
@@@ -560,7 -558,6 +558,6 @@@ void btrfs_submit_compressed_read(struc
em_start = em->start;
cb->len = bbio->bio.bi_iter.bi_size;
- cb->compressed_len = compressed_len;
cb->compress_type = btrfs_extent_map_compression(em);
cb->orig_bbio = bbio;
cb->bbio.csum_search_commit_root = bbio->csum_search_commit_root;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2026-03-17 13:48 Mark Brown
0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2026-03-17 13:48 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Filipe Manana, Linux Kernel Mailing List,
Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 22045 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/disk-io.c
between commit:
50242828700f0 ("btrfs: check for NULL root after calls to btrfs_extent_root()")
from the btrfs-fixes tree and commits:
6960a23c3d592 ("btrfs: check for NULL root after calls to btrfs_extent_root()")
a1f82939d6410 ("btrfs: remove max_mirrors argument from write_all_supers()")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined fs/btrfs/disk-io.c
index 01f2dbb698326,45e6dde602744..0000000000000
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@@ -50,7 -50,6 +50,6 @@@
#include "relocation.h"
#include "scrub.h"
#include "super.h"
- #include "delayed-inode.h"
#define BTRFS_SUPER_FLAG_SUPP (BTRFS_HEADER_FLAG_WRITTEN |\
BTRFS_HEADER_FLAG_RELOC |\
@@@ -110,19 -109,26 +109,26 @@@ static void csum_tree_block(struct exte
* detect blocks that either didn't get written at all or got written
* in the wrong place.
*/
- int btrfs_buffer_uptodate(struct extent_buffer *eb, u64 parent_transid, bool atomic)
+ int btrfs_buffer_uptodate(struct extent_buffer *eb, u64 parent_transid, bool atomic,
+ const struct btrfs_tree_parent_check *check)
{
if (!extent_buffer_uptodate(eb))
return 0;
- if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
+ if (!parent_transid || btrfs_header_generation(eb) == parent_transid) {
+ /*
+ * On a cache hit, the caller may still need tree parent
+ * verification before reusing the buffer.
+ */
+ if (unlikely(check && btrfs_verify_level_key(eb, check)))
+ return -EUCLEAN;
return 1;
+ }
if (atomic)
return -EAGAIN;
- if (!extent_buffer_uptodate(eb) ||
- btrfs_header_generation(eb) != parent_transid) {
+ if (btrfs_header_generation(eb) != parent_transid) {
btrfs_err_rl(eb->fs_info,
"parent transid verify failed on logical %llu mirror %u wanted %llu found %llu",
eb->start, eb->read_mirror,
@@@ -730,7 -736,7 +736,7 @@@ void btrfs_global_root_delete(struct bt
}
struct btrfs_root *btrfs_global_root(struct btrfs_fs_info *fs_info,
- struct btrfs_key *key)
+ const struct btrfs_key *key)
{
struct rb_node *node;
struct btrfs_root *root = NULL;
@@@ -767,7 -773,7 +773,7 @@@ static u64 btrfs_global_root_id(struct
struct btrfs_root *btrfs_csum_root(struct btrfs_fs_info *fs_info, u64 bytenr)
{
- struct btrfs_key key = {
+ const struct btrfs_key key = {
.objectid = BTRFS_CSUM_TREE_OBJECTID,
.type = BTRFS_ROOT_ITEM_KEY,
.offset = btrfs_global_root_id(fs_info, bytenr),
@@@ -778,7 -784,7 +784,7 @@@
struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr)
{
- struct btrfs_key key = {
+ const struct btrfs_key key = {
.objectid = BTRFS_EXTENT_TREE_OBJECTID,
.type = BTRFS_ROOT_ITEM_KEY,
.offset = btrfs_global_root_id(fs_info, bytenr),
@@@ -994,8 -1000,11 +1000,11 @@@ static struct btrfs_root *read_tree_roo
root->node = NULL;
goto fail;
}
- if (unlikely(!btrfs_buffer_uptodate(root->node, generation, false))) {
- ret = -EIO;
+
+ ret = btrfs_buffer_uptodate(root->node, generation, false, &check);
+ if (unlikely(ret <= 0)) {
+ if (ret == 0)
+ ret = -EIO;
goto fail;
}
@@@ -2025,11 -2034,6 +2034,6 @@@ static int btrfs_replay_log(struct btrf
btrfs_put_root(log_tree_root);
return ret;
}
- if (unlikely(!extent_buffer_uptodate(log_tree_root->node))) {
- btrfs_err(fs_info, "failed to read log tree");
- btrfs_put_root(log_tree_root);
- return -EIO;
- }
/* returns with log_tree_root freed on success */
ret = btrfs_recover_log_trees(log_tree_root);
@@@ -2299,6 -2303,15 +2303,15 @@@ static int validate_sys_chunk_array(con
return -EUCLEAN;
}
+ /* It must hold at least one key and one chunk. */
+ if (unlikely(sys_array_size < sizeof(struct btrfs_disk_key) +
+ sizeof(struct btrfs_chunk))) {
+ btrfs_err(fs_info, "system chunk array too small %u < %zu",
+ sys_array_size,
+ sizeof(struct btrfs_disk_key) + sizeof(struct btrfs_chunk));
+ return -EUCLEAN;
+ }
+
while (cur < sys_array_size) {
struct btrfs_disk_key *disk_key;
struct btrfs_chunk *chunk;
@@@ -2365,11 -2378,11 +2378,11 @@@ int btrfs_validate_super(const struct b
int ret = 0;
const bool ignore_flags = btrfs_test_opt(fs_info, IGNORESUPERFLAGS);
- if (btrfs_super_magic(sb) != BTRFS_MAGIC) {
+ if (unlikely(btrfs_super_magic(sb) != BTRFS_MAGIC)) {
btrfs_err(fs_info, "no valid FS found");
ret = -EINVAL;
}
- if ((btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP)) {
+ if (unlikely(btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP)) {
if (!ignore_flags) {
btrfs_err(fs_info,
"unrecognized or unsupported super flag 0x%llx",
@@@ -2381,17 -2394,17 +2394,17 @@@
btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP);
}
}
- if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) {
+ if (unlikely(btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL)) {
btrfs_err(fs_info, "tree_root level too big: %d >= %d",
btrfs_super_root_level(sb), BTRFS_MAX_LEVEL);
ret = -EINVAL;
}
- if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) {
+ if (unlikely(btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL)) {
btrfs_err(fs_info, "chunk_root level too big: %d >= %d",
btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL);
ret = -EINVAL;
}
- if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) {
+ if (unlikely(btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL)) {
btrfs_err(fs_info, "log_root level too big: %d >= %d",
btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL);
ret = -EINVAL;
@@@ -2401,65 -2414,65 +2414,65 @@@
* Check sectorsize and nodesize first, other check will need it.
* Check all possible sectorsize(4K, 8K, 16K, 32K, 64K) here.
*/
- if (!is_power_of_2(sectorsize) || sectorsize < BTRFS_MIN_BLOCKSIZE ||
- sectorsize > BTRFS_MAX_METADATA_BLOCKSIZE) {
+ if (unlikely(!is_power_of_2(sectorsize) || sectorsize < BTRFS_MIN_BLOCKSIZE ||
+ sectorsize > BTRFS_MAX_METADATA_BLOCKSIZE)) {
btrfs_err(fs_info, "invalid sectorsize %llu", sectorsize);
ret = -EINVAL;
}
- if (!btrfs_supported_blocksize(sectorsize)) {
+ if (unlikely(!btrfs_supported_blocksize(sectorsize))) {
btrfs_err(fs_info,
"sectorsize %llu not yet supported for page size %lu",
sectorsize, PAGE_SIZE);
ret = -EINVAL;
}
- if (!is_power_of_2(nodesize) || nodesize < sectorsize ||
- nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) {
+ if (unlikely(!is_power_of_2(nodesize) || nodesize < sectorsize ||
+ nodesize > BTRFS_MAX_METADATA_BLOCKSIZE)) {
btrfs_err(fs_info, "invalid nodesize %llu", nodesize);
ret = -EINVAL;
}
- if (nodesize != le32_to_cpu(sb->__unused_leafsize)) {
+ if (unlikely(nodesize != le32_to_cpu(sb->__unused_leafsize))) {
btrfs_err(fs_info, "invalid leafsize %u, should be %llu",
le32_to_cpu(sb->__unused_leafsize), nodesize);
ret = -EINVAL;
}
/* Root alignment check */
- if (!IS_ALIGNED(btrfs_super_root(sb), sectorsize)) {
+ if (unlikely(!IS_ALIGNED(btrfs_super_root(sb), sectorsize))) {
btrfs_err(fs_info, "tree_root block unaligned: %llu",
btrfs_super_root(sb));
ret = -EINVAL;
}
- if (!IS_ALIGNED(btrfs_super_chunk_root(sb), sectorsize)) {
+ if (unlikely(!IS_ALIGNED(btrfs_super_chunk_root(sb), sectorsize))) {
btrfs_err(fs_info, "chunk_root block unaligned: %llu",
btrfs_super_chunk_root(sb));
ret = -EINVAL;
}
- if (!IS_ALIGNED(btrfs_super_log_root(sb), sectorsize)) {
+ if (unlikely(!IS_ALIGNED(btrfs_super_log_root(sb), sectorsize))) {
btrfs_err(fs_info, "log_root block unaligned: %llu",
btrfs_super_log_root(sb));
ret = -EINVAL;
}
- if (!fs_info->fs_devices->temp_fsid &&
- memcmp(fs_info->fs_devices->fsid, sb->fsid, BTRFS_FSID_SIZE) != 0) {
+ if (unlikely(!fs_info->fs_devices->temp_fsid &&
+ memcmp(fs_info->fs_devices->fsid, sb->fsid, BTRFS_FSID_SIZE) != 0)) {
btrfs_err(fs_info,
"superblock fsid doesn't match fsid of fs_devices: %pU != %pU",
sb->fsid, fs_info->fs_devices->fsid);
ret = -EINVAL;
}
- if (memcmp(fs_info->fs_devices->metadata_uuid, btrfs_sb_fsid_ptr(sb),
- BTRFS_FSID_SIZE) != 0) {
+ if (unlikely(memcmp(fs_info->fs_devices->metadata_uuid, btrfs_sb_fsid_ptr(sb),
+ BTRFS_FSID_SIZE) != 0)) {
btrfs_err(fs_info,
"superblock metadata_uuid doesn't match metadata uuid of fs_devices: %pU != %pU",
btrfs_sb_fsid_ptr(sb), fs_info->fs_devices->metadata_uuid);
ret = -EINVAL;
}
- if (memcmp(fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid,
- BTRFS_FSID_SIZE) != 0) {
+ if (unlikely(memcmp(fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid,
+ BTRFS_FSID_SIZE) != 0)) {
btrfs_err(fs_info,
"dev_item UUID does not match metadata fsid: %pU != %pU",
fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid);
@@@ -2470,9 -2483,9 +2483,9 @@@
* Artificial requirement for block-group-tree to force newer features
* (free-space-tree, no-holes) so the test matrix is smaller.
*/
- if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE) &&
- (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
- !btrfs_fs_incompat(fs_info, NO_HOLES))) {
+ if (unlikely(btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE) &&
+ (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
+ !btrfs_fs_incompat(fs_info, NO_HOLES)))) {
btrfs_err(fs_info,
"block-group-tree feature requires free-space-tree and no-holes");
ret = -EINVAL;
@@@ -2483,25 -2496,25 +2496,25 @@@
* Reduce test matrix for remap tree by requiring block-group-tree
* and no-holes. Free-space-tree is a hard requirement.
*/
- if (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
- !btrfs_fs_incompat(fs_info, NO_HOLES) ||
- !btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE)) {
+ if (unlikely(!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
+ !btrfs_fs_incompat(fs_info, NO_HOLES) ||
+ !btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE))) {
btrfs_err(fs_info,
"remap-tree feature requires free-space-tree, no-holes, and block-group-tree");
ret = -EINVAL;
}
- if (btrfs_fs_incompat(fs_info, MIXED_GROUPS)) {
+ if (unlikely(btrfs_fs_incompat(fs_info, MIXED_GROUPS))) {
btrfs_err(fs_info, "remap-tree not supported with mixed-bg");
ret = -EINVAL;
}
- if (btrfs_fs_incompat(fs_info, ZONED)) {
+ if (unlikely(btrfs_fs_incompat(fs_info, ZONED))) {
btrfs_err(fs_info, "remap-tree not supported with zoned devices");
ret = -EINVAL;
}
- if (sectorsize > PAGE_SIZE) {
+ if (unlikely(sectorsize > PAGE_SIZE)) {
btrfs_err(fs_info, "remap-tree not supported when block size > page size");
ret = -EINVAL;
}
@@@ -2511,66 -2524,47 +2524,47 @@@
* Hint to catch really bogus numbers, bitflips or so, more exact checks are
* done later
*/
- if (btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb)) {
+ if (unlikely(btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb))) {
btrfs_err(fs_info, "bytes_used is too small %llu",
btrfs_super_bytes_used(sb));
ret = -EINVAL;
}
- if (!is_power_of_2(btrfs_super_stripesize(sb))) {
+ if (unlikely(!is_power_of_2(btrfs_super_stripesize(sb)))) {
btrfs_err(fs_info, "invalid stripesize %u",
btrfs_super_stripesize(sb));
ret = -EINVAL;
}
- if (btrfs_super_num_devices(sb) > (1UL << 31))
+ if (unlikely(btrfs_super_num_devices(sb) > (1UL << 31)))
btrfs_warn(fs_info, "suspicious number of devices: %llu",
btrfs_super_num_devices(sb));
- if (btrfs_super_num_devices(sb) == 0) {
+ if (unlikely(btrfs_super_num_devices(sb) == 0)) {
btrfs_err(fs_info, "number of devices is 0");
ret = -EINVAL;
}
- if (mirror_num >= 0 &&
- btrfs_super_bytenr(sb) != btrfs_sb_offset(mirror_num)) {
- btrfs_err(fs_info, "super offset mismatch %llu != %u",
- btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET);
+ if (unlikely(mirror_num >= 0 &&
+ btrfs_super_bytenr(sb) != btrfs_sb_offset(mirror_num))) {
+ btrfs_err(fs_info, "super offset mismatch %llu != %llu",
+ btrfs_super_bytenr(sb), btrfs_sb_offset(mirror_num));
ret = -EINVAL;
}
- if (ret)
+ if (unlikely(ret))
return ret;
ret = validate_sys_chunk_array(fs_info, sb);
- /*
- * Obvious sys_chunk_array corruptions, it must hold at least one key
- * and one chunk
- */
- if (btrfs_super_sys_array_size(sb) > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) {
- btrfs_err(fs_info, "system chunk array too big %u > %u",
- btrfs_super_sys_array_size(sb),
- BTRFS_SYSTEM_CHUNK_ARRAY_SIZE);
- ret = -EINVAL;
- }
- if (btrfs_super_sys_array_size(sb) < sizeof(struct btrfs_disk_key)
- + sizeof(struct btrfs_chunk)) {
- btrfs_err(fs_info, "system chunk array too small %u < %zu",
- btrfs_super_sys_array_size(sb),
- sizeof(struct btrfs_disk_key)
- + sizeof(struct btrfs_chunk));
- ret = -EINVAL;
- }
-
/*
* The generation is a global counter, we'll trust it more than the others
* but it's still possible that it's the one that's wrong.
*/
- if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb))
+ if (unlikely(btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb)))
btrfs_warn(fs_info,
"suspicious: generation < chunk_root_generation: %llu < %llu",
btrfs_super_generation(sb),
btrfs_super_chunk_root_generation(sb));
- if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb)
- && btrfs_super_cache_generation(sb) != (u64)-1)
+ if (unlikely(btrfs_super_generation(sb) < btrfs_super_cache_generation(sb) &&
+ btrfs_super_cache_generation(sb) != (u64)-1))
btrfs_warn(fs_info,
"suspicious: generation < cache_generation: %llu < %llu",
btrfs_super_generation(sb),
@@@ -2601,7 -2595,7 +2595,7 @@@ static int btrfs_validate_write_super(s
int ret;
ret = btrfs_validate_super(fs_info, sb, -1);
- if (ret < 0)
+ if (unlikely(ret < 0))
goto out;
if (unlikely(!btrfs_supported_super_csum(btrfs_super_csum_type(sb)))) {
ret = -EUCLEAN;
@@@ -2618,7 -2612,7 +2612,7 @@@
goto out;
}
out:
- if (ret < 0)
+ if (unlikely(ret < 0))
btrfs_err(fs_info,
"super block corruption detected before writing it to disk");
return ret;
@@@ -2639,11 -2633,6 +2633,6 @@@ static int load_super_root(struct btrfs
root->node = NULL;
return ret;
}
- if (unlikely(!extent_buffer_uptodate(root->node))) {
- free_extent_buffer(root->node);
- root->node = NULL;
- return -EIO;
- }
btrfs_set_root_node(&root->root_item, root->node);
root->commit_root = btrfs_root_node(root);
@@@ -3766,8 -3755,7 +3755,7 @@@ static void btrfs_end_super_write(struc
* Write superblock @sb to the @device. Do not wait for completion, all the
* folios we use for writing are locked.
*
- * Write @max_mirrors copies of the superblock, where 0 means default that fit
- * the expected device size at commit time. Note that max_mirrors must be
+ * Write @max_mirrors copies of the superblock. Note that max_mirrors must be
* same for write and wait phases.
*
* Return number of errors when folio is not found or submission fails.
@@@ -3783,9 -3771,6 +3771,6 @@@ static int write_dev_supers(struct btrf
atomic_set(&device->sb_write_errors, 0);
- if (max_mirrors == 0)
- max_mirrors = BTRFS_SUPER_MIRROR_MAX;
-
for (i = 0; i < max_mirrors; i++) {
struct folio *folio;
struct bio *bio;
@@@ -3870,16 -3855,13 +3855,13 @@@ static int wait_dev_supers(struct btrfs
int ret;
u64 bytenr;
- if (max_mirrors == 0)
- max_mirrors = BTRFS_SUPER_MIRROR_MAX;
-
for (i = 0; i < max_mirrors; i++) {
struct folio *folio;
ret = btrfs_sb_log_location(device, i, READ, &bytenr);
if (ret == -ENOENT) {
break;
- } else if (ret < 0) {
+ } else if (unlikely(ret < 0)) {
errors++;
if (i == 0)
primary_failed = true;
@@@ -3901,9 -3883,8 +3883,8 @@@
}
errors += atomic_read(&device->sb_write_errors);
- if (errors >= BTRFS_SUPER_PRIMARY_WRITE_ERROR)
- primary_failed = true;
- if (primary_failed) {
+
+ if (unlikely(primary_failed || errors >= BTRFS_SUPER_PRIMARY_WRITE_ERROR)) {
btrfs_err(device->fs_info, "error writing primary super block to device %llu",
device->devid);
return -1;
@@@ -3954,7 -3935,7 +3935,7 @@@ static bool wait_dev_flush(struct btrfs
wait_for_completion_io(&device->flush_wait);
- if (bio->bi_status) {
+ if (unlikely(bio->bi_status)) {
set_bit(BTRFS_DEV_STATE_FLUSH_FAILED, &device->dev_state);
btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_FLUSH_ERRS);
return true;
@@@ -3992,7 -3973,7 +3973,7 @@@ static int barrier_all_devices(struct b
list_for_each_entry(dev, head, dev_list) {
if (test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state))
continue;
- if (!dev->bdev) {
+ if (unlikely(!dev->bdev)) {
errors_wait++;
continue;
}
@@@ -4000,7 -3981,7 +3981,7 @@@
!test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
continue;
- if (wait_dev_flush(dev))
+ if (unlikely(wait_dev_flush(dev)))
errors_wait++;
}
@@@ -4043,26 -4024,27 +4024,27 @@@ int btrfs_get_num_tolerated_disk_barrie
return min_tolerated;
}
- int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
+ int write_all_supers(struct btrfs_trans_handle *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct list_head *head;
struct btrfs_device *dev;
struct btrfs_super_block *sb;
struct btrfs_dev_item *dev_item;
+ int max_mirrors;
int ret;
int do_barriers;
int max_errors;
int total_errors = 0;
- u64 flags;
do_barriers = !btrfs_test_opt(fs_info, NOBARRIER);
- /*
- * max_mirrors == 0 indicates we're from commit_transaction,
- * not from fsync where the tree roots in fs_info have not
- * been consistent on disk.
- */
- if (max_mirrors == 0) {
+ if (trans->transaction->state < TRANS_STATE_UNBLOCKED) {
+ /* We are called from fsync. */
+ max_mirrors = 1;
+ } else {
+ /* We are called from transaction commit. */
+ max_mirrors = BTRFS_SUPER_MIRROR_MAX;
ret = backup_super_roots(fs_info);
if (ret < 0)
return ret;
@@@ -4077,17 -4059,19 +4059,19 @@@
if (do_barriers) {
ret = barrier_all_devices(fs_info);
- if (ret) {
+ if (unlikely(ret)) {
mutex_unlock(
&fs_info->fs_devices->device_list_mutex);
- btrfs_handle_fs_error(fs_info, ret,
- "errors while submitting device barriers.");
+ btrfs_abort_transaction(trans, ret);
+ btrfs_err(fs_info, "error while submitting device barriers");
return ret;
}
}
+ btrfs_set_super_flags(sb, btrfs_super_flags(sb) | BTRFS_HEADER_FLAG_WRITTEN);
+
list_for_each_entry(dev, head, dev_list) {
- if (!dev->bdev) {
+ if (unlikely(!dev->bdev)) {
total_errors++;
continue;
}
@@@ -4109,19 -4093,17 +4093,17 @@@
memcpy(dev_item->fsid, dev->fs_devices->metadata_uuid,
BTRFS_FSID_SIZE);
- flags = btrfs_super_flags(sb);
- btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN);
-
ret = btrfs_validate_write_super(fs_info, sb);
if (unlikely(ret < 0)) {
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
- btrfs_handle_fs_error(fs_info, -EUCLEAN,
- "unexpected superblock corruption detected");
- return -EUCLEAN;
+ btrfs_abort_transaction(trans, ret);
+ btrfs_err(fs_info,
+ "unexpected superblock corruption before writing it");
+ return ret;
}
ret = write_dev_supers(dev, sb, max_mirrors);
- if (ret)
+ if (unlikely(ret))
total_errors++;
}
if (unlikely(total_errors > max_errors)) {
@@@ -4130,29 -4112,27 +4112,27 @@@
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
/* FUA is masked off if unsupported and can't be the reason */
- btrfs_handle_fs_error(fs_info, -EIO,
- "%d errors while writing supers",
- total_errors);
+ btrfs_abort_transaction(trans, -EIO);
+ btrfs_err(fs_info, "%d errors while writing supers", total_errors);
return -EIO;
}
total_errors = 0;
list_for_each_entry(dev, head, dev_list) {
- if (!dev->bdev)
+ if (unlikely(!dev->bdev))
continue;
if (!test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &dev->dev_state) ||
!test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
continue;
ret = wait_dev_supers(dev, max_mirrors);
- if (ret)
+ if (unlikely(ret))
total_errors++;
}
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
if (unlikely(total_errors > max_errors)) {
- btrfs_handle_fs_error(fs_info, -EIO,
- "%d errors while writing supers",
- total_errors);
+ btrfs_abort_transaction(trans, -EIO);
+ btrfs_err(fs_info, "%d errors while writing supers", total_errors);
return -EIO;
}
return 0;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2026-03-17 13:48 Mark Brown
0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2026-03-17 13:48 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Filipe Manana, Linux Kernel Mailing List,
Linux Next Mailing List, Qu Wenruo
[-- Attachment #1: Type: text/plain, Size: 21987 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/inode.c
between commit:
2b4cb4e58f346 ("btrfs: check for NULL root after calls to btrfs_csum_root()")
from the btrfs-fixes tree and commits:
95c2b73d28d71 ("btrfs: check for NULL root after calls to btrfs_csum_root()")
0d0b5f693bf44 ("btrfs: make add_pending_csums() to take an ordered extent as parameter")
30525e90e1e86 ("btrfs: rename btrfs_csum_file_blocks() to btrfs_insert_data_csums()")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined fs/btrfs/inode.c
index f643a05208720,8d97a8ad3858b..0000000000000
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@@ -74,7 -74,6 +74,6 @@@
#include "delayed-inode.h"
#define COW_FILE_RANGE_KEEP_LOCKED (1UL << 0)
- #define COW_FILE_RANGE_NO_INLINE (1UL << 1)
struct btrfs_iget_args {
u64 ino;
@@@ -424,7 -423,7 +423,7 @@@ static inline void btrfs_cleanup_ordere
folio_put(folio);
}
- return btrfs_mark_ordered_io_finished(inode, NULL, offset, bytes, false);
+ return btrfs_mark_ordered_io_finished(inode, offset, bytes, false);
}
static int btrfs_dirty_inode(struct btrfs_inode *inode);
@@@ -622,6 -621,10 +621,10 @@@ static bool can_cow_file_range_inline(s
*
* If being used directly, you must have already checked we're allowed to cow
* the range by getting true from can_cow_file_range_inline().
+ *
+ * Return 0 if the inlined extent is created successfully.
+ * Return <0 for critical error, and should be considered as an writeback error.
+ * Return >0 if can not create an inlined extent (mostly due to lack of meta space).
*/
static noinline int __cow_file_range_inline(struct btrfs_inode *inode,
u64 size, size_t compressed_size,
@@@ -703,55 -706,6 +706,6 @@@ out
return ret;
}
- static noinline int cow_file_range_inline(struct btrfs_inode *inode,
- struct folio *locked_folio,
- u64 offset, u64 end,
- size_t compressed_size,
- int compress_type,
- struct folio *compressed_folio,
- bool update_i_size)
- {
- struct extent_state *cached = NULL;
- unsigned long clear_flags = EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
- EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING | EXTENT_LOCKED;
- u64 size = min_t(u64, i_size_read(&inode->vfs_inode), end + 1);
- int ret;
-
- if (!can_cow_file_range_inline(inode, offset, size, compressed_size))
- return 1;
-
- btrfs_lock_extent(&inode->io_tree, offset, end, &cached);
- ret = __cow_file_range_inline(inode, size, compressed_size,
- compress_type, compressed_folio,
- update_i_size);
- if (ret > 0) {
- btrfs_unlock_extent(&inode->io_tree, offset, end, &cached);
- return ret;
- }
-
- /*
- * In the successful case (ret == 0 here), cow_file_range will return 1.
- *
- * Quite a bit further up the callstack in extent_writepage(), ret == 1
- * is treated as a short circuited success and does not unlock the folio,
- * so we must do it here.
- *
- * In the failure case, the locked_folio does get unlocked by
- * btrfs_folio_end_all_writers, which asserts that it is still locked
- * at that point, so we must *not* unlock it here.
- *
- * The other two callsites in compress_file_range do not have a
- * locked_folio, so they are not relevant to this logic.
- */
- if (ret == 0)
- locked_folio = NULL;
-
- extent_clear_unlock_delalloc(inode, offset, end, locked_folio, &cached,
- clear_flags, PAGE_UNLOCK |
- PAGE_START_WRITEBACK | PAGE_END_WRITEBACK);
- return ret;
- }
-
struct async_extent {
u64 start;
u64 ram_size;
@@@ -797,7 -751,7 +751,7 @@@ static int add_async_extent(struct asyn
* options, defragmentation, properties or heuristics.
*/
static inline int inode_need_compress(struct btrfs_inode *inode, u64 start,
- u64 end)
+ u64 end, bool check_inline)
{
struct btrfs_fs_info *fs_info = inode->root->fs_info;
@@@ -811,8 -765,10 +765,10 @@@
* do not even bother try compression, as there will be no space saving
* and will always fallback to regular write later.
*/
- if (start != 0 && end + 1 - start <= fs_info->sectorsize)
+ if (end + 1 - start <= fs_info->sectorsize &&
+ (!check_inline || (start > 0 || end + 1 < inode->disk_i_size)))
return 0;
+
/* Defrag ioctl takes precedence over mount options and properties. */
if (inode->defrag_compress == BTRFS_DEFRAG_DONT_COMPRESS)
return 0;
@@@ -890,28 -846,20 +846,20 @@@ static struct folio *compressed_bio_las
return page_folio(phys_to_page(paddr));
}
- static void zero_last_folio(struct compressed_bio *cb)
- {
- struct bio *bio = &cb->bbio.bio;
- struct folio *last_folio = compressed_bio_last_folio(cb);
- const u32 bio_size = bio->bi_iter.bi_size;
- const u32 foffset = offset_in_folio(last_folio, bio_size);
-
- folio_zero_range(last_folio, foffset, folio_size(last_folio) - foffset);
- }
-
static void round_up_last_block(struct compressed_bio *cb, u32 blocksize)
{
struct bio *bio = &cb->bbio.bio;
struct folio *last_folio = compressed_bio_last_folio(cb);
const u32 bio_size = bio->bi_iter.bi_size;
const u32 foffset = offset_in_folio(last_folio, bio_size);
+ const u32 padding_len = round_up(foffset, blocksize) - foffset;
bool ret;
if (IS_ALIGNED(bio_size, blocksize))
return;
- ret = bio_add_folio(bio, last_folio, round_up(foffset, blocksize) - foffset, foffset);
+ folio_zero_range(last_folio, foffset, padding_len);
+ ret = bio_add_folio(bio, last_folio, padding_len, foffset);
/* The remaining part should be merged thus never fail. */
ASSERT(ret);
}
@@@ -935,9 -883,7 +883,7 @@@ static void compress_file_range(struct
container_of(work, struct async_chunk, work);
struct btrfs_inode *inode = async_chunk->inode;
struct btrfs_fs_info *fs_info = inode->root->fs_info;
- struct address_space *mapping = inode->vfs_inode.i_mapping;
struct compressed_bio *cb = NULL;
- const u32 min_folio_size = btrfs_min_folio_size(fs_info);
u64 blocksize = fs_info->sectorsize;
u64 start = async_chunk->start;
u64 end = async_chunk->end;
@@@ -947,7 -893,6 +893,6 @@@
int ret = 0;
unsigned long total_compressed = 0;
unsigned long total_in = 0;
- unsigned int loff;
int compress_type = fs_info->compress_type;
int compress_level = fs_info->compress_level;
@@@ -1009,7 -954,7 +954,7 @@@ again
* been flagged as NOCOMPRESS. This flag can change at any time if we
* discover bad compression ratios.
*/
- if (!inode_need_compress(inode, start, end))
+ if (!inode_need_compress(inode, start, end, false))
goto cleanup_and_bail_uncompressed;
if (0 < inode->defrag_compress && inode->defrag_compress < BTRFS_NR_COMPRESS_TYPES) {
@@@ -1030,43 -975,13 +975,13 @@@
total_compressed = cb->bbio.bio.bi_iter.bi_size;
total_in = cur_len;
- /*
- * Zero the tail end of the last folio, as we might be sending it down
- * to disk.
- */
- loff = (total_compressed & (min_folio_size - 1));
- if (loff)
- zero_last_folio(cb);
-
- /*
- * Try to create an inline extent.
- *
- * If we didn't compress the entire range, try to create an uncompressed
- * inline extent, else a compressed one.
- *
- * Check cow_file_range() for why we don't even try to create inline
- * extent for the subpage case.
- */
- if (total_in < actual_end)
- ret = cow_file_range_inline(inode, NULL, start, end, 0,
- BTRFS_COMPRESS_NONE, NULL, false);
- else
- ret = cow_file_range_inline(inode, NULL, start, end, total_compressed,
- compress_type,
- bio_first_folio_all(&cb->bbio.bio), false);
- if (ret <= 0) {
- cleanup_compressed_bio(cb);
- if (ret < 0)
- mapping_set_error(mapping, -EIO);
- return;
- }
-
/*
* We aren't doing an inline extent. Round the compressed size up to a
* block size boundary so the allocator does sane things.
*/
- total_compressed = ALIGN(total_compressed, blocksize);
round_up_last_block(cb, blocksize);
+ total_compressed = cb->bbio.bio.bi_iter.bi_size;
+ ASSERT(IS_ALIGNED(total_compressed, blocksize));
/*
* One last check to make sure the compression is really a win, compare
@@@ -1437,11 -1352,6 +1352,6 @@@ free_reserved
*
* When this function fails, it unlocks all folios except @locked_folio.
*
- * When this function successfully creates an inline extent, it returns 1 and
- * unlocks all folios including locked_folio and starts I/O on them.
- * (In reality inline extents are limited to a single block, so locked_folio is
- * the only folio handled anyway).
- *
* When this function succeed and creates a normal extent, the folio locking
* status depends on the passed in flags:
*
@@@ -1485,25 -1395,6 +1395,6 @@@ static noinline int cow_file_range(stru
ASSERT(num_bytes <= btrfs_super_total_bytes(fs_info->super_copy));
inode_should_defrag(inode, start, end, num_bytes, SZ_64K);
-
- if (!(flags & COW_FILE_RANGE_NO_INLINE)) {
- /* lets try to make an inline extent */
- ret = cow_file_range_inline(inode, locked_folio, start, end, 0,
- BTRFS_COMPRESS_NONE, NULL, false);
- if (ret <= 0) {
- /*
- * We succeeded, return 1 so the caller knows we're done
- * with this page and already handled the IO.
- *
- * If there was an error then cow_file_range_inline() has
- * already done the cleanup.
- */
- if (ret == 0)
- ret = 1;
- goto done;
- }
- }
-
alloc_hint = btrfs_get_extent_allocation_hint(inode, start, num_bytes);
/*
@@@ -1581,7 -1472,6 +1472,6 @@@
}
extent_clear_unlock_delalloc(inode, orig_start, end, locked_folio, &cached,
EXTENT_LOCKED | EXTENT_DELALLOC, page_ops);
- done:
if (done_offset)
*done_offset = end;
return ret;
@@@ -1701,7 -1591,7 +1591,7 @@@ static bool run_delalloc_compressed(str
struct async_cow *ctx;
struct async_chunk *async_chunk;
unsigned long nr_pages;
- u64 num_chunks = DIV_ROUND_UP(end - start, SZ_512K);
+ u64 num_chunks = DIV_ROUND_UP(end - start, BTRFS_COMPRESSION_CHUNK_SIZE);
int i;
unsigned nofs_flag;
const blk_opf_t write_flags = wbc_to_write_flags(wbc);
@@@ -1718,7 -1608,7 +1608,7 @@@
atomic_set(&ctx->num_chunks, num_chunks);
for (i = 0; i < num_chunks; i++) {
- u64 cur_end = min(end, start + SZ_512K - 1);
+ u64 cur_end = min(end, start + BTRFS_COMPRESSION_CHUNK_SIZE - 1);
/*
* igrab is called higher up in the call chain, take only the
@@@ -1853,7 -1743,7 +1743,7 @@@ static int fallback_to_cow(struct btrfs
*/
btrfs_lock_extent(io_tree, start, end, &cached_state);
count = btrfs_count_range_bits(io_tree, &range_start, end, range_bytes,
- EXTENT_NORESERVE, 0, NULL);
+ EXTENT_NORESERVE, false, NULL);
if (count > 0 || is_space_ino || is_reloc_ino) {
u64 bytes = count;
struct btrfs_fs_info *fs_info = inode->root->fs_info;
@@@ -1884,7 -1774,7 +1774,7 @@@
* a locked folio, which can race with writeback.
*/
ret = cow_file_range(inode, locked_folio, start, end, NULL,
- COW_FILE_RANGE_NO_INLINE | COW_FILE_RANGE_KEEP_LOCKED);
+ COW_FILE_RANGE_KEEP_LOCKED);
ASSERT(ret != 1);
return ret;
}
@@@ -1936,6 -1826,11 +1826,11 @@@ static int can_nocow_file_extent(struc
int ret = 0;
bool nowait = path->nowait;
+ /* If there are pending snapshots for this root, we must do COW. */
+ if (args->writeback_path && !is_freespace_inode &&
+ atomic_read(&root->snapshot_force_cow))
+ goto out;
+
fi = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item);
extent_type = btrfs_file_extent_type(leaf, fi);
@@@ -1997,11 -1892,6 +1892,6 @@@
path = NULL;
}
- /* If there are pending snapshots for this root, we must COW. */
- if (args->writeback_path && !is_freespace_inode &&
- atomic_read(&root->snapshot_force_cow))
- goto out;
-
args->file_extent.num_bytes = min(args->end + 1, extent_end) - args->start;
args->file_extent.offset += args->start - key->offset;
io_start = args->file_extent.disk_bytenr + args->file_extent.offset;
@@@ -2435,6 -2325,91 +2325,91 @@@ static bool should_nocow(struct btrfs_i
return false;
}
+ /*
+ * Return 0 if an inlined extent is created successfully.
+ * Return <0 if critical error happened.
+ * Return >0 if an inline extent can not be created.
+ */
+ static int run_delalloc_inline(struct btrfs_inode *inode, struct folio *locked_folio)
+ {
+ struct btrfs_fs_info *fs_info = inode->root->fs_info;
+ struct compressed_bio *cb = NULL;
+ struct extent_state *cached = NULL;
+ const u64 i_size = i_size_read(&inode->vfs_inode);
+ const u32 blocksize = fs_info->sectorsize;
+ int compress_type = fs_info->compress_type;
+ int compress_level = fs_info->compress_level;
+ u32 compressed_size = 0;
+ int ret;
+
+ ASSERT(folio_pos(locked_folio) == 0);
+
+ if (btrfs_inode_can_compress(inode) &&
+ inode_need_compress(inode, 0, blocksize, true)) {
+ if (inode->defrag_compress > 0 &&
+ inode->defrag_compress < BTRFS_NR_COMPRESS_TYPES) {
+ compress_type = inode->defrag_compress;
+ compress_level = inode->defrag_compress_level;
+ } else if (inode->prop_compress) {
+ compress_type = inode->prop_compress;
+ }
+ cb = btrfs_compress_bio(inode, 0, blocksize, compress_type, compress_level, 0);
+ if (IS_ERR(cb)) {
+ cb = NULL;
+ /* Just fall back to non-compressed case. */
+ } else {
+ compressed_size = cb->bbio.bio.bi_iter.bi_size;
+ }
+ }
+ if (!can_cow_file_range_inline(inode, 0, i_size, compressed_size)) {
+ if (cb)
+ cleanup_compressed_bio(cb);
+ return 1;
+ }
+
+ btrfs_lock_extent(&inode->io_tree, 0, blocksize - 1, &cached);
+ if (cb) {
+ ret = __cow_file_range_inline(inode, i_size, compressed_size, compress_type,
+ bio_first_folio_all(&cb->bbio.bio), false);
+ cleanup_compressed_bio(cb);
+ cb = NULL;
+ } else {
+ ret = __cow_file_range_inline(inode, i_size, 0, BTRFS_COMPRESS_NONE,
+ NULL, false);
+ }
+ /*
+ * We failed to insert inline extent due to lack of meta space.
+ * Just unlock the extent io range and fallback to regular COW/NOCOW path.
+ */
+ if (ret > 0) {
+ btrfs_unlock_extent(&inode->io_tree, 0, blocksize - 1, &cached);
+ return ret;
+ }
+
+ /*
+ * In the successful case (ret == 0 here), btrfs_run_delalloc_range()
+ * will return 1.
+ *
+ * Quite a bit further up the callstack in extent_writepage(), ret == 1
+ * is treated as a short circuited success and does not unlock the folio,
+ * so we must do it here.
+ *
+ * For failure case, the @locked_folio does get unlocked by
+ * btrfs_folio_end_lock_bitmap(), so we must *not* unlock it here.
+ *
+ * So if ret == 0, we let extent_clear_unlock_delalloc() to unlock the
+ * folio by passing NULL as @locked_folio.
+ * Otherwise pass @locked_folio as usual.
+ */
+ if (ret == 0)
+ locked_folio = NULL;
+ extent_clear_unlock_delalloc(inode, 0, blocksize - 1, locked_folio, &cached,
+ EXTENT_DELALLOC | EXTENT_DELALLOC_NEW | EXTENT_DEFRAG |
+ EXTENT_DO_ACCOUNTING | EXTENT_LOCKED,
+ PAGE_UNLOCK | PAGE_START_WRITEBACK | PAGE_END_WRITEBACK);
+ return ret;
+ }
+
/*
* Function to process delayed allocation (create CoW) for ranges which are
* being touched for the first time.
@@@ -2451,11 -2426,26 +2426,26 @@@ int btrfs_run_delalloc_range(struct btr
ASSERT(!(end <= folio_pos(locked_folio) ||
start >= folio_next_pos(locked_folio)));
+ if (start == 0 && end + 1 <= inode->root->fs_info->sectorsize &&
+ end + 1 >= inode->disk_i_size) {
+ int ret;
+
+ ret = run_delalloc_inline(inode, locked_folio);
+ if (ret < 0)
+ return ret;
+ if (ret == 0)
+ return 1;
+ /*
+ * Continue regular handling if we can not create an
+ * inlined extent.
+ */
+ }
+
if (should_nocow(inode, start, end))
return run_delalloc_nocow(inode, locked_folio, start, end);
if (btrfs_inode_can_compress(inode) &&
- inode_need_compress(inode, start, end) &&
+ inode_need_compress(inode, start, end, false) &&
run_delalloc_compressed(inode, locked_folio, start, end, wbc))
return 1;
@@@ -2745,17 -2735,19 +2735,19 @@@ void btrfs_clear_delalloc_extent(struc
}
/*
- * given a list of ordered sums record them in the inode. This happens
- * at IO completion time based on sums calculated at bio submission time.
+ * Given an ordered extent and insert all its checksums into the csum tree.
+ *
+ * This happens at IO completion time based on sums calculated at bio
+ * submission time.
*/
static int add_pending_csums(struct btrfs_trans_handle *trans,
- struct list_head *list)
+ struct btrfs_ordered_extent *oe)
{
struct btrfs_ordered_sum *sum;
struct btrfs_root *csum_root = NULL;
int ret;
- list_for_each_entry(sum, list, list) {
+ list_for_each_entry(sum, &oe->csum_list, list) {
if (!csum_root) {
csum_root = btrfs_csum_root(trans->fs_info,
sum->logical);
@@@ -2767,7 -2759,7 +2759,7 @@@
}
}
trans->adding_csums = true;
- ret = btrfs_csum_file_blocks(trans, csum_root, sum);
+ ret = btrfs_insert_data_csums(trans, csum_root, sum);
trans->adding_csums = false;
if (ret)
return ret;
@@@ -2956,7 -2948,9 +2948,9 @@@ out_page
* to reflect the errors and clean the page.
*/
mapping_set_error(folio->mapping, ret);
- btrfs_mark_ordered_io_finished(inode, folio, page_start,
+ btrfs_folio_clear_ordered(fs_info, folio, page_start,
+ folio_size(folio));
+ btrfs_mark_ordered_io_finished(inode, page_start,
folio_size(folio), !ret);
folio_clear_dirty_for_io(folio);
}
@@@ -3271,8 -3265,8 +3265,8 @@@ int btrfs_finish_one_ordered(struct btr
if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
/* Logic error */
- ASSERT(list_empty(&ordered_extent->list));
- if (unlikely(!list_empty(&ordered_extent->list))) {
+ ASSERT(list_empty(&ordered_extent->csum_list));
+ if (unlikely(!list_empty(&ordered_extent->csum_list))) {
ret = -EINVAL;
btrfs_abort_transaction(trans, ret);
goto out;
@@@ -3321,7 -3315,7 +3315,7 @@@
goto out;
}
- ret = add_pending_csums(trans, &ordered_extent->list);
+ ret = add_pending_csums(trans, ordered_extent);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
goto out;
@@@ -3427,7 -3421,7 +3421,7 @@@ out
* This needs to be done to make sure anybody waiting knows we are done
* updating everything for this ordered extent.
*/
- btrfs_remove_ordered_extent(inode, ordered_extent);
+ btrfs_remove_ordered_extent(ordered_extent);
/* once for us */
btrfs_put_ordered_extent(ordered_extent);
@@@ -4697,7 -4691,7 +4691,7 @@@ static noinline int may_destroy_subvol(
dir_id = btrfs_super_root_dir(fs_info->super_copy);
di = btrfs_lookup_dir_item(NULL, fs_info->tree_root, path,
dir_id, &name, 0);
- if (di && !IS_ERR(di)) {
+ if (!IS_ERR_OR_NULL(di)) {
btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key);
if (key.objectid == btrfs_root_id(root)) {
ret = -EPERM;
@@@ -6859,7 -6853,7 +6853,7 @@@ int btrfs_create_new_inode(struct btrfs
}
} else {
ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name,
- 0, BTRFS_I(inode)->dir_index);
+ false, BTRFS_I(inode)->dir_index);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
goto discard;
@@@ -7075,7 -7069,7 +7069,7 @@@ static int btrfs_link(struct dentry *ol
inode_set_ctime_current(inode);
ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
- &fname.disk_name, 1, index);
+ &fname.disk_name, true, index);
if (ret)
goto fail;
@@@ -8173,7 -8167,7 +8167,7 @@@ void btrfs_destroy_inode(struct inode *
if (!freespace_inode)
btrfs_lockdep_acquire(root->fs_info, btrfs_ordered_extent);
- btrfs_remove_ordered_extent(inode, ordered);
+ btrfs_remove_ordered_extent(ordered);
btrfs_put_ordered_extent(ordered);
btrfs_put_ordered_extent(ordered);
}
@@@ -8495,14 -8489,14 +8489,14 @@@ static int btrfs_rename_exchange(struc
}
ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
- new_name, 0, old_idx);
+ new_name, false, old_idx);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
goto out_fail;
}
ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode),
- old_name, 0, new_idx);
+ old_name, false, new_idx);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
goto out_fail;
@@@ -8793,7 -8787,7 +8787,7 @@@ static int btrfs_rename(struct mnt_idma
}
ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
- &new_fname.disk_name, 0, index);
+ &new_fname.disk_name, false, index);
if (unlikely(ret)) {
btrfs_abort_transaction(trans, ret);
goto out_fail;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2026-03-24 13:25 Mark Brown
0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2026-03-24 13:25 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Filipe Manana, Linux Kernel Mailing List,
Linux Next Mailing List, Mark Harmstone
[-- Attachment #1: Type: text/plain, Size: 21851 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got conflicts in:
fs/btrfs/disk-io.c
between commit:
b52fe51f72438 ("btrfs: fix super block offset in error message in btrfs_validate_super()")
from the btrfs-fixes tree and commit:
5814cb220921a ("btrfs: mark all error and warning checks as unlikely in btrfs_validate_super()")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined fs/btrfs/disk-io.c
index 1b0eb246b7147,c835141ee384f..0000000000000
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@@ -50,7 -50,6 +50,6 @@@
#include "relocation.h"
#include "scrub.h"
#include "super.h"
- #include "delayed-inode.h"
#define BTRFS_SUPER_FLAG_SUPP (BTRFS_HEADER_FLAG_WRITTEN |\
BTRFS_HEADER_FLAG_RELOC |\
@@@ -110,19 -109,23 +109,23 @@@ static void csum_tree_block(struct exte
* detect blocks that either didn't get written at all or got written
* in the wrong place.
*/
- int btrfs_buffer_uptodate(struct extent_buffer *eb, u64 parent_transid, bool atomic)
+ int btrfs_buffer_uptodate(struct extent_buffer *eb, u64 parent_transid,
+ const struct btrfs_tree_parent_check *check)
{
if (!extent_buffer_uptodate(eb))
return 0;
- if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
+ if (!parent_transid || btrfs_header_generation(eb) == parent_transid) {
+ /*
+ * On a cache hit, the caller may still need tree parent
+ * verification before reusing the buffer.
+ */
+ if (unlikely(check && btrfs_verify_level_key(eb, check)))
+ return -EUCLEAN;
return 1;
+ }
- if (atomic)
- return -EAGAIN;
-
- if (!extent_buffer_uptodate(eb) ||
- btrfs_header_generation(eb) != parent_transid) {
+ if (btrfs_header_generation(eb) != parent_transid) {
btrfs_err_rl(eb->fs_info,
"parent transid verify failed on logical %llu mirror %u wanted %llu found %llu",
eb->start, eb->read_mirror,
@@@ -730,7 -733,7 +733,7 @@@ void btrfs_global_root_delete(struct bt
}
struct btrfs_root *btrfs_global_root(struct btrfs_fs_info *fs_info,
- struct btrfs_key *key)
+ const struct btrfs_key *key)
{
struct rb_node *node;
struct btrfs_root *root = NULL;
@@@ -767,7 -770,7 +770,7 @@@ static u64 btrfs_global_root_id(struct
struct btrfs_root *btrfs_csum_root(struct btrfs_fs_info *fs_info, u64 bytenr)
{
- struct btrfs_key key = {
+ const struct btrfs_key key = {
.objectid = BTRFS_CSUM_TREE_OBJECTID,
.type = BTRFS_ROOT_ITEM_KEY,
.offset = btrfs_global_root_id(fs_info, bytenr),
@@@ -778,7 -781,7 +781,7 @@@
struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr)
{
- struct btrfs_key key = {
+ const struct btrfs_key key = {
.objectid = BTRFS_EXTENT_TREE_OBJECTID,
.type = BTRFS_ROOT_ITEM_KEY,
.offset = btrfs_global_root_id(fs_info, bytenr),
@@@ -994,8 -997,11 +997,11 @@@ static struct btrfs_root *read_tree_roo
root->node = NULL;
goto fail;
}
- if (unlikely(!btrfs_buffer_uptodate(root->node, generation, false))) {
- ret = -EIO;
+
+ ret = btrfs_buffer_uptodate(root->node, generation, &check);
+ if (unlikely(ret <= 0)) {
+ if (ret == 0)
+ ret = -EIO;
goto fail;
}
@@@ -2025,11 -2031,6 +2031,6 @@@ static int btrfs_replay_log(struct btrf
btrfs_put_root(log_tree_root);
return ret;
}
- if (unlikely(!extent_buffer_uptodate(log_tree_root->node))) {
- btrfs_err(fs_info, "failed to read log tree");
- btrfs_put_root(log_tree_root);
- return -EIO;
- }
/* returns with log_tree_root freed on success */
ret = btrfs_recover_log_trees(log_tree_root);
@@@ -2299,6 -2300,15 +2300,15 @@@ static int validate_sys_chunk_array(con
return -EUCLEAN;
}
+ /* It must hold at least one key and one chunk. */
+ if (unlikely(sys_array_size < sizeof(struct btrfs_disk_key) +
+ sizeof(struct btrfs_chunk))) {
+ btrfs_err(fs_info, "system chunk array too small %u < %zu",
+ sys_array_size,
+ sizeof(struct btrfs_disk_key) + sizeof(struct btrfs_chunk));
+ return -EUCLEAN;
+ }
+
while (cur < sys_array_size) {
struct btrfs_disk_key *disk_key;
struct btrfs_chunk *chunk;
@@@ -2365,11 -2375,11 +2375,11 @@@ int btrfs_validate_super(const struct b
int ret = 0;
const bool ignore_flags = btrfs_test_opt(fs_info, IGNORESUPERFLAGS);
- if (btrfs_super_magic(sb) != BTRFS_MAGIC) {
+ if (unlikely(btrfs_super_magic(sb) != BTRFS_MAGIC)) {
btrfs_err(fs_info, "no valid FS found");
ret = -EINVAL;
}
- if ((btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP)) {
+ if (unlikely(btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP)) {
if (!ignore_flags) {
btrfs_err(fs_info,
"unrecognized or unsupported super flag 0x%llx",
@@@ -2381,17 -2391,17 +2391,17 @@@
btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP);
}
}
- if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) {
+ if (unlikely(btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL)) {
btrfs_err(fs_info, "tree_root level too big: %d >= %d",
btrfs_super_root_level(sb), BTRFS_MAX_LEVEL);
ret = -EINVAL;
}
- if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) {
+ if (unlikely(btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL)) {
btrfs_err(fs_info, "chunk_root level too big: %d >= %d",
btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL);
ret = -EINVAL;
}
- if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) {
+ if (unlikely(btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL)) {
btrfs_err(fs_info, "log_root level too big: %d >= %d",
btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL);
ret = -EINVAL;
@@@ -2401,65 -2411,65 +2411,65 @@@
* Check sectorsize and nodesize first, other check will need it.
* Check all possible sectorsize(4K, 8K, 16K, 32K, 64K) here.
*/
- if (!is_power_of_2(sectorsize) || sectorsize < BTRFS_MIN_BLOCKSIZE ||
- sectorsize > BTRFS_MAX_METADATA_BLOCKSIZE) {
+ if (unlikely(!is_power_of_2(sectorsize) || sectorsize < BTRFS_MIN_BLOCKSIZE ||
+ sectorsize > BTRFS_MAX_METADATA_BLOCKSIZE)) {
btrfs_err(fs_info, "invalid sectorsize %llu", sectorsize);
ret = -EINVAL;
}
- if (!btrfs_supported_blocksize(sectorsize)) {
+ if (unlikely(!btrfs_supported_blocksize(sectorsize))) {
btrfs_err(fs_info,
"sectorsize %llu not yet supported for page size %lu",
sectorsize, PAGE_SIZE);
ret = -EINVAL;
}
- if (!is_power_of_2(nodesize) || nodesize < sectorsize ||
- nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) {
+ if (unlikely(!is_power_of_2(nodesize) || nodesize < sectorsize ||
+ nodesize > BTRFS_MAX_METADATA_BLOCKSIZE)) {
btrfs_err(fs_info, "invalid nodesize %llu", nodesize);
ret = -EINVAL;
}
- if (nodesize != le32_to_cpu(sb->__unused_leafsize)) {
+ if (unlikely(nodesize != le32_to_cpu(sb->__unused_leafsize))) {
btrfs_err(fs_info, "invalid leafsize %u, should be %llu",
le32_to_cpu(sb->__unused_leafsize), nodesize);
ret = -EINVAL;
}
/* Root alignment check */
- if (!IS_ALIGNED(btrfs_super_root(sb), sectorsize)) {
+ if (unlikely(!IS_ALIGNED(btrfs_super_root(sb), sectorsize))) {
btrfs_err(fs_info, "tree_root block unaligned: %llu",
btrfs_super_root(sb));
ret = -EINVAL;
}
- if (!IS_ALIGNED(btrfs_super_chunk_root(sb), sectorsize)) {
+ if (unlikely(!IS_ALIGNED(btrfs_super_chunk_root(sb), sectorsize))) {
btrfs_err(fs_info, "chunk_root block unaligned: %llu",
btrfs_super_chunk_root(sb));
ret = -EINVAL;
}
- if (!IS_ALIGNED(btrfs_super_log_root(sb), sectorsize)) {
+ if (unlikely(!IS_ALIGNED(btrfs_super_log_root(sb), sectorsize))) {
btrfs_err(fs_info, "log_root block unaligned: %llu",
btrfs_super_log_root(sb));
ret = -EINVAL;
}
- if (!fs_info->fs_devices->temp_fsid &&
- memcmp(fs_info->fs_devices->fsid, sb->fsid, BTRFS_FSID_SIZE) != 0) {
+ if (unlikely(!fs_info->fs_devices->temp_fsid &&
+ memcmp(fs_info->fs_devices->fsid, sb->fsid, BTRFS_FSID_SIZE) != 0)) {
btrfs_err(fs_info,
"superblock fsid doesn't match fsid of fs_devices: %pU != %pU",
sb->fsid, fs_info->fs_devices->fsid);
ret = -EINVAL;
}
- if (memcmp(fs_info->fs_devices->metadata_uuid, btrfs_sb_fsid_ptr(sb),
- BTRFS_FSID_SIZE) != 0) {
+ if (unlikely(memcmp(fs_info->fs_devices->metadata_uuid, btrfs_sb_fsid_ptr(sb),
+ BTRFS_FSID_SIZE) != 0)) {
btrfs_err(fs_info,
"superblock metadata_uuid doesn't match metadata uuid of fs_devices: %pU != %pU",
btrfs_sb_fsid_ptr(sb), fs_info->fs_devices->metadata_uuid);
ret = -EINVAL;
}
- if (memcmp(fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid,
- BTRFS_FSID_SIZE) != 0) {
+ if (unlikely(memcmp(fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid,
+ BTRFS_FSID_SIZE) != 0)) {
btrfs_err(fs_info,
"dev_item UUID does not match metadata fsid: %pU != %pU",
fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid);
@@@ -2470,9 -2480,9 +2480,9 @@@
* Artificial requirement for block-group-tree to force newer features
* (free-space-tree, no-holes) so the test matrix is smaller.
*/
- if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE) &&
- (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
- !btrfs_fs_incompat(fs_info, NO_HOLES))) {
+ if (unlikely(btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE) &&
+ (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
+ !btrfs_fs_incompat(fs_info, NO_HOLES)))) {
btrfs_err(fs_info,
"block-group-tree feature requires free-space-tree and no-holes");
ret = -EINVAL;
@@@ -2483,25 -2493,25 +2493,25 @@@
* Reduce test matrix for remap tree by requiring block-group-tree
* and no-holes. Free-space-tree is a hard requirement.
*/
- if (!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
- !btrfs_fs_incompat(fs_info, NO_HOLES) ||
- !btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE)) {
+ if (unlikely(!btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID) ||
+ !btrfs_fs_incompat(fs_info, NO_HOLES) ||
+ !btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE))) {
btrfs_err(fs_info,
"remap-tree feature requires free-space-tree, no-holes, and block-group-tree");
ret = -EINVAL;
}
- if (btrfs_fs_incompat(fs_info, MIXED_GROUPS)) {
+ if (unlikely(btrfs_fs_incompat(fs_info, MIXED_GROUPS))) {
btrfs_err(fs_info, "remap-tree not supported with mixed-bg");
ret = -EINVAL;
}
- if (btrfs_fs_incompat(fs_info, ZONED)) {
+ if (unlikely(btrfs_fs_incompat(fs_info, ZONED))) {
btrfs_err(fs_info, "remap-tree not supported with zoned devices");
ret = -EINVAL;
}
- if (sectorsize > PAGE_SIZE) {
+ if (unlikely(sectorsize > PAGE_SIZE)) {
btrfs_err(fs_info, "remap-tree not supported when block size > page size");
ret = -EINVAL;
}
@@@ -2511,66 -2521,47 +2521,47 @@@
* Hint to catch really bogus numbers, bitflips or so, more exact checks are
* done later
*/
- if (btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb)) {
+ if (unlikely(btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb))) {
btrfs_err(fs_info, "bytes_used is too small %llu",
btrfs_super_bytes_used(sb));
ret = -EINVAL;
}
- if (!is_power_of_2(btrfs_super_stripesize(sb))) {
+ if (unlikely(!is_power_of_2(btrfs_super_stripesize(sb)))) {
btrfs_err(fs_info, "invalid stripesize %u",
btrfs_super_stripesize(sb));
ret = -EINVAL;
}
- if (btrfs_super_num_devices(sb) > (1UL << 31))
+ if (unlikely(btrfs_super_num_devices(sb) > (1UL << 31)))
btrfs_warn(fs_info, "suspicious number of devices: %llu",
btrfs_super_num_devices(sb));
- if (btrfs_super_num_devices(sb) == 0) {
+ if (unlikely(btrfs_super_num_devices(sb) == 0)) {
btrfs_err(fs_info, "number of devices is 0");
ret = -EINVAL;
}
- if (mirror_num >= 0 &&
- btrfs_super_bytenr(sb) != btrfs_sb_offset(mirror_num)) {
+ if (unlikely(mirror_num >= 0 &&
+ btrfs_super_bytenr(sb) != btrfs_sb_offset(mirror_num))) {
btrfs_err(fs_info, "super offset mismatch %llu != %llu",
btrfs_super_bytenr(sb), btrfs_sb_offset(mirror_num));
ret = -EINVAL;
}
- if (ret)
+ if (unlikely(ret))
return ret;
ret = validate_sys_chunk_array(fs_info, sb);
- /*
- * Obvious sys_chunk_array corruptions, it must hold at least one key
- * and one chunk
- */
- if (btrfs_super_sys_array_size(sb) > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) {
- btrfs_err(fs_info, "system chunk array too big %u > %u",
- btrfs_super_sys_array_size(sb),
- BTRFS_SYSTEM_CHUNK_ARRAY_SIZE);
- ret = -EINVAL;
- }
- if (btrfs_super_sys_array_size(sb) < sizeof(struct btrfs_disk_key)
- + sizeof(struct btrfs_chunk)) {
- btrfs_err(fs_info, "system chunk array too small %u < %zu",
- btrfs_super_sys_array_size(sb),
- sizeof(struct btrfs_disk_key)
- + sizeof(struct btrfs_chunk));
- ret = -EINVAL;
- }
-
/*
* The generation is a global counter, we'll trust it more than the others
* but it's still possible that it's the one that's wrong.
*/
- if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb))
+ if (unlikely(btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb)))
btrfs_warn(fs_info,
"suspicious: generation < chunk_root_generation: %llu < %llu",
btrfs_super_generation(sb),
btrfs_super_chunk_root_generation(sb));
- if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb)
- && btrfs_super_cache_generation(sb) != (u64)-1)
+ if (unlikely(btrfs_super_generation(sb) < btrfs_super_cache_generation(sb) &&
+ btrfs_super_cache_generation(sb) != (u64)-1))
btrfs_warn(fs_info,
"suspicious: generation < cache_generation: %llu < %llu",
btrfs_super_generation(sb),
@@@ -2601,7 -2592,7 +2592,7 @@@ static int btrfs_validate_write_super(s
int ret;
ret = btrfs_validate_super(fs_info, sb, -1);
- if (ret < 0)
+ if (unlikely(ret < 0))
goto out;
if (unlikely(!btrfs_supported_super_csum(btrfs_super_csum_type(sb)))) {
ret = -EUCLEAN;
@@@ -2618,7 -2609,7 +2609,7 @@@
goto out;
}
out:
- if (ret < 0)
+ if (unlikely(ret < 0))
btrfs_err(fs_info,
"super block corruption detected before writing it to disk");
return ret;
@@@ -2639,11 -2630,6 +2630,6 @@@ static int load_super_root(struct btrfs
root->node = NULL;
return ret;
}
- if (unlikely(!extent_buffer_uptodate(root->node))) {
- free_extent_buffer(root->node);
- root->node = NULL;
- return -EIO;
- }
btrfs_set_root_node(&root->root_item, root->node);
root->commit_root = btrfs_root_node(root);
@@@ -3766,8 -3752,7 +3752,7 @@@ static void btrfs_end_super_write(struc
* Write superblock @sb to the @device. Do not wait for completion, all the
* folios we use for writing are locked.
*
- * Write @max_mirrors copies of the superblock, where 0 means default that fit
- * the expected device size at commit time. Note that max_mirrors must be
+ * Write @max_mirrors copies of the superblock. Note that max_mirrors must be
* same for write and wait phases.
*
* Return number of errors when folio is not found or submission fails.
@@@ -3783,9 -3768,6 +3768,6 @@@ static int write_dev_supers(struct btrf
atomic_set(&device->sb_write_errors, 0);
- if (max_mirrors == 0)
- max_mirrors = BTRFS_SUPER_MIRROR_MAX;
-
for (i = 0; i < max_mirrors; i++) {
struct folio *folio;
struct bio *bio;
@@@ -3870,16 -3852,13 +3852,13 @@@ static int wait_dev_supers(struct btrfs
int ret;
u64 bytenr;
- if (max_mirrors == 0)
- max_mirrors = BTRFS_SUPER_MIRROR_MAX;
-
for (i = 0; i < max_mirrors; i++) {
struct folio *folio;
ret = btrfs_sb_log_location(device, i, READ, &bytenr);
if (ret == -ENOENT) {
break;
- } else if (ret < 0) {
+ } else if (unlikely(ret < 0)) {
errors++;
if (i == 0)
primary_failed = true;
@@@ -3901,9 -3880,8 +3880,8 @@@
}
errors += atomic_read(&device->sb_write_errors);
- if (errors >= BTRFS_SUPER_PRIMARY_WRITE_ERROR)
- primary_failed = true;
- if (primary_failed) {
+
+ if (unlikely(primary_failed || errors >= BTRFS_SUPER_PRIMARY_WRITE_ERROR)) {
btrfs_err(device->fs_info, "error writing primary super block to device %llu",
device->devid);
return -1;
@@@ -3954,7 -3932,7 +3932,7 @@@ static bool wait_dev_flush(struct btrfs
wait_for_completion_io(&device->flush_wait);
- if (bio->bi_status) {
+ if (unlikely(bio->bi_status)) {
set_bit(BTRFS_DEV_STATE_FLUSH_FAILED, &device->dev_state);
btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_FLUSH_ERRS);
return true;
@@@ -3992,7 -3970,7 +3970,7 @@@ static int barrier_all_devices(struct b
list_for_each_entry(dev, head, dev_list) {
if (test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state))
continue;
- if (!dev->bdev) {
+ if (unlikely(!dev->bdev)) {
errors_wait++;
continue;
}
@@@ -4000,7 -3978,7 +3978,7 @@@
!test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
continue;
- if (wait_dev_flush(dev))
+ if (unlikely(wait_dev_flush(dev)))
errors_wait++;
}
@@@ -4043,26 -4021,27 +4021,27 @@@ int btrfs_get_num_tolerated_disk_barrie
return min_tolerated;
}
- int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
+ int write_all_supers(struct btrfs_trans_handle *trans)
{
+ struct btrfs_fs_info *fs_info = trans->fs_info;
struct list_head *head;
struct btrfs_device *dev;
struct btrfs_super_block *sb;
struct btrfs_dev_item *dev_item;
+ int max_mirrors;
int ret;
int do_barriers;
int max_errors;
int total_errors = 0;
- u64 flags;
do_barriers = !btrfs_test_opt(fs_info, NOBARRIER);
- /*
- * max_mirrors == 0 indicates we're from commit_transaction,
- * not from fsync where the tree roots in fs_info have not
- * been consistent on disk.
- */
- if (max_mirrors == 0) {
+ if (trans->transaction->state < TRANS_STATE_UNBLOCKED) {
+ /* We are called from fsync. */
+ max_mirrors = 1;
+ } else {
+ /* We are called from transaction commit. */
+ max_mirrors = BTRFS_SUPER_MIRROR_MAX;
ret = backup_super_roots(fs_info);
if (ret < 0)
return ret;
@@@ -4077,17 -4056,19 +4056,19 @@@
if (do_barriers) {
ret = barrier_all_devices(fs_info);
- if (ret) {
+ if (unlikely(ret)) {
mutex_unlock(
&fs_info->fs_devices->device_list_mutex);
- btrfs_handle_fs_error(fs_info, ret,
- "errors while submitting device barriers.");
+ btrfs_abort_transaction(trans, ret);
+ btrfs_err(fs_info, "error while submitting device barriers");
return ret;
}
}
+ btrfs_set_super_flags(sb, btrfs_super_flags(sb) | BTRFS_HEADER_FLAG_WRITTEN);
+
list_for_each_entry(dev, head, dev_list) {
- if (!dev->bdev) {
+ if (unlikely(!dev->bdev)) {
total_errors++;
continue;
}
@@@ -4109,19 -4090,17 +4090,17 @@@
memcpy(dev_item->fsid, dev->fs_devices->metadata_uuid,
BTRFS_FSID_SIZE);
- flags = btrfs_super_flags(sb);
- btrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN);
-
ret = btrfs_validate_write_super(fs_info, sb);
if (unlikely(ret < 0)) {
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
- btrfs_handle_fs_error(fs_info, -EUCLEAN,
- "unexpected superblock corruption detected");
- return -EUCLEAN;
+ btrfs_abort_transaction(trans, ret);
+ btrfs_err(fs_info,
+ "unexpected superblock corruption before writing it");
+ return ret;
}
ret = write_dev_supers(dev, sb, max_mirrors);
- if (ret)
+ if (unlikely(ret))
total_errors++;
}
if (unlikely(total_errors > max_errors)) {
@@@ -4130,29 -4109,27 +4109,27 @@@
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
/* FUA is masked off if unsupported and can't be the reason */
- btrfs_handle_fs_error(fs_info, -EIO,
- "%d errors while writing supers",
- total_errors);
+ btrfs_abort_transaction(trans, -EIO);
+ btrfs_err(fs_info, "%d errors while writing supers", total_errors);
return -EIO;
}
total_errors = 0;
list_for_each_entry(dev, head, dev_list) {
- if (!dev->bdev)
+ if (unlikely(!dev->bdev))
continue;
if (!test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &dev->dev_state) ||
!test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
continue;
ret = wait_dev_supers(dev, max_mirrors);
- if (ret)
+ if (unlikely(ret))
total_errors++;
}
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
if (unlikely(total_errors > max_errors)) {
- btrfs_handle_fs_error(fs_info, -EIO,
- "%d errors while writing supers",
- total_errors);
+ btrfs_abort_transaction(trans, -EIO);
+ btrfs_err(fs_info, "%d errors while writing supers", total_errors);
return -EIO;
}
return 0;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* linux-next: manual merge of the btrfs tree with the btrfs-fixes tree
@ 2026-03-24 13:25 Mark Brown
0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2026-03-24 13:25 UTC (permalink / raw)
To: David Sterba
Cc: David Sterba, Filipe Manana, Linux Kernel Mailing List,
Linux Next Mailing List
[-- Attachment #1: Type: text/plain, Size: 8742 bytes --]
Hi all,
Today's linux-next merge of the btrfs tree got a conflict in:
fs/btrfs/tree-log.c
between commit:
5254d4181add9 ("btrfs: fix zero size inode with non-zero size after log replay")
from the btrfs-fixes tree and commits:
5ff218f0ce4bf ("btrfs: pass a btrfs inode to tree-log.c:fill_inode_item()")
b665ca59560b5 ("btrfs: fix zero size inode with non-zero size after log replay")
from the btrfs tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined fs/btrfs/tree-log.c
index ac871efb97639,de4707b1227ef..0000000000000
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@@ -457,7 -457,7 +457,7 @@@ static int process_one_buffer(struct ex
return ret;
}
- if (btrfs_buffer_uptodate(eb, gen, false) && level == 0) {
+ if (btrfs_buffer_uptodate(eb, gen, NULL) && level == 0) {
ret = btrfs_exclude_logged_extents(eb);
if (ret)
btrfs_abort_transaction(trans, ret);
@@@ -1003,7 -1003,7 +1003,7 @@@ static noinline int replay_one_extent(s
btrfs_root_id(root));
}
if (!ret) {
- ret = btrfs_csum_file_blocks(trans, csum_root, sums);
+ ret = btrfs_insert_data_csums(trans, csum_root, sums);
if (ret)
btrfs_abort_log_replay(wc, ret,
"failed to add csums for range [%llu, %llu) inode %llu root %llu",
@@@ -1711,7 -1711,7 +1711,7 @@@ static noinline int add_inode_ref(struc
}
/* insert our name */
- ret = btrfs_add_link(trans, dir, inode, &name, 0, ref_index);
+ ret = btrfs_add_link(trans, dir, inode, &name, false, ref_index);
if (ret) {
btrfs_abort_log_replay(wc, ret,
"failed to add link for inode %llu in dir %llu ref_index %llu name %.*s root %llu",
@@@ -2059,7 -2059,7 +2059,7 @@@ static noinline int insert_one_name(str
return PTR_ERR(dir);
}
- ret = btrfs_add_link(trans, dir, inode, name, 1, index);
+ ret = btrfs_add_link(trans, dir, inode, name, true, index);
/* FIXME, put inode into FIXUP list */
@@@ -3576,7 -3576,7 +3576,7 @@@ int btrfs_sync_log(struct btrfs_trans_h
btrfs_set_super_log_root(fs_info->super_for_commit, log_root_start);
btrfs_set_super_log_root_level(fs_info->super_for_commit, log_root_level);
- ret = write_all_supers(fs_info, 1);
+ ret = write_all_supers(trans);
mutex_unlock(&fs_info->tree_log_mutex);
if (unlikely(ret)) {
btrfs_set_log_full_commit(trans);
@@@ -4613,10 -4613,11 +4613,11 @@@ static int truncate_inode_items(struct
static void fill_inode_item(struct btrfs_trans_handle *trans,
struct extent_buffer *leaf,
struct btrfs_inode_item *item,
- struct inode *inode, bool log_inode_only,
+ struct btrfs_inode *inode, bool log_inode_only,
u64 logged_isize)
{
- u64 gen = BTRFS_I(inode)->generation;
+ struct inode *vfs_inode = &inode->vfs_inode;
+ u64 gen = inode->generation;
u64 flags;
if (log_inode_only) {
@@@ -4631,33 -4632,33 +4632,33 @@@
* and one can set it to 0 since that only happens on eviction
* and we are holding a ref on the inode.
*/
- ASSERT(data_race(BTRFS_I(inode)->logged_trans) > 0);
- if (data_race(BTRFS_I(inode)->logged_trans) < trans->transid)
+ ASSERT(data_race(inode->logged_trans) > 0);
+ if (data_race(inode->logged_trans) < trans->transid)
gen = 0;
btrfs_set_inode_size(leaf, item, logged_isize);
} else {
- btrfs_set_inode_size(leaf, item, inode->i_size);
+ btrfs_set_inode_size(leaf, item, vfs_inode->i_size);
}
btrfs_set_inode_generation(leaf, item, gen);
- btrfs_set_inode_uid(leaf, item, i_uid_read(inode));
- btrfs_set_inode_gid(leaf, item, i_gid_read(inode));
- btrfs_set_inode_mode(leaf, item, inode->i_mode);
- btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
+ btrfs_set_inode_uid(leaf, item, i_uid_read(vfs_inode));
+ btrfs_set_inode_gid(leaf, item, i_gid_read(vfs_inode));
+ btrfs_set_inode_mode(leaf, item, vfs_inode->i_mode);
+ btrfs_set_inode_nlink(leaf, item, vfs_inode->i_nlink);
- btrfs_set_timespec_sec(leaf, &item->atime, inode_get_atime_sec(inode));
- btrfs_set_timespec_nsec(leaf, &item->atime, inode_get_atime_nsec(inode));
+ btrfs_set_timespec_sec(leaf, &item->atime, inode_get_atime_sec(vfs_inode));
+ btrfs_set_timespec_nsec(leaf, &item->atime, inode_get_atime_nsec(vfs_inode));
- btrfs_set_timespec_sec(leaf, &item->mtime, inode_get_mtime_sec(inode));
- btrfs_set_timespec_nsec(leaf, &item->mtime, inode_get_mtime_nsec(inode));
+ btrfs_set_timespec_sec(leaf, &item->mtime, inode_get_mtime_sec(vfs_inode));
+ btrfs_set_timespec_nsec(leaf, &item->mtime, inode_get_mtime_nsec(vfs_inode));
- btrfs_set_timespec_sec(leaf, &item->ctime, inode_get_ctime_sec(inode));
- btrfs_set_timespec_nsec(leaf, &item->ctime, inode_get_ctime_nsec(inode));
+ btrfs_set_timespec_sec(leaf, &item->ctime, inode_get_ctime_sec(vfs_inode));
+ btrfs_set_timespec_nsec(leaf, &item->ctime, inode_get_ctime_nsec(vfs_inode));
- btrfs_set_timespec_sec(leaf, &item->otime, BTRFS_I(inode)->i_otime_sec);
- btrfs_set_timespec_nsec(leaf, &item->otime, BTRFS_I(inode)->i_otime_nsec);
+ btrfs_set_timespec_sec(leaf, &item->otime, inode->i_otime_sec);
+ btrfs_set_timespec_nsec(leaf, &item->otime, inode->i_otime_nsec);
/*
* We do not need to set the nbytes field, in fact during a fast fsync
@@@ -4668,11 -4669,10 +4669,10 @@@
* inode item in subvolume tree as needed (see overwrite_item()).
*/
- btrfs_set_inode_sequence(leaf, item, inode_peek_iversion(inode));
+ btrfs_set_inode_sequence(leaf, item, inode_peek_iversion(vfs_inode));
btrfs_set_inode_transid(leaf, item, trans->transid);
- btrfs_set_inode_rdev(leaf, item, inode->i_rdev);
- flags = btrfs_inode_combine_flags(BTRFS_I(inode)->flags,
- BTRFS_I(inode)->ro_flags);
+ btrfs_set_inode_rdev(leaf, item, vfs_inode->i_rdev);
+ flags = btrfs_inode_combine_flags(inode->flags, inode->ro_flags);
btrfs_set_inode_flags(leaf, item, flags);
btrfs_set_inode_block_group(leaf, item, 0);
}
@@@ -4719,8 -4719,7 +4719,7 @@@ static int log_inode_item(struct btrfs_
return ret;
inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_inode_item);
- fill_inode_item(trans, path->nodes[0], inode_item, &inode->vfs_inode,
- false, 0);
+ fill_inode_item(trans, path->nodes[0], inode_item, inode, false, 0);
btrfs_release_path(path);
return 0;
}
@@@ -4740,7 -4739,7 +4739,7 @@@ static int log_csums(struct btrfs_trans
* worry about logging checksum items with overlapping ranges.
*/
if (inode->last_reflink_trans < trans->transid)
- return btrfs_csum_file_blocks(trans, log_root, sums);
+ return btrfs_insert_data_csums(trans, log_root, sums);
/*
* Serialize logging for checksums. This is to avoid racing with the
@@@ -4763,7 -4762,7 +4762,7 @@@
*/
ret = btrfs_del_csums(trans, log_root, sums->logical, sums->len);
if (!ret)
- ret = btrfs_csum_file_blocks(trans, log_root, sums);
+ ret = btrfs_insert_data_csums(trans, log_root, sums);
btrfs_unlock_extent(&log_root->log_csum_range, sums->logical, lock_end,
&cached_state);
@@@ -4989,8 -4988,7 +4988,7 @@@ copy_item
inode_item = btrfs_item_ptr(dst_path->nodes[0], dst_slot,
struct btrfs_inode_item);
fill_inode_item(trans, dst_path->nodes[0], inode_item,
- &inode->vfs_inode,
- inode_only == LOG_INODE_EXISTS,
+ inode, inode_only == LOG_INODE_EXISTS,
logged_isize);
} else {
copy_extent_buffer(dst_path->nodes[0], src, dst_offset,
@@@ -5088,7 -5086,7 +5086,7 @@@ static int log_extent_csums(struct btrf
if (test_and_set_bit(BTRFS_ORDERED_LOGGED_CSUM, &ordered->flags))
continue;
- list_for_each_entry(sums, &ordered->list, list) {
+ list_for_each_entry(sums, &ordered->csum_list, list) {
ret = log_csums(trans, inode, log_root, sums);
if (ret)
return ret;
@@@ -5803,7 -5801,7 +5801,7 @@@ static int btrfs_check_ref_name_overrid
name_str.len = this_name_len;
di = btrfs_lookup_dir_item(NULL, inode->root, search_path,
parent, &name_str, 0);
- if (di && !IS_ERR(di)) {
+ if (!IS_ERR_OR_NULL(di)) {
struct btrfs_key di_key;
btrfs_dir_item_key_to_cpu(search_path->nodes[0],
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2026-03-24 13:25 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 13:48 linux-next: manual merge of the btrfs tree with the btrfs-fixes tree Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2026-03-24 13:25 Mark Brown
2026-03-24 13:25 Mark Brown
2026-03-17 13:48 Mark Brown
2026-03-17 13:48 Mark Brown
2025-09-18 11:26 Mark Brown
2024-06-06 22:55 Stephen Rothwell
2024-06-06 23:12 ` Qu Wenruo
2023-10-04 23:09 Stephen Rothwell
2022-10-31 23:28 Stephen Rothwell
2022-09-05 23:50 Stephen Rothwell
2022-09-06 0:15 ` Stephen Rothwell
2022-09-06 19:41 ` David Sterba
2022-03-24 23:48 Stephen Rothwell
2022-02-24 13:44 broonie
2022-02-25 11:59 ` David Sterba
2021-01-10 22:29 Stephen Rothwell
2020-05-01 0:28 Stephen Rothwell
2020-05-03 21:40 ` David Sterba
2020-05-01 0:24 Stephen Rothwell
2020-05-01 1:05 ` Stephen Rothwell
2020-05-01 2:06 ` Qu Wenruo
2020-01-08 22:14 Stephen Rothwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox