Re: [f2fs-dev] [PATCH] mkfs.f2fs: align each device to zone size

2024-04-29 Thread Chao Yu

On 2024/4/10 20:38, Sheng Yong wrote:

For multiple device, each device should be aligned to zone size, instead
of aligning the total size.

Signed-off-by: Sheng Yong 


Reviewed-by: Chao Yu 

Thanks,


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v2] f2fs: fix block migration when section is not aligned to pow2

2024-04-29 Thread Chao Yu

On 2024/4/29 11:51, Wu Bo wrote:

As for zoned-UFS, f2fs section size is forced to zone size. And zone
size may not aligned to pow2.

Fixes: 859fca6b706e ("f2fs: swap: support migrating swapfile in aligned write 
mode")
Signed-off-by: Liao Yuanhong 
Signed-off-by: Wu Bo 


Reviewed-by: Chao Yu 

Thanks,


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v3 01/12] f2fs: drop usage of page_index

2024-04-29 Thread Kairui Song
From: Kairui Song 

page_index is needed for mixed usage of page cache and swap cache,
for pure page cache usage, the caller can just use page->index instead.

It can't be a swap cache page here, so just drop it.

[ This commit will not be needed once f2fs converted
  f2fs_mpage_readpages() to use folio]

Signed-off-by: Kairui Song 
Cc: Chao Yu 
Cc: Jaegeuk Kim 
Cc: linux-f2fs-devel@lists.sourceforge.net
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 961e6ff77c72..c0e1459702e6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2057,7 +2057,7 @@ static int f2fs_read_single_page(struct inode *inode, 
struct page *page,
sector_t block_nr;
int ret = 0;
 
-   block_in_file = (sector_t)page_index(page);
+   block_in_file = (sector_t)page->index;
last_block = block_in_file + nr_pages;
last_block_in_file = bytes_to_blks(inode,
f2fs_readpage_limit(inode) + blocksize - 1);
-- 
2.44.0



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [syzbot] [f2fs?] KASAN: slab-use-after-free Read in sanity_check_extent_cache

2024-04-29 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:e67572cd2204 Linux 6.9-rc6
git tree:   upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=13724f0f18
kernel config:  https://syzkaller.appspot.com/x/.config?x=d2f00edef461175
dashboard link: https://syzkaller.appspot.com/bug?extid=74ebe2104433e9dc610d
compiler:   Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 
2.40
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=1693844098
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13ae851718

Downloadable assets:
disk image: 
https://storage.googleapis.com/syzbot-assets/526d150815dd/disk-e67572cd.raw.xz
vmlinux: 
https://storage.googleapis.com/syzbot-assets/03cba3db92e8/vmlinux-e67572cd.xz
kernel image: 
https://storage.googleapis.com/syzbot-assets/ec3f54fc8985/bzImage-e67572cd.xz
mounted in repro: 
https://storage.googleapis.com/syzbot-assets/21aa65da230a/mount_0.gz

The issue was bisected to:

commit a53936361330e4c55c0654605178281387d9c761
Author: Chao Yu 
Date:   Sun Dec 10 09:20:35 2023 +

f2fs: delete obsolete FI_FIRST_BLOCK_WRITTEN

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=11b7844098
final oops: https://syzkaller.appspot.com/x/report.txt?x=13b7844098
console output: https://syzkaller.appspot.com/x/log.txt?x=15b7844098

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+74ebe2104433e9dc6...@syzkaller.appspotmail.com
Fixes: a53936361330 ("f2fs: delete obsolete FI_FIRST_BLOCK_WRITTEN")

R10:  R11: 0246 R12: 7f3b853316dc
R13: 7f3b852f8160 R14: 0030656c69662f2e R15: 7ffdc8faca88
 
==
BUG: KASAN: slab-use-after-free in sanity_check_extent_cache+0x370/0x410 
fs/f2fs/extent_cache.c:46
Read of size 4 at addr 8880739ab220 by task syz-executor200/5097

CPU: 0 PID: 5097 Comm: syz-executor200 Not tainted 6.9.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
03/27/2024
Call Trace:
 
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 sanity_check_extent_cache+0x370/0x410 fs/f2fs/extent_cache.c:46
 do_read_inode fs/f2fs/inode.c:509 [inline]
 f2fs_iget+0x33e1/0x46e0 fs/f2fs/inode.c:560
 f2fs_nfs_get_inode+0x74/0x100 fs/f2fs/super.c:3237
 generic_fh_to_dentry+0x9f/0xf0 fs/libfs.c:1413
 exportfs_decode_fh_raw+0x152/0x5f0 fs/exportfs/expfs.c:444
 exportfs_decode_fh+0x3c/0x80 fs/exportfs/expfs.c:584
 do_handle_to_path fs/fhandle.c:155 [inline]
 handle_to_path fs/fhandle.c:210 [inline]
 do_handle_open+0x495/0x650 fs/fhandle.c:226
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f3b852ab889
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 91 1b 00 00 90 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 
c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:7f3b85239228 EFLAGS: 0246 ORIG_RAX: 0130
RAX: ffda RBX: 7f3b853316d8 RCX: 7f3b852ab889
RDX:  RSI: 2040 RDI: 0004
RBP: 7f3b853316d0 R08: 7ffdc8faca87 R09: 7f3b852396c0
R10:  R11: 0246 R12: 7f3b853316dc
R13: 7f3b852f8160 R14: 0030656c69662f2e R15: 7ffdc8faca88
 

Allocated by task 5092:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:312 [inline]
 __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:338
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3798 [inline]
 slab_alloc_node mm/slub.c:3845 [inline]
 kmem_cache_alloc+0x174/0x340 mm/slub.c:3852
 f2fs_kmem_cache_alloc_nofail fs/f2fs/f2fs.h:2817 [inline]
 f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:2827 [inline]
 __grab_extent_tree+0x183/0x400 fs/f2fs/extent_cache.c:334
 f2fs_init_read_extent_tree+0x455/0x910 fs/f2fs/extent_cache.c:405
 do_read_inode fs/f2fs/inode.c:506 [inline]
 f2fs_iget+0x33d1/0x46e0 fs/f2fs/inode.c:560
 f2fs_nfs_get_inode+0x74/0x100 fs/f2fs/super.c:3237
 generic_fh_to_dentry+0x9f/0xf0 fs/libfs.c:1413
 exportfs_decode_fh_raw+0x152/0x5f0 fs/exportfs/expfs.c:444
 exportfs_decode_fh+0x3c/0x80 fs/exportfs/expfs.c:584
 do_handle_to_path fs/fhandle.c:155 [inline]
 handle_to_path fs/fhandle.c:210 [inline]
 do_handle_open+0x495/0x650 fs/fhandle.c:226
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5092:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68

Re: [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2

2024-04-29 Thread Jaegeuk Kim
On 04/29, Jaegeuk Kim wrote:
> On 04/26, Wu Bo wrote:
> > As for zoned-UFS, f2fs section size is forced to zone size. And zone
> > size may not aligned to pow2.
> > 
> > Fixes: 859fca6b706e ("f2fs: swap: support migrating swapfile in aligned 
> > write mode")
> > Signed-off-by: Liao Yuanhong 
> > Signed-off-by: Wu Bo 
> > ---
> >  fs/f2fs/data.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index d9494b5fc7c1..7ff5ad3fd5dc 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -3904,7 +3904,6 @@ static int check_swap_activate(struct 
> > swap_info_struct *sis,
> > int nr_extents = 0;
> > unsigned long nr_pblocks;
> > unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
> > -   unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1;
> > unsigned int not_aligned = 0;
> > int ret = 0;
> >  
> > @@ -3942,8 +3941,8 @@ static int check_swap_activate(struct 
> > swap_info_struct *sis,
> > pblock = map.m_pblk;
> > nr_pblocks = map.m_len;
> >  
> > -   if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask ||
> > -   nr_pblocks & sec_blks_mask ||
> > +   if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec ||
> > +   nr_pblocks % blks_per_sec ||
> 
> Modified a bit to address udiv issue like below. Let's see.

Ok, I took v2 instead of this.

> 
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3923,8 +3923,8 @@ static int check_swap_activate(struct swap_info_struct 
> *sis,
> sector_t highest_pblock = 0;
> int nr_extents = 0;
> unsigned long nr_pblocks;
> +   u32 align;
> unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
> -   unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1;
> unsigned int not_aligned = 0;
> int ret = 0;
> 
> @@ -3961,10 +3961,10 @@ static int check_swap_activate(struct 
> swap_info_struct *sis,
> 
> pblock = map.m_pblk;
> nr_pblocks = map.m_len;
> +   div_u64_rem(nr_pblocks, blks_per_sec, );
> 
> -   if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask ||
> -   nr_pblocks & sec_blks_mask ||
> -   !f2fs_valid_pinned_area(sbi, pblock)) {
> +   if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec ||
> +   align || !f2fs_valid_pinned_area(sbi, 
> pblock)) {
> bool last_extent = false;
> 
> not_aligned++;
> 
> > !f2fs_valid_pinned_area(sbi, pblock)) {
> > bool last_extent = false;
> >  
> > -- 
> > 2.25.1


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs: fix block migration when section is not aligned to pow2

2024-04-29 Thread Jaegeuk Kim
On 04/26, Wu Bo wrote:
> As for zoned-UFS, f2fs section size is forced to zone size. And zone
> size may not aligned to pow2.
> 
> Fixes: 859fca6b706e ("f2fs: swap: support migrating swapfile in aligned write 
> mode")
> Signed-off-by: Liao Yuanhong 
> Signed-off-by: Wu Bo 
> ---
>  fs/f2fs/data.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index d9494b5fc7c1..7ff5ad3fd5dc 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3904,7 +3904,6 @@ static int check_swap_activate(struct swap_info_struct 
> *sis,
>   int nr_extents = 0;
>   unsigned long nr_pblocks;
>   unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
> - unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1;
>   unsigned int not_aligned = 0;
>   int ret = 0;
>  
> @@ -3942,8 +3941,8 @@ static int check_swap_activate(struct swap_info_struct 
> *sis,
>   pblock = map.m_pblk;
>   nr_pblocks = map.m_len;
>  
> - if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask ||
> - nr_pblocks & sec_blks_mask ||
> + if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec ||
> + nr_pblocks % blks_per_sec ||

Modified a bit to address udiv issue like below. Let's see.

--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3923,8 +3923,8 @@ static int check_swap_activate(struct swap_info_struct 
*sis,
sector_t highest_pblock = 0;
int nr_extents = 0;
unsigned long nr_pblocks;
+   u32 align;
unsigned int blks_per_sec = BLKS_PER_SEC(sbi);
-   unsigned int sec_blks_mask = BLKS_PER_SEC(sbi) - 1;
unsigned int not_aligned = 0;
int ret = 0;

@@ -3961,10 +3961,10 @@ static int check_swap_activate(struct swap_info_struct 
*sis,

pblock = map.m_pblk;
nr_pblocks = map.m_len;
+   div_u64_rem(nr_pblocks, blks_per_sec, );

-   if ((pblock - SM_I(sbi)->main_blkaddr) & sec_blks_mask ||
-   nr_pblocks & sec_blks_mask ||
-   !f2fs_valid_pinned_area(sbi, pblock)) {
+   if ((pblock - SM_I(sbi)->main_blkaddr) % blks_per_sec ||
+   align || !f2fs_valid_pinned_area(sbi, pblock)) {
bool last_extent = false;

not_aligned++;

>   !f2fs_valid_pinned_area(sbi, pblock)) {
>   bool last_extent = false;
>  
> -- 
> 2.25.1


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [Bug 218770] fsck seems unable to solve corruption

2024-04-29 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=218770

--- Comment #7 from Guido (guido.iod...@gmail.com) ---
(In reply to Jaegeuk Kim from comment #6)
> Thank you for the report. It seems I need to reapply that patch indeed.

Does rc6 contain the reapplied patch?

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel