Re: [PATCH] bcachefs: Add missing error handling

2025-04-13 Thread Alan Huang
On Apr 13, 2025, at 17:59, Kent Overstreet wrote: > > On Sat, Apr 12, 2025 at 06:20:49PM +0800, Alan Huang wrote: >> Reported-by: syzbot+d10151bf01574a09a...@syzkaller.appspotmail.com >> Signed-off-by: Alan Huang > > This was a silly mistake. > > In the past I&

[PATCH] bcachefs: Add missing error handling

2025-04-12 Thread Alan Huang
Reported-by: syzbot+d10151bf01574a09a...@syzkaller.appspotmail.com Signed-off-by: Alan Huang --- fs/bcachefs/recovery.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index d2b07f602da9..606d684e6f23 100644 --- a/fs

Re: [syzbot] [bcachefs?] kernel BUG in bch2_fs_initialize

2025-04-11 Thread Alan Huang
On Apr 12, 2025, at 14:45, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:29e7bf01ed80 Add linux-next specific files for 20250410 > git tree: linux-next > console output: https://syzkaller.appspot.com/x/log.txt?x=1515f74c58 > kernel config: htt

Re: [syzbot] [bcachefs?] INFO: task hung in bch2_fs_read_only_work (2)

2025-04-06 Thread Alan Huang
On Apr 7, 2025, at 01:51, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:a2392f333575 drm/panthor: Clean up FW version information .. > git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git > for-kernelci > console output: https:/

Re: [PATCH] bcachefs: replace deprecated strncpy() with strscpy()

2025-04-05 Thread Alan Huang
On Mar 27, 2025, at 00:17, Kent Overstreet wrote: > > On Wed, Mar 26, 2025 at 09:19:06PM +0530, Bharadwaj Raju wrote: >> On Wed, Mar 26, 2025 at 8:22 PM Kent Overstreet >> wrote: >>> Or better, a new helper: when we're copying to a fixed size buffer we >>> really want to zero out the rest of the

Re: [PATCH] bcachefs: replace deprecated strncpy() with strscpy()

2025-03-26 Thread Alan Huang
On Mar 26, 2025, at 17:44, Roxana Nicolescu wrote: > > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead. > > Link: https://github.com/KSPP/linux/issues/90 > Signed-off-by: Roxana Nicolescu > --- > fs/bcachefs/btree_trans_commit.c | 2 +- > 1 file changed,

[PATCH v2] bcachefs: Add missing smp_rmb()

2025-03-22 Thread Alan Huang
The smp_rmb() guarantees that reads from reservations.counter occur before accessing cur_entry_u64s. It's paired with the atomic64_try_cmpxchg in journal_entry_open. Signed-off-by: Alan Huang --- Since I'm touching this part, add the READ_ONCE anyway. fs/bcachefs/journal.h | 6

Re: [PATCH] bcachefs: Increase blacklist range

2025-03-18 Thread Alan Huang
On Mar 18, 2025, at 22:57, Kent Overstreet wrote: > > On Tue, Mar 18, 2025 at 10:26:03AM -0400, John Stoffel wrote: >>>>>>> "Kent" == Kent Overstreet writes: >> >>> On Mon, Mar 17, 2025 at 04:58:26PM -0400, John Stoffel wrote: >>>&

[PATCH 1/2] bcachefs: Add missing smp_rmb()

2025-03-18 Thread Alan Huang
The smp_rmb() guarantees that reads from reservations.counter occur before accessing cur_entry_u64s. It's paired with the atomic64_try_cmpxchg in journal_entry_open. Signed-off-by: Alan Huang --- fs/bcachefs/journal.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git

[PATCH 2/2] bcachefs: Remove spurious smp_mb()

2025-03-18 Thread Alan Huang
The smp_mb() is paired with nothing. Signed-off-by: Alan Huang --- fs/bcachefs/journal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c index 8d4f3bfaa228..fc15644c9f24 100644 --- a/fs/bcachefs/journal.c +++ b/fs/bcachefs/journal.c @@ -761,7

[PATCH] bcachefs: Fix incorrect state count

2025-03-17 Thread Alan Huang
atomic64_read(&j->seq) - j->seq_write_started == JOURNAL_STATE_BUF_NR is the condition in journal_entry_open where we return JOURNAL_ERR_max_open, so journal_cur_seq(j) - seq == JOURNAL_STATE_BUF_NR means that the buf corresponding to seq has started to write. Signed-off-by: Alan Huan

[PATCH] bcachefs: Increase blacklist range

2025-03-15 Thread Alan Huang
Now there are 16 journal buffers, 8 is too small to be enough. Signed-off-by: Alan Huang --- fs/bcachefs/recovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 71c786cdb192..a6e26733854d 100644 --- a/fs/bcachefs

Re: [syzbot] [bcachefs?] KASAN: slab-out-of-bounds Read in __bch2_bkey_unpack_key

2025-03-07 Thread Alan Huang
On Mar 7, 2025, at 01:57, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:99fa936e8e4f Merge tag 'affs-6.14-rc5-tag' of git://git.ke.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=11f0807858 > kernel config: h

[PATCH] bcachefs: Fix b->written overflow

2025-03-07 Thread Alan Huang
When bset past end of btree node, we should not add sectors to b->written, which will overflow b->written. Reported-by: syzbot+3cb3d9e8c3f197754...@syzkaller.appspotmail.com Tested-by: syzbot+3cb3d9e8c3f197754...@syzkaller.appspotmail.com Signed-off-by: Alan Huang --- fs/bcachefs/btree_io

Re: [syzbot] [bcachefs?] KASAN: slab-out-of-bounds Read in validate_bset_keys

2025-03-06 Thread Alan Huang
On Mar 3, 2025, at 22:51, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:e056da87c780 Merge remote-tracking branch 'will/for-next/p.. > git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git > for-kernelci > console output: https:/

[PATCH v2] bcachefs: Fix deadlock

2025-02-26 Thread Alan Huang
@google.com/T/ Reported-by: syzbot+fe63f377148a6371a...@syzkaller.appspotmail.com Tested-by: syzbot+fe63f377148a6371a...@syzkaller.appspotmail.com Signed-off-by: Alan Huang --- fs/bcachefs/btree_cache.c | 9 + fs/bcachefs/btree_key_cache.c | 2 +- fs/bcachefs/btree_locking.c | 5

[PATCH] bcachefs: Fix deadlock

2025-02-25 Thread Alan Huang
@google.com/T/ Reported-by: syzbot+fe63f377148a6371a...@syzkaller.appspotmail.com Tested-by: syzbot+fe63f377148a6371a...@syzkaller.appspotmail.com Signed-off-by: Alan Huang --- syzbot test: https://lore.kernel.org/all/66f97d9a.050a0220.6bad9.001d@google.com/T

Re: [syzbot] [bcachefs?] possible deadlock in pcpu_alloc_noprof

2025-02-24 Thread Alan Huang
> On Feb 12, 2025, at 12:31, syzbot > wrote: > > syzbot has found a reproducer for the following issue on: > > HEAD commit:09fbf3d50205 Merge tag 'tomoyo-pr-20250211' of git://git.c.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14370aa458 > k

Re: [PATCH] bcachefs: Use alloc_percpu_gfp to avoid deadlock

2025-02-21 Thread Alan Huang
On Feb 21, 2025, at 10:46, Dennis Zhou wrote: > > Hello, > > On Thu, Feb 20, 2025 at 03:37:26PM -0500, Kent Overstreet wrote: >> On Thu, Feb 20, 2025 at 06:16:43PM +0100, Vlastimil Babka wrote: >>> On 2/20/25 11:57, Alan Huang wrote: >>>> Ping >

Re: [PATCH] bcachefs: Use alloc_percpu_gfp to avoid deadlock

2025-02-20 Thread Alan Huang
> On Feb 20, 2025, at 20:40, Kent Overstreet wrote: > > On Thu, Feb 20, 2025 at 06:57:32PM +0800, Alan Huang wrote: >> Ping > > I really want to get this fixed in percpu... > > let's leave this until we can fix it properly, this has come up before > an

Re: [PATCH] bcachefs: Use alloc_percpu_gfp to avoid deadlock

2025-02-20 Thread Alan Huang
Ping > On Feb 12, 2025, at 22:27, Kent Overstreet wrote: > > Adding pcpu people to the CC > > On Wed, Feb 12, 2025 at 06:06:25PM +0800, Alan Huang wrote: >> The cycle: >> >> CPU0: CPU1: >> bc->lock pcpu_alloc_mutex >> pcpu_alloc_mutex bc-&g

[PATCH] bcachefs: Fix memmove when move keys down

2025-02-20 Thread Alan Huang
The fix alone doesn't fix [1], but should be applied before debugging that. [1] https://syzkaller.appspot.com/bug?extid=38a0cbd267eff2d286ff Signed-off-by: Alan Huang --- fs/bcachefs/btree_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/btree_io.c

Re: [Patch v2] doc/RCU/listRCU: refine example code for eliminating stale data

2025-02-19 Thread Alan Huang
On Feb 18, 2025, at 08:50, Wei Yang wrote: > > This patch adjust the example code with following two purpose: > > * reduce the confusion on not releasing e->lock > * emphasize e is valid and not stale with e->lock held > > Signed-off-by: Wei Yang > CC

Re: [syzbot] [mm?] [bcachefs?] WARNING in lock_list_lru_of_memcg

2025-02-18 Thread Alan Huang
On Feb 18, 2025, at 19:40, Kairui Song wrote: > > On Tue, Feb 18, 2025 at 2:09 AM Alan Huang wrote: >> >> On Feb 18, 2025, at 01:12, Kairui Song wrote: >>> >>> On Mon, Feb 17, 2025 at 12:13 AM Kairui Song wrote: >>>> >>>>

Re: [PATCH] bcachefs: Fix memmove when move keys down

2025-02-18 Thread Alan Huang
Ignore this. > On Feb 18, 2025, at 14:37, Alan Huang wrote: > > Reported-by: syzbot+38a0cbd267eff2d28...@syzkaller.appspotmail.com > Signed-off-by: Alan Huang > --- > fs/bcachefs/btree_io.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git

[PATCH] bcachefs: Fix memmove when move keys down

2025-02-17 Thread Alan Huang
Reported-by: syzbot+38a0cbd267eff2d28...@syzkaller.appspotmail.com Signed-off-by: Alan Huang --- fs/bcachefs/btree_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index e71b278672b6..0022529522f1 100644 --- a/fs

Re: [syzbot] [mm?] [bcachefs?] WARNING in lock_list_lru_of_memcg

2025-02-17 Thread Alan Huang
On Feb 18, 2025, at 01:12, Kairui Song wrote: > > On Mon, Feb 17, 2025 at 12:13 AM Kairui Song wrote: >> >> On Sat, Feb 15, 2025 at 7:24 AM Andrew Morton >> wrote: >>> >>> On Fri, 14 Feb 2025 10:11:19 -0800 syzbot >>> wrote: >>> syzbot has found a reproducer for the following issue o

Re: [PATCH] doc/RCU/listRCU: fix an example code snippets

2025-02-17 Thread Alan Huang
On Feb 17, 2025, at 15:41, Wei Yang wrote: > > On Mon, Feb 17, 2025 at 10:22:53AM +0800, Alan Huang wrote: >> On Feb 17, 2025, at 10:12, Boqun Feng wrote: >>> >>> Hi Wei, >>> >>> The change loosk good to me, thanks! >>> >>> I

Re: [PATCH] doc/RCU/listRCU: fix an example code snippets

2025-02-16 Thread Alan Huang
On Feb 17, 2025, at 10:12, Boqun Feng wrote: > > Hi Wei, > > The change loosk good to me, thanks! > > I queued the patch for futher reviews and tests with some changes in the > commit log (for title formating and a bit more explanation), please see > below. > > Regards, > Boqun > > On Wed, Ja

[PATCH] bcachefs: Pass _orig_restart_count to trans_was_restarted

2025-02-12 Thread Alan Huang
_orig_restart_count is unused now, according to the logic, trans_was_restarted should be using _orig_restart_count. Signed-off-by: Alan Huang --- fs/bcachefs/btree_iter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h

[PATCH v2] bcachefs: Reuse transaction

2025-02-12 Thread Alan Huang
/0xa0 00242 el0t_64_sync_handler+0x104/0x130 00242 el0t_64_sync+0x154/0x158 00242 Code: 6b01001f 5401 79408460 3617fec0 (d421) 00242 ---[ end trace ]--- 00242 Kernel panic - not syncing: Oops - BUG: Fatal exception Signed-off-by: Alan Huang --- fs/bcachefs/io_write.c | 33

[PATCH] bcachefs: Use alloc_percpu_gfp to avoid deadlock

2025-02-12 Thread Alan Huang
The cycle: CPU0: CPU1: bc->lockpcpu_alloc_mutex pcpu_alloc_mutexbc->lock Reported-by: syzbot+fe63f377148a6371a...@syzkaller.appspotmail.com Tested-by: syzbot+fe63f377148a6371a...@syzkaller.appspotmail.com Signed-off-by: Alan Huang --- fs/bcachefs

[PATCH] bcachefs: Reuse transaction

2025-02-12 Thread Alan Huang
/0xa0 00242 el0t_64_sync_handler+0x104/0x130 00242 el0t_64_sync+0x154/0x158 00242 Code: 6b01001f 5401 79408460 3617fec0 (d421) 00242 ---[ end trace ]--- 00242 Kernel panic - not syncing: Oops - BUG: Fatal exception Signed-off-by: Alan Huang --- fs/bcachefs/io_write.c | 12

Re: [syzbot] [bcachefs?] possible deadlock in pcpu_alloc_noprof

2025-02-12 Thread Alan Huang
> On Feb 12, 2025, at 12:31, syzbot > wrote: > > syzbot has found a reproducer for the following issue on: > > HEAD commit:09fbf3d50205 Merge tag 'tomoyo-pr-20250211' of git://git.c.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=14370aa458 > k

Re: [PATCH] bcachefs: Use uncompressed_size as the operand

2025-02-10 Thread Alan Huang
On Feb 11, 2025, at 00:25, Kent Overstreet wrote: > > On Mon, Feb 10, 2025 at 11:04:21AM +0800, Alan Huang wrote: >> Since we don't merge compressed extents, uncompressed_size should be >> equal to compressed_size, use uncompressed_size to clarify the intention. >

Re: [PATCH] bcachefs: Fix use after free

2025-02-10 Thread Alan Huang
On Feb 11, 2025, at 00:28, Kent Overstreet wrote: > > On Mon, Feb 10, 2025 at 11:04:22AM +0800, Alan Huang wrote: >> acc->k.data should be used with the lock hold: > > > >> >> Signed-off-by: Alan Huang > > > Test this with lockdep (you know

[PATCH] bcachefs: Fix use after free

2025-02-09 Thread Alan Huang
opping secondary CPUs 00265 Kernel Offset: disabled 00265 CPU features: 0x000,0070,0010,8240500b 00265 Memory Limit: none 00265 ---[ end Kernel panic - not syncing: kasan.fault=panic set ... ]--- 00270 = FAILED TIMEOUT generic.187 in 1200s Signed-off-by: Alan Huang --- fs/bc

[PATCH] bcachefs: Use uncompressed_size as the operand

2025-02-09 Thread Alan Huang
Since we don't merge compressed extents, uncompressed_size should be equal to compressed_size, use uncompressed_size to clarify the intention. Signed-off-by: Alan Huang --- fs/bcachefs/extents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/extents.c

Re: [PATCH v2] bcachefs: fix deadlock in journal_entry_open()

2025-01-31 Thread Alan Huang
On Jan 31, 2025, at 20:47, Jeongjun Park wrote: > > In the previous commit b3d82c2f2761, code was added to prevent journal > sequence > overflow. Among them, the code added to journal_entry_open() uses the > bch2_fs_fatal_err_on() function to handle errors. At least, bch2_journal_halt could inv

[PATCH] bcachefs: Fix subtraction underflow

2025-01-27 Thread Alan Huang
When ancestor is less than IS_ANCESTOR_BITMAP, we would get an incorrect result. Signed-off-by: Alan Huang --- fs/bcachefs/snapshot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/snapshot.c b/fs/bcachefs/snapshot.c index c54091a28909..ede0b480e7d4 100644

The missing patches

2025-01-08 Thread Alan Huang
Hello Kent, Here are the links to the missed patches, I’d like to know if these patches are still needed :) [1] https://lore.kernel.org/all/20240925164500.1178107-1-mmpgour...@gmail.com/T/ [2] https://lore.kernel.org/all/20240925164602.1179117-1-mmpgour...@gmail.com/T/ [3] https://www.mail-arc

Re: A question about "4.3.4.2 A Volatile Solution" of perfbook

2024-11-11 Thread Alan Huang
On Nov 11, 2024, at 17:30, Nan Xiao wrote: > > Hi Alan and Akira, > > Thanks very much for your answers! I have another question from > "4.3.4.2 A Volatile Solution". In this section, it mentions: > > 1. Implementations are forbidden from tearing an aligned volatile > access when machine inst

Re: A question about "4.3.4.2 A Volatile Solution" of perfbook

2024-11-10 Thread Alan Huang
On Nov 11, 2024, at 15:45, Nan Xiao wrote: > > Hello, > > Greetings from me! > > I am reading "4.3.4.2 A Volatile Solution" of perfbook, and come > across following summary: > >To summarize, the volatile keyword can prevent load tearing and > store tearing in cases where the loads and stor

Re: [PATCH] libbcachefs: add support for true/false & yes/no in bool-type options

2024-11-06 Thread Alan Huang
On Nov 7, 2024, at 05:20, Kent Overstreet wrote: > > On Thu, Jul 18, 2024 at 03:13:48PM +0800, Integral wrote: >> This is a resend of my previous patch with code style optimized as I >> forgot to add Kent Overstreet in "To". The previous patch is >> (https://lore.kernel.org/linux-bcachefs/2024071

Re: [PATCH v5] bcachefs: add support for true/false & yes/no in bool-type options

2024-10-27 Thread Alan Huang
On Oct 23, 2024, at 18:00, Integral wrote: > > Here is the patch which uses existing constant table: > > Currently, when using bcachefs-tools to set options, bool-type options > can only accept 1 or 0. Add support for accepting true/false and yes/no > for these options. > > Signed-off-by: Integ

Re: [PATCH v2] bcachefs: fix null-ptr-deref in have_stripes()

2024-10-25 Thread Alan Huang
On Oct 26, 2024, at 00:54, Kent Overstreet wrote: > > On Fri, Oct 25, 2024 at 08:56:18PM +0900, Jeongjun Park wrote: >> c->btree_roots_known[i].b can be NULL. In this case, a NULL pointer >> dereference >> occurs, so you need to add code to check the variable. >> >> Reported-by: syzbot+b468b9fe

Re: [PATCH rcu] srcu: Guarantee non-negative return value from srcu_read_lock()

2024-10-23 Thread Alan Huang
On Oct 24, 2024, at 00:40, Paul E. McKenney wrote: > > On Wed, Oct 23, 2024 at 02:58:07PM +0800, Alan Huang wrote: >> On Oct 22, 2024, at 22:26, Paul E. McKenney wrote: >>> >>> On Tue, Oct 22, 2024 at 12:13:12AM -0700, Christoph Hellwig wrote: >>>>

Re: [PATCH rcu] srcu: Guarantee non-negative return value from srcu_read_lock()

2024-10-23 Thread Alan Huang
On Oct 24, 2024, at 00:34, Andrii Nakryiko wrote: > > On Tue, Oct 22, 2024 at 11:40 PM Christoph Hellwig wrote: >> >> On Tue, Oct 22, 2024 at 10:29:13AM -0700, Andrii Nakryiko wrote: Would this work? #define SRCU_INVALID_INDEX -1 >>> >>> But why? >> >> Becaue it ve

Re: [PATCH] bcachefs: Fix NULL ptr dereference in btree_node_iter_and_journal_peek

2024-10-23 Thread Alan Huang
On Oct 23, 2024, at 15:21, Piotr Zalewski wrote: > > Add NULL check for key returned from bch2_btree_and_journal_iter_peek in > btree_node_iter_and_journal_peek to avoid NULL ptr dereference in > bch2_bkey_buf_reassemble. It would be helpful if the commit message explained why k.k is null in thi

Re: [PATCH v4] libbcachefs: add support for true/false & yes/no in bool-type options

2024-10-23 Thread Alan Huang
On Oct 23, 2024, at 13:15, Integral wrote: > > Here is my latest patch: > > Currently, when using bcachefs-tools to set options, bool-type options > can only accept 1 or 0. Add support for accepting true/false and yes/no > for these options. > > Signed-off-by: Integral > --- > fs/bcachefs/opts

Re: [PATCH rcu] srcu: Guarantee non-negative return value from srcu_read_lock()

2024-10-23 Thread Alan Huang
On Oct 22, 2024, at 22:26, Paul E. McKenney wrote: > > On Tue, Oct 22, 2024 at 12:13:12AM -0700, Christoph Hellwig wrote: >> On Tue, Oct 22, 2024 at 09:10:18AM +0200, Peter Zijlstra wrote: >>> Ah, well, the thing that got us here is that we (Andrii and me) wanted >>> to use -1 as an 'invalid' val

Re: [PATCH v3] bcachefs: fix shift oob in alloc_lru_idx_fragmentation

2024-10-21 Thread Alan Huang
On Oct 22, 2024, at 11:05, Hongbo Li wrote: > > > > On 2024/10/22 10:38, Alan Huang wrote: >> On Oct 22, 2024, at 10:26, Hongbo Li wrote: >>> >>> >>> >>> On 2024/10/21 23:43, Jeongjun Park wrote: >>>> The size of a.da

Re: [PATCH v3] bcachefs: fix shift oob in alloc_lru_idx_fragmentation

2024-10-21 Thread Alan Huang
On Oct 22, 2024, at 10:26, Hongbo Li wrote: > > > > On 2024/10/21 23:43, Jeongjun Park wrote: >> The size of a.data_type is set abnormally large, causing shift-out-of-bounds. >> To fix this, we need to add validation on a.data_type in >> alloc_lru_idx_fragmentation(). >> Reported-by: syzbot+7f4

Re: [PATCH v2] bcachefs: fix shift oob in alloc_lru_idx_fragmentation

2024-10-21 Thread Alan Huang
On Oct 21, 2024, at 23:10, Jeongjun Park wrote: > > The size of a.data_type is set abnormally large, causing shift-out-of-bounds. > To fix this, we need to add validation on a.data_type in > alloc_lru_idx_fragmentation(). > > Reported-by: syzbot+7f45fa9805c40db3f...@syzkaller.appspotmail.com >

Re: [PATCH] bcachefs: fix shift oob in alloc_lru_idx_fragmentation

2024-10-21 Thread Alan Huang
On Oct 21, 2024, at 22:09, Jeongjun Park wrote: > > The size of a.data_type is set abnormally large, causing shift-out-of-bounds. > To fix this, we need to add validation on a.data_type in > alloc_lru_idx_fragmentation(). > > Reported-by: syzbot+7f45fa9805c40db3f...@syzkaller.appspotmail.com >

Re: Libmount bug ?

2024-10-15 Thread Alan Huang
On Oct 14, 2024, at 23:57, Karel Zak wrote: > > > Hi Alan, > > On Sat, Oct 12, 2024 at 04:57:39PM GMT, Alan Huang wrote: >> The bcachefs has the helper called mount.bcachefs. > > do you mean the following script? > https://evilpiepirate.org/git/bcachefs-tools.g

Libmount bug ?

2024-10-12 Thread Alan Huang
Hello Karel, The bcachefs has the helper called mount.bcachefs. Currently, there are users using fstab with nofail/user fail to mount, we would like to know whether other filesystems using similar helper properly handle this. This is like commit 06e05eb0f78566b68c44328c37d7c28d8655e9df (“libmou

Re: [PATCH] bcachefs: Do not allow no fail lock request to fail

2024-10-10 Thread Alan Huang
On Oct 11, 2024, at 00:20, Kent Overstreet wrote: > > On Thu, Oct 10, 2024 at 09:21:50PM GMT, Alan Huang wrote: >> If the transaction chose itself as a victim before and restarted, it >> might request a no fail lock request this time. But it might be added to >> others&

[PATCH] bcachefs: Do not allow no fail lock request to fail

2024-10-10 Thread Alan Huang
fully RCU-based to solve that unsoundness, but the latency added to trans_put and additional memory required may not worth it. Signed-off-by: Alan Huang --- fs/bcachefs/btree_locking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/btree_locking.c b/f

[PATCH] bcachefs: Fix state lock involved deadlock

2024-10-08 Thread Alan Huang
s.h:55 arch/arm64/include/asm/irqflags.h:76 arch/arm64/kernel/entry-common.c:165 arch/arm64/kernel/entry-common.c:178 arch/arm64/kernel/entry-common.c:713) 00392 el0t_64_sync_handler (arch/arm64/kernel/entry-common.c:731) 00392 el0t_64_sync (arch/arm64/kernel/entry.S:598) Signed-off-by: Al

[PATCH] bcachefs: Release transaction before wake up

2024-10-08 Thread Alan Huang
We will get this if we wake up first: Kernel panic - not syncing: btree_node_write_done leaked btree_trans since there are still transactions waiting for cycle detectors after BTREE_NODE_write_in_flight is cleared. Signed-off-by: Alan Huang --- fs/bcachefs/btree_io.c | 5 +++-- 1 file changed

Re: [GIT PULL] bcachefs fixes for 6.12-rc2

2024-10-06 Thread Alan Huang
On Oct 7, 2024, at 03:29, Kent Overstreet wrote: > > On Sun, Oct 06, 2024 at 12:04:45PM GMT, Linus Torvalds wrote: >> On Sat, 5 Oct 2024 at 21:33, Kent Overstreet >> wrote: >>> >>> On Sun, Oct 06, 2024 at 12:30:02AM GMT, Theodore Ts'o wrote: You may believe that yours is better than

Re: [PATCH] Add support for true/false, yes/no & on/off in bool-type options

2024-10-03 Thread Alan Huang
> On Oct 3, 2024, at 17:35, Integral wrote: > > Therefore, if my original patch is okay, could you merge it? I took a look just now, I think you can use lookup_constant. > > > Thanks, > > Integral > > > On 7/22/24 12:03 PM, Hongbo Li wrote: >> >> >> On 2024/7/19 6:50, Kent Overstreet wro

[PATCH 4/4] bcachefs: Pop all the transactions from the abort one

2024-10-02 Thread Alan Huang
The transaction is going to abort, so there will be no cycle involving this transaction anymore. Signed-off-by: Alan Huang --- fs/bcachefs/btree_locking.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 70f13ab5ba7b

[PATCH 3/4] bcachefs: Only abort the transactions in the cycle

2024-10-02 Thread Alan Huang
When the cycle doesn't involve the initiator of the cycle detection, we might choose a transaction that is not involved in the cycle to abort. It shouldn't be that since it won't break the cycle, this patch therefore chooses the transaction in the cycle to abort. Signed-off

[PATCH 2/4] bcachefs: Introduce lock_graph_pop_from

2024-10-02 Thread Alan Huang
This patch introduces a helper function called lock_graph_pop_from, it pops the graph from i. Signed-off-by: Alan Huang --- fs/bcachefs/btree_locking.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index

[PATCH 1/4] bcachefs: Convert open-coded lock_graph_pop_all to helper

2024-10-02 Thread Alan Huang
Signed-off-by: Alan Huang --- fs/bcachefs/btree_locking.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 617478fd5351..50d9366d49bd 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-30 Thread Alan Huang
On Sep 30, 2024, at 17:33, Jonas Oberhauser wrote: > > > > Am 9/30/2024 um 11:27 AM schrieb Alan Huang: >> 2024年9月30日 17:15,Alan Huang 写道: >>> >>> 2024年9月30日 16:57,Jonas Oberhauser 写道: >>>> >>>> >>>> >>

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-30 Thread Alan Huang
2024年9月30日 17:15,Alan Huang 写道: > > 2024年9月30日 16:57,Jonas Oberhauser 写道: >> >> >> >> Am 9/29/2024 um 12:26 AM schrieb Alan Huang: >>> 2024年9月28日 23:55,Mathieu Desnoyers wrote: >>>> >>>> On 2024-09-28 17:49, Alan Stern

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-30 Thread Alan Huang
2024年9月30日 16:57,Jonas Oberhauser 写道: > > > > Am 9/29/2024 um 12:26 AM schrieb Alan Huang: >> 2024年9月28日 23:55,Mathieu Desnoyers wrote: >>> >>> On 2024-09-28 17:49, Alan Stern wrote: >>>> On Sat, Sep 28, 2024 at 11:32:18AM -0400, Mathieu Desnoy

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-28 Thread Alan Huang
2024年9月29日 07:55,Boqun Feng wrote: > > > > On Sun, Sep 29, 2024, at 6:26 AM, Alan Huang wrote: >> 2024年9月28日 23:55,Mathieu Desnoyers wrote: >>> >>> On 2024-09-28 17:49, Alan Stern wrote: >>>> On Sat, Sep 28, 2024 at 11:32:18AM -0400, Mathieu

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-28 Thread Alan Huang
2024年9月29日 06:10,Alan Huang wrote: > > 2024年9月28日 06:18,Jonas Oberhauser wrote: >> >> >> >> Am 9/27/2024 um 10:10 PM schrieb Mathieu Desnoyers: >>> On 2024-09-27 21:23, Jonas Oberhauser wrote: >>> [...] >>>> That idea seems to be co

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-28 Thread Alan Huang
2024年9月28日 23:55,Mathieu Desnoyers wrote: > > On 2024-09-28 17:49, Alan Stern wrote: >> On Sat, Sep 28, 2024 at 11:32:18AM -0400, Mathieu Desnoyers wrote: >>> On 2024-09-28 16:49, Alan Stern wrote: On Sat, Sep 28, 2024 at 09:51:27AM -0400, Mathieu Desnoyers wrote: > equality, which does

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-28 Thread Alan Huang
2024年9月28日 06:18,Jonas Oberhauser wrote: > > > > Am 9/27/2024 um 10:10 PM schrieb Mathieu Desnoyers: >> On 2024-09-27 21:23, Jonas Oberhauser wrote: >> [...] >>> That idea seems to be confirmed by this (atrocious, not to be copied!) >>> example: >>> >>> int fct_escape_address_of_b(void) >>> {

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Alan Huang
2024年9月27日 12:28,Boqun Feng wrote: > > On Fri, Sep 27, 2024 at 09:37:50AM +0800, Boqun Feng wrote: >> >> >> On Fri, Sep 27, 2024, at 9:30 AM, Mathieu Desnoyers wrote: >>> On 2024-09-27 02:01, Boqun Feng wrote: #define ADDRESS_EQ(var, expr) \ ({ \ bool _cmp_res = (unsigned lon

[PATCH] bcachefs: Delete dead code

2024-09-27 Thread Alan Huang
lock_fail_root_changed has not been used since commit 0d7009d7ca99 ("bcachefs: Delete old deadlock avoidance code") Remove it. Signed-off-by: Alan Huang --- fs/bcachefs/btree_iter.c | 2 -- fs/bcachefs/errcode.h| 1 - 2 files changed, 3 deletions(-) diff --git a/fs/bcachefs/btre

[PATCH] Revert "bcachefs: Fix bch2_btree_node_upgrade()"

2024-09-25 Thread Alan Huang
This reverts commit 62448afee714354a26db8a0f3c644f58628f0792. six_lock_tryupgrade fails only if there is an intent lock held, it won't fail no matter how many read locks are held. Signed-off-by: Alan Huang --- fs/bcachefs/btree_locking.c | 22 -- 1 file chang

[PATCH v2] bcachefs: Merge the condition to avoid additional invocation

2024-09-25 Thread Alan Huang
If the lock has been acquired and unlocked, we don't have to do clear and wakeup again, though harmless since we hold the intent lock. Merge the condition might be clearer. Signed-off-by: Alan Huang --- Only the title is changed in this version. The original one is "bcachefs: Remove

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-19 Thread Alan Huang
2024年9月20日 02:58,Boqun Feng wrote: > > On Thu, Sep 19, 2024 at 09:57:12PM +0800, Alan Huang wrote: > [...] >>> >>> I think you're right. (Although the node will be eventually deleted at >>> cleanup_hazptr_context(), however there could be a lo

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-19 Thread Alan Huang
2024年9月19日 15:10,Boqun Feng wrote: > > On Thu, Sep 19, 2024 at 02:39:13PM +0800, Lai Jiangshan wrote: >> On Tue, Sep 17, 2024 at 10:34 PM Boqun Feng wrote: >> >>> +static void hazptr_context_snap_readers_locked(struct hazptr_reader_tree >>> *tree, >>> +

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-19 Thread Alan Huang
2024年9月19日 15:10,Boqun Feng wrote: > > On Thu, Sep 19, 2024 at 02:39:13PM +0800, Lai Jiangshan wrote: >> On Tue, Sep 17, 2024 at 10:34 PM Boqun Feng wrote: >> >>> +static void hazptr_context_snap_readers_locked(struct hazptr_reader_tree >>> *tree, >>> +

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-19 Thread Alan Huang
2024年9月19日 15:10,Boqun Feng wrote: > > On Thu, Sep 19, 2024 at 02:39:13PM +0800, Lai Jiangshan wrote: >> On Tue, Sep 17, 2024 at 10:34 PM Boqun Feng wrote: >> >>> +static void hazptr_context_snap_readers_locked(struct hazptr_reader_tree >>> *tree, >>> +

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-18 Thread Alan Huang
2024年9月17日 22:33,Boqun Feng wrote: > > Hazard pointers [1] provide a way to dynamically distribute refcounting > and can be used to improve the scalability of refcounting without > significant space cost. > > Hazard pointers are similar to RCU: they build the synchronization > between two part,

Re: [PATCH] bcachefs: Fix lost wake up

2024-08-31 Thread Alan Huang
2024年9月1日 11:10,Kent Overstreet wrote: > > On Sun, Sep 01, 2024 at 10:50:37AM GMT, Alan Huang wrote: >>> 2024年9月1日 09:09,Kent Overstreet wrote: >>> >>> On Tue, Aug 27, 2024 at 11:14:48PM GMT, Alan Huang wrote: >>>> If the reader acquires the

Re: [PATCH] bcachefs: Fix lost wake up

2024-08-31 Thread Alan Huang
> 2024年9月1日 09:09,Kent Overstreet wrote: > > On Tue, Aug 27, 2024 at 11:14:48PM GMT, Alan Huang wrote: >> If the reader acquires the read lock and then the writer enters the slow >> path, while the reader proceeds to the unlock path, the following scenario >> c

[PATCH] bcachefs: Remove the second call to these function

2024-08-28 Thread Alan Huang
If the lock has been acquired and unlocked, we don't have to do clear and wakeup again, though harmless since we hold the intent lock. Merge the condition might be clearer. Signed-off-by: Alan Huang --- fs/bcachefs/six.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-)

[PATCH] bcachefs: Fix lost wake up

2024-08-27 Thread Alan Huang
der: smp_mb() reader: state = atomic_read(&lock->state) (there is no waiting flag set) writer: six_set_bitmask() then the writer will sleep forever. Signed-off-by: Alan Huang --- fs/bcachefs/six.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/bcachefs/

[PATCH v2] bcachefs: Refactor bch2_bset_fix_lookup_table

2024-08-17 Thread Alan Huang
x27;t need to adjust the rw aux tree. Signed-off-by: Alan Huang --- Changes in v2: - rw_aux_tree_build_entry is renamed to rw_aux_tree_insert_entry - l is renamed to idx - two comments are removed since there are assertions - two parameters of the helper function are removed since they can be

[PATCH] bcachefs: Refactor bch2_bset_fix_lookup_table

2024-08-15 Thread Alan Huang
x27;t need to adjust the rw aux tree. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 116 + 1 file changed, 65 insertions(+), 51 deletions(-) diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index 1b66b2c7e018..c5fffed88c46 100644 --- a/fs/bcache

[PATCH] bcachefs: Remove unused parameter

2024-08-14 Thread Alan Huang
iter here is unused, remove it. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 1 - fs/bcachefs/bset.h | 4 ++-- fs/bcachefs/btree_trans_commit.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index

[PATCH v2 2/2] bcachefs: Remove the prev array stuff

2024-08-12 Thread Alan Huang
After reducing the search range when building the aux tree, the prev array stuff is no longer useful, so remove it. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 34 -- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/fs/bcachefs/bset.c b/fs

[PATCH v2 1/2] bcachefs: Minimize the search range used to calculate the mantissa

2024-08-12 Thread Alan Huang
ey of node i. Once the search range is minimized, the mantissa we are calculating can have more useful bits, thus reduce the slow path comparison. Besides, we can now remove all the prev array stuff. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletio

[PATCH v2 0/2] Minimize the search range used

2024-08-12 Thread Alan Huang
comparison when search a key. The prev array stuff becomes useless after minimizing the search range, so this series also removes the prev array stuff. Alan Huang (2): bcachefs: Minimize the search range used to calculate the mantissa bcachefs: Remove the prev array stuff fs/bcachefs/bset.c | 36

[PATCH 2/2] bcachefs: Remove the prev array stuff

2024-08-12 Thread Alan Huang
After reducing the search range when building the aux tree, the prev array stuff is no longer useful, so remove it. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 31 +++ 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/fs/bcachefs/bset.c b/fs

[PATCH 1/2] bcachefs: Minimize the search range used to calculate the mantissa

2024-08-12 Thread Alan Huang
ey of node i. Once the search range is minimized, the mantissa we are calculating can have more useful bits, thus reduce the slow path comparison. Besides, we can now remove all the prev array stuff. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletio

[PATCH 0/2] bcachefs: Minimize the search range used to

2024-08-12 Thread Alan Huang
array stuff. Alan Huang (2): bcachefs: Minimize the search range used to calculate the mantissa bcachefs: Remove the prev array stuff fs/bcachefs/bset.c | 33 - 1 file changed, 4 insertions(+), 29 deletions(-) -- 2.45.2

[PATCH 2/2] bcachefs: Remove unused parameter of bkey_mantissa_bits_dropped

2024-08-10 Thread Alan Huang
The idx parameter of bkey_mantissa_bits_dropped is unused, remove it. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index a2a87ed09f37..00a821f617a5 100644 --- a/fs/bcachefs

[PATCH 1/2] bcachefs: Remove unused parameter of bkey_mantissa

2024-08-10 Thread Alan Huang
The idx parameter of bkey_mantissa became unused since commit b904a7991802 ("bcachefs: Go back to 16 bit mantissa bkey floats"), so remove it. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/bcachefs/b

[PATCH 0/2] Remove two unused parameters

2024-08-10 Thread Alan Huang
This series simply removes two unused parameters. Alan Huang (2): bcachefs: Remove unused parameter of bkey_mantissa bcachefs: Remove unused parameter of bkey_mantissa_bits_dropped fs/bcachefs/bset.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.45.2

[PATCH] bcachefs: Convert open-coded extra computation to helper

2024-08-10 Thread Alan Huang
This patch replaces open-coded extra computation to eytzinger1_extra. Signed-off-by: Alan Huang --- fs/bcachefs/bset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index b95deeb83071..e7c44f35f0c5 100644 --- a/fs/bcachefs/bset.c

  1   2   >