Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-28 Thread Chao Yu

On 2021/1/29 0:12, Jaegeuk Kim wrote:

On 01/28, Chao Yu wrote:

On 2021/1/22 10:17, Chao Yu wrote:

No, it seems this is not the case.

Oops, could you please help to remove all below codes and do the test again
to check whether they are the buggy codes? as I doubt there is use-after-free
bug.


Any test result? :)


It seems I don't see the errors anymore. Will you post another version?


No, your test result only indicate that bug was caused by race condition
of that line with high possibility, however I've no idea how that happen
after several round code review. Still struggling in troubleshooting this
issue.

Thanks,





Thanks,

.



Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-28 Thread Jaegeuk Kim
On 01/28, Chao Yu wrote:
> On 2021/1/22 10:17, Chao Yu wrote:
> > > No, it seems this is not the case.
> > Oops, could you please help to remove all below codes and do the test again
> > to check whether they are the buggy codes? as I doubt there is 
> > use-after-free
> > bug.
> 
> Any test result? :)

It seems I don't see the errors anymore. Will you post another version?

> 
> Thanks,


Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-27 Thread Chao Yu

On 2021/1/22 10:17, Chao Yu wrote:

No, it seems this is not the case.

Oops, could you please help to remove all below codes and do the test again
to check whether they are the buggy codes? as I doubt there is use-after-free
bug.


Any test result? :)

Thanks,


Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-21 Thread Chao Yu

On 2021/1/20 5:42, Jaegeuk Kim wrote:

On 01/16, Chao Yu wrote:

On 2021/1/15 22:59, Jaegeuk Kim wrote:

On 01/15, Chao Yu wrote:

On 2021/1/14 12:06, Jaegeuk Kim wrote:

On 01/14, Chao Yu wrote:

On 2021/1/13 23:41, Jaegeuk Kim wrote:

[58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page of 
f2fs_quota_write+0x150/0x1f0 [f2fs]
[58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
[58691.077338] [ cut here ]
[58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr intel_rapl_common 
sb_edac kvm_intel kvm irqbypass joydev parport_pc parport input_leds serio_raw 
mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables autofs4 btrfs 
blake2b_generic raid10 raid456 async_raid6_recov async_memcpy asy
[58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
5.11.0-rc3-custom #1
[58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
[58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 89 f2 31 
c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 <0f> 0b 31 c0 e9 
5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
[58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
[58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
[58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 9c3bbbd58940
[58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: b429047afaa8
[58691.155266] R10: 001ba090 R11: 0003 R12: 7952
[58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
[58691.161160] FS:  () GS:9c3bbbd4() 
knlGS:
[58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
[58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 00370ee0
[58691.169714] DR0:  DR1:  DR2: 
[58691.173102] DR3:  DR6: fffe0ff0 DR7: 0400
[58691.176163] Call Trace:
[58691.177948]  f2fs_cache_compressed_page+0x69/0x280 [f2fs]
[58691.180549]  ? newidle_balance+0x253/0x3d0
[58691.183238]  f2fs_end_read_compressed_page+0x5a/0x70 [f2fs]
[58691.188205]  f2fs_post_read_work+0x11d/0x120 [f2fs]
[58691.192489]  process_one_work+0x221/0x3a0
[58691.194482]  worker_thread+0x4d/0x3f0
[58691.198867]  kthread+0x114/0x150
[58691.202243]  ? process_one_work+0x3a0/0x3a0
[58691.205367]  ? kthread_park+0x90/0x90
[58691.208244]  ret_from_fork+0x22/0x30


Below patch fixes two issues, I expect this can fix above warning at least.


[106115.591837] general protection fault, probably for non-canonical address 
0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
[106115.595584] CPU: 3 PID: 10109 Comm: fsstress Tainted: G   O  
5.11.0-rc3-custom #1
[106115.601087] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[106115.601087] RIP: 0010:f2fs_read_multi_pages+0x415/0xa70 [f2fs]


Jaegeuk,

Could you please help to run:

gdb f2fs.ko
(gdb) l *(f2fs_read_multi_pages+0x415)

to see where we hit the panic.


It's fs/f2fs/data.c:2203

2199 goto out_put_dnode;
2200 }
2201
2202 for (i = 0; i < dic->nr_cpages; i++) {


I doubt when i == cc->nr_cpages, dic was released in below condition,
then dic->nr_cpages can be any value (may be larger than cc->nr_cpages),
then we may continue the loop, and will access invalid pointer dic.

if (f2fs_load_compressed_page(sbi, page, blkaddr)) {
if (atomic_dec_and_test(>remaining_pages))
f2fs_decompress_cluster(dic);
continue;
}


I'd like to add a condition here (in between line 2202 and line 2203) to
make sure whether this can happen, could you please help to verify this?

f2fs_bug_on(sbi, i >= cc->nr_cpages);


No, it seems this is not the case.


Oops, could you please help to remove all below codes and do the test again
to check whether they are the buggy codes? as I doubt there is use-after-free
bug.

if (f2fs_load_compressed_page(sbi, page, blkaddr)) {
if (atomic_dec_and_test(>remaining_pages))
f2fs_decompress_cluster(dic);
continue;
}

Before that, please merge last fixing patch as below:

https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/commit/?h=dev=2371a9b8131712276458f1991a6ae394ef6c6c90

Thanks,





Thanks,


2203 struct page *page = dic->cpages[i];
2204 block_t blkaddr;

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-19 Thread Jaegeuk Kim
On 01/16, Chao Yu wrote:
> On 2021/1/15 22:59, Jaegeuk Kim wrote:
> > On 01/15, Chao Yu wrote:
> > > On 2021/1/14 12:06, Jaegeuk Kim wrote:
> > > > On 01/14, Chao Yu wrote:
> > > > > On 2021/1/13 23:41, Jaegeuk Kim wrote:
> > > > > > [58690.961685] F2FS-fs (vdb) : inject page get in 
> > > > > > f2fs_pagecache_get_page of f2fs_quota_write+0x150/0x1f0 [f2fs]
> > > > > > [58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit 
> > > > > > bitmap:0
> > > > > > [58691.077338] [ cut here ]
> > > > > > [58691.081461] WARNING: CPU: 5 PID: 8308 at 
> > > > > > fs/f2fs/checkpoint.c:151 f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > > > > > [58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree 
> > > > > > dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev 
> > > > > > intel_rapl_msr intel_rapl_common sb_edac kvm_intel kvm irqbypass 
> > > > > > joydev parport_pc parport input_leds serio_raw mac_hid qemu_fw_cfg 
> > > > > > sch_fq_codel ip_tables x_tables autofs4 btrfs blake2b_generic 
> > > > > > raid10 raid456 async_raid6_recov async_memcpy asy
> > > > > > [58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  
> > > > > > DO  5.11.0-rc3-custom #1
> > > > > > [58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 
> > > > > > 1996), BIOS 1.14.0-1 04/01/2014
> > > > > > [58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work 
> > > > > > [f2fs]
> > > > > > [58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > > > > > [58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 
> > > > > > 07 75 52 89 f2 31 c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 
> > > > > > f0 80 4b 48 04 <0f> 0b 31 c0 e9 5e fe ff ff 48 8b 57 10 8b 42 30 d3 
> > > > > > e0 03 42 48 39
> > > > > > [58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
> > > > > > [58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
> > > > > > 
> > > > > > [58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 
> > > > > > 9c3bbbd58940
> > > > > > [58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: 
> > > > > > b429047afaa8
> > > > > > [58691.155266] R10: 001ba090 R11: 0003 R12: 
> > > > > > 7952
> > > > > > [58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
> > > > > > 
> > > > > > [58691.161160] FS:  () 
> > > > > > GS:9c3bbbd4() knlGS:
> > > > > > [58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
> > > > > > [58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 
> > > > > > 00370ee0
> > > > > > [58691.169714] DR0:  DR1:  DR2: 
> > > > > > 
> > > > > > [58691.173102] DR3:  DR6: fffe0ff0 DR7: 
> > > > > > 0400
> > > > > > [58691.176163] Call Trace:
> > > > > > [58691.177948]  f2fs_cache_compressed_page+0x69/0x280 [f2fs]
> > > > > > [58691.180549]  ? newidle_balance+0x253/0x3d0
> > > > > > [58691.183238]  f2fs_end_read_compressed_page+0x5a/0x70 [f2fs]
> > > > > > [58691.188205]  f2fs_post_read_work+0x11d/0x120 [f2fs]
> > > > > > [58691.192489]  process_one_work+0x221/0x3a0
> > > > > > [58691.194482]  worker_thread+0x4d/0x3f0
> > > > > > [58691.198867]  kthread+0x114/0x150
> > > > > > [58691.202243]  ? process_one_work+0x3a0/0x3a0
> > > > > > [58691.205367]  ? kthread_park+0x90/0x90
> > > > > > [58691.208244]  ret_from_fork+0x22/0x30
> > > > > 
> > > > > Below patch fixes two issues, I expect this can fix above warning at 
> > > > > least.
> > > > 
> > > > [106115.591837] general protection fault, probably for non-canonical 
> > > > address 0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
> > > > [106115.595584] CPU: 3 PID: 10109 Comm: fsstress Tainted: G   O 
> > > >  5.11.0-rc3-custom #1
> > > > [106115.601087] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
> > > > BIOS 1.14.0-1 04/01/2014
> > > > [106115.601087] RIP: 0010:f2fs_read_multi_pages+0x415/0xa70 [f2fs]
> > > 
> > > Jaegeuk,
> > > 
> > > Could you please help to run:
> > > 
> > > gdb f2fs.ko
> > > (gdb) l *(f2fs_read_multi_pages+0x415)
> > > 
> > > to see where we hit the panic.
> > 
> > It's fs/f2fs/data.c:2203
> > 
> > 2199 goto out_put_dnode;
> > 2200 }
> > 2201
> > 2202 for (i = 0; i < dic->nr_cpages; i++) {
> 
> I doubt when i == cc->nr_cpages, dic was released in below condition,
> then dic->nr_cpages can be any value (may be larger than cc->nr_cpages),
> then we may continue the loop, and will access invalid pointer dic.
> 
>   if (f2fs_load_compressed_page(sbi, page, blkaddr)) {
>   if (atomic_dec_and_test(>remaining_pages))
>   f2fs_decompress_cluster(dic);
>   continue;
>   }
> 
> 
> I'd like to add a condition here (in between line 2202 and line 2203) to
> make sure 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-16 Thread Chao Yu

On 2021/1/15 22:59, Jaegeuk Kim wrote:

On 01/15, Chao Yu wrote:

On 2021/1/14 12:06, Jaegeuk Kim wrote:

On 01/14, Chao Yu wrote:

On 2021/1/13 23:41, Jaegeuk Kim wrote:

[58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page of 
f2fs_quota_write+0x150/0x1f0 [f2fs]
[58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
[58691.077338] [ cut here ]
[58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr intel_rapl_common 
sb_edac kvm_intel kvm irqbypass joydev parport_pc parport input_leds serio_raw 
mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables autofs4 btrfs 
blake2b_generic raid10 raid456 async_raid6_recov async_memcpy asy
[58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
5.11.0-rc3-custom #1
[58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
[58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 89 f2 31 
c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 <0f> 0b 31 c0 e9 
5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
[58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
[58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
[58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 9c3bbbd58940
[58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: b429047afaa8
[58691.155266] R10: 001ba090 R11: 0003 R12: 7952
[58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
[58691.161160] FS:  () GS:9c3bbbd4() 
knlGS:
[58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
[58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 00370ee0
[58691.169714] DR0:  DR1:  DR2: 
[58691.173102] DR3:  DR6: fffe0ff0 DR7: 0400
[58691.176163] Call Trace:
[58691.177948]  f2fs_cache_compressed_page+0x69/0x280 [f2fs]
[58691.180549]  ? newidle_balance+0x253/0x3d0
[58691.183238]  f2fs_end_read_compressed_page+0x5a/0x70 [f2fs]
[58691.188205]  f2fs_post_read_work+0x11d/0x120 [f2fs]
[58691.192489]  process_one_work+0x221/0x3a0
[58691.194482]  worker_thread+0x4d/0x3f0
[58691.198867]  kthread+0x114/0x150
[58691.202243]  ? process_one_work+0x3a0/0x3a0
[58691.205367]  ? kthread_park+0x90/0x90
[58691.208244]  ret_from_fork+0x22/0x30


Below patch fixes two issues, I expect this can fix above warning at least.


[106115.591837] general protection fault, probably for non-canonical address 
0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
[106115.595584] CPU: 3 PID: 10109 Comm: fsstress Tainted: G   O  
5.11.0-rc3-custom #1
[106115.601087] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[106115.601087] RIP: 0010:f2fs_read_multi_pages+0x415/0xa70 [f2fs]


Jaegeuk,

Could you please help to run:

gdb f2fs.ko
(gdb) l *(f2fs_read_multi_pages+0x415)

to see where we hit the panic.


It's fs/f2fs/data.c:2203

2199 goto out_put_dnode;
2200 }
2201
2202 for (i = 0; i < dic->nr_cpages; i++) {


I doubt when i == cc->nr_cpages, dic was released in below condition,
then dic->nr_cpages can be any value (may be larger than cc->nr_cpages),
then we may continue the loop, and will access invalid pointer dic.

if (f2fs_load_compressed_page(sbi, page, blkaddr)) {
if (atomic_dec_and_test(>remaining_pages))
f2fs_decompress_cluster(dic);
continue;
}


I'd like to add a condition here (in between line 2202 and line 2203) to make 
sure whether this can happen, could you please help to verify this?


f2fs_bug_on(sbi, i >= cc->nr_cpages);

Thanks,


2203 struct page *page = dic->cpages[i];
2204 block_t blkaddr;
2205 struct bio_post_read_ctx *ctx;
2206
2207 blkaddr = data_blkaddr(dn.inode, dn.node_page,
2208 dn.ofs_in_node + i + 1);




Thanks,


[106115.601087] Code: ff ff ff 45 31 ff f7 d0 25 00 00 08 00 89 45 80 48 8b 45 a0 48 
83 c0 6c 48 89 85 78 ff ff ff 48 8b 7d a0 49 63 c7 48 8b 57 30 <48> 8b 1c c2 8b 
45 c4 8d 50 01 48 8b 45 b8 48 2b 05 c6 55 92 dc 48
[106115.601087] RSP: 0018:c0a4822f7710 EFLAGS: 00010206
[106115.620978] RAX: 0001 RBX: e801820034c0 RCX: 
0020
[106115.620978] RDX: 6b6b6b6b6b6b6b6b RSI: c09487af RDI: 
9bc1d87c4200
[106115.627351] RBP: c0a4822f77c0 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-15 Thread Jaegeuk Kim
On 01/15, Chao Yu wrote:
> On 2021/1/14 12:06, Jaegeuk Kim wrote:
> > On 01/14, Chao Yu wrote:
> > > On 2021/1/13 23:41, Jaegeuk Kim wrote:
> > > > [58690.961685] F2FS-fs (vdb) : inject page get in 
> > > > f2fs_pagecache_get_page of f2fs_quota_write+0x150/0x1f0 [f2fs]
> > > > [58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit 
> > > > bitmap:0
> > > > [58691.077338] [ cut here ]
> > > > [58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
> > > > f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > > > [58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree 
> > > > dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr 
> > > > intel_rapl_common sb_edac kvm_intel kvm irqbypass joydev parport_pc 
> > > > parport input_leds serio_raw mac_hid qemu_fw_cfg sch_fq_codel ip_tables 
> > > > x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov 
> > > > async_memcpy asy
> > > > [58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  D   
> > > >  O  5.11.0-rc3-custom #1
> > > > [58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
> > > > BIOS 1.14.0-1 04/01/2014
> > > > [58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
> > > > [58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > > > [58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 
> > > > 52 89 f2 31 c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 
> > > > 04 <0f> 0b 31 c0 e9 5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
> > > > [58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
> > > > [58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
> > > > 
> > > > [58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 
> > > > 9c3bbbd58940
> > > > [58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: 
> > > > b429047afaa8
> > > > [58691.155266] R10: 001ba090 R11: 0003 R12: 
> > > > 7952
> > > > [58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
> > > > 
> > > > [58691.161160] FS:  () GS:9c3bbbd4() 
> > > > knlGS:
> > > > [58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
> > > > [58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 
> > > > 00370ee0
> > > > [58691.169714] DR0:  DR1:  DR2: 
> > > > 
> > > > [58691.173102] DR3:  DR6: fffe0ff0 DR7: 
> > > > 0400
> > > > [58691.176163] Call Trace:
> > > > [58691.177948]  f2fs_cache_compressed_page+0x69/0x280 [f2fs]
> > > > [58691.180549]  ? newidle_balance+0x253/0x3d0
> > > > [58691.183238]  f2fs_end_read_compressed_page+0x5a/0x70 [f2fs]
> > > > [58691.188205]  f2fs_post_read_work+0x11d/0x120 [f2fs]
> > > > [58691.192489]  process_one_work+0x221/0x3a0
> > > > [58691.194482]  worker_thread+0x4d/0x3f0
> > > > [58691.198867]  kthread+0x114/0x150
> > > > [58691.202243]  ? process_one_work+0x3a0/0x3a0
> > > > [58691.205367]  ? kthread_park+0x90/0x90
> > > > [58691.208244]  ret_from_fork+0x22/0x30
> > > 
> > > Below patch fixes two issues, I expect this can fix above warning at 
> > > least.
> > 
> > [106115.591837] general protection fault, probably for non-canonical 
> > address 0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
> > [106115.595584] CPU: 3 PID: 10109 Comm: fsstress Tainted: G   O 
> >  5.11.0-rc3-custom #1
> > [106115.601087] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> > 1.14.0-1 04/01/2014
> > [106115.601087] RIP: 0010:f2fs_read_multi_pages+0x415/0xa70 [f2fs]
> 
> Jaegeuk,
> 
> Could you please help to run:
> 
> gdb f2fs.ko
> (gdb) l *(f2fs_read_multi_pages+0x415)
> 
> to see where we hit the panic.

It's fs/f2fs/data.c:2203

2199 goto out_put_dnode;
2200 }
2201
2202 for (i = 0; i < dic->nr_cpages; i++) {
2203 struct page *page = dic->cpages[i];
2204 block_t blkaddr;
2205 struct bio_post_read_ctx *ctx;
2206
2207 blkaddr = data_blkaddr(dn.inode, dn.node_page,
2208 dn.ofs_in_node + i + 1);


> 
> Thanks,
> 
> > [106115.601087] Code: ff ff ff 45 31 ff f7 d0 25 00 00 08 00 89 45 80 48 8b 
> > 45 a0 48 83 c0 6c 48 89 85 78 ff ff ff 48 8b 7d a0 49 63 c7 48 8b 57 30 
> > <48> 8b 1c c2 8b 45 c4 8d 50 01 48 8b 45 b8 48 2b 05 c6 55 92 dc 48
> > [106115.601087] RSP: 0018:c0a4822f7710 EFLAGS: 00010206
> > [106115.620978] RAX: 0001 RBX: e801820034c0 RCX: 
> > 0020
> > [106115.620978] RDX: 6b6b6b6b6b6b6b6b RSI: c09487af RDI: 
> > 9bc1d87c4200
> > [106115.627351] RBP: c0a4822f77c0 R08:  R09: 
> > 
> > [106115.627351] R10: 9bc1d87c4200 R11: 0001 R12: 
> > 00105343
> > [106115.627351] 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-15 Thread Chao Yu

On 2021/1/14 12:06, Jaegeuk Kim wrote:

On 01/14, Chao Yu wrote:

On 2021/1/13 23:41, Jaegeuk Kim wrote:

[58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page of 
f2fs_quota_write+0x150/0x1f0 [f2fs]
[58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
[58691.077338] [ cut here ]
[58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr intel_rapl_common 
sb_edac kvm_intel kvm irqbypass joydev parport_pc parport input_leds serio_raw 
mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables autofs4 btrfs 
blake2b_generic raid10 raid456 async_raid6_recov async_memcpy asy
[58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
5.11.0-rc3-custom #1
[58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
[58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 89 f2 31 
c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 <0f> 0b 31 c0 e9 
5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
[58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
[58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
[58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 9c3bbbd58940
[58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: b429047afaa8
[58691.155266] R10: 001ba090 R11: 0003 R12: 7952
[58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
[58691.161160] FS:  () GS:9c3bbbd4() 
knlGS:
[58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
[58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 00370ee0
[58691.169714] DR0:  DR1:  DR2: 
[58691.173102] DR3:  DR6: fffe0ff0 DR7: 0400
[58691.176163] Call Trace:
[58691.177948]  f2fs_cache_compressed_page+0x69/0x280 [f2fs]
[58691.180549]  ? newidle_balance+0x253/0x3d0
[58691.183238]  f2fs_end_read_compressed_page+0x5a/0x70 [f2fs]
[58691.188205]  f2fs_post_read_work+0x11d/0x120 [f2fs]
[58691.192489]  process_one_work+0x221/0x3a0
[58691.194482]  worker_thread+0x4d/0x3f0
[58691.198867]  kthread+0x114/0x150
[58691.202243]  ? process_one_work+0x3a0/0x3a0
[58691.205367]  ? kthread_park+0x90/0x90
[58691.208244]  ret_from_fork+0x22/0x30


Below patch fixes two issues, I expect this can fix above warning at least.


[106115.591837] general protection fault, probably for non-canonical address 
0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
[106115.595584] CPU: 3 PID: 10109 Comm: fsstress Tainted: G   O  
5.11.0-rc3-custom #1
[106115.601087] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[106115.601087] RIP: 0010:f2fs_read_multi_pages+0x415/0xa70 [f2fs]


Jaegeuk,

Could you please help to run:

gdb f2fs.ko
(gdb) l *(f2fs_read_multi_pages+0x415)

to see where we hit the panic.

Thanks,


[106115.601087] Code: ff ff ff 45 31 ff f7 d0 25 00 00 08 00 89 45 80 48 8b 45 a0 48 
83 c0 6c 48 89 85 78 ff ff ff 48 8b 7d a0 49 63 c7 48 8b 57 30 <48> 8b 1c c2 8b 
45 c4 8d 50 01 48 8b 45 b8 48 2b 05 c6 55 92 dc 48
[106115.601087] RSP: 0018:c0a4822f7710 EFLAGS: 00010206
[106115.620978] RAX: 0001 RBX: e801820034c0 RCX: 
0020
[106115.620978] RDX: 6b6b6b6b6b6b6b6b RSI: c09487af RDI: 
9bc1d87c4200
[106115.627351] RBP: c0a4822f77c0 R08:  R09: 

[106115.627351] R10: 9bc1d87c4200 R11: 0001 R12: 
00105343
[106115.627351] R13: 9bc2d2184000 R14:  R15: 
0001
[106115.635587] FS:  7f188e909b80() GS:9bc2fbcc() 
knlGS:
[106115.635587] CS:  0010 DS:  ES:  CR0: 80050033
[106115.635587] CR2: 56446d88b358 CR3: 534b4002 CR4: 
00370ee0
[106115.635587] DR0:  DR1:  DR2: 

[106115.635587] DR3:  DR6: fffe0ff0 DR7: 
0400
[106115.635587] Call Trace:
[106115.635587]  f2fs_mpage_readpages+0x4e4/0xac0 [f2fs]
[106115.635587]  f2fs_readahead+0x47/0x90 [f2fs]
[106115.635587]  read_pages+0x8e/0x280
[106115.635587]  page_cache_ra_unbounded+0x11f/0x1f0
[106115.665909]  do_page_cache_ra+0x3d/0x40
[106115.670756]  ondemand_readahead+0x2c1/0x2e0
[106115.671682]  page_cache_sync_ra+0xd4/0xe0
[106115.675622]  generic_file_buffered_read_get_pages+0x126/0x8d0
[106115.679158]  generic_file_buffered_read+0x113/0x4a0
[106115.679158]  ? __filemap_fdatawrite_range+0xd8/0x110

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-13 Thread Jaegeuk Kim
On 01/14, Chao Yu wrote:
> On 2021/1/13 23:41, Jaegeuk Kim wrote:
> > [58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page 
> > of f2fs_quota_write+0x150/0x1f0 [f2fs]
> > [58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
> > [58691.077338] [ cut here ]
> > [58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
> > f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > [58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
> > scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr 
> > intel_rapl_common sb_edac kvm_intel kvm irqbypass joydev parport_pc parport 
> > input_leds serio_raw mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables 
> > autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy 
> > asy
> > [58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
> > 5.11.0-rc3-custom #1
> > [58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> > 1.14.0-1 04/01/2014
> > [58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
> > [58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > [58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 
> > 89 f2 31 c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 
> > <0f> 0b 31 c0 e9 5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
> > [58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
> > [58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
> > 
> > [58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 
> > 9c3bbbd58940
> > [58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: 
> > b429047afaa8
> > [58691.155266] R10: 001ba090 R11: 0003 R12: 
> > 7952
> > [58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
> > 
> > [58691.161160] FS:  () GS:9c3bbbd4() 
> > knlGS:
> > [58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
> > [58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 
> > 00370ee0
> > [58691.169714] DR0:  DR1:  DR2: 
> > 
> > [58691.173102] DR3:  DR6: fffe0ff0 DR7: 
> > 0400
> > [58691.176163] Call Trace:
> > [58691.177948]  f2fs_cache_compressed_page+0x69/0x280 [f2fs]
> > [58691.180549]  ? newidle_balance+0x253/0x3d0
> > [58691.183238]  f2fs_end_read_compressed_page+0x5a/0x70 [f2fs]
> > [58691.188205]  f2fs_post_read_work+0x11d/0x120 [f2fs]
> > [58691.192489]  process_one_work+0x221/0x3a0
> > [58691.194482]  worker_thread+0x4d/0x3f0
> > [58691.198867]  kthread+0x114/0x150
> > [58691.202243]  ? process_one_work+0x3a0/0x3a0
> > [58691.205367]  ? kthread_park+0x90/0x90
> > [58691.208244]  ret_from_fork+0x22/0x30
> 
> Below patch fixes two issues, I expect this can fix above warning at least.

[106115.591837] general protection fault, probably for non-canonical address 
0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
[106115.595584] CPU: 3 PID: 10109 Comm: fsstress Tainted: G   O  
5.11.0-rc3-custom #1
[106115.601087] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[106115.601087] RIP: 0010:f2fs_read_multi_pages+0x415/0xa70 [f2fs]
[106115.601087] Code: ff ff ff 45 31 ff f7 d0 25 00 00 08 00 89 45 80 48 8b 45 
a0 48 83 c0 6c 48 89 85 78 ff ff ff 48 8b 7d a0 49 63 c7 48 8b 57 30 <48> 8b 1c 
c2 8b 45 c4 8d 50 01 48 8b 45 b8 48 2b 05 c6 55 92 dc 48
[106115.601087] RSP: 0018:c0a4822f7710 EFLAGS: 00010206
[106115.620978] RAX: 0001 RBX: e801820034c0 RCX: 
0020
[106115.620978] RDX: 6b6b6b6b6b6b6b6b RSI: c09487af RDI: 
9bc1d87c4200
[106115.627351] RBP: c0a4822f77c0 R08:  R09: 

[106115.627351] R10: 9bc1d87c4200 R11: 0001 R12: 
00105343
[106115.627351] R13: 9bc2d2184000 R14:  R15: 
0001
[106115.635587] FS:  7f188e909b80() GS:9bc2fbcc() 
knlGS:
[106115.635587] CS:  0010 DS:  ES:  CR0: 80050033
[106115.635587] CR2: 56446d88b358 CR3: 534b4002 CR4: 
00370ee0
[106115.635587] DR0:  DR1:  DR2: 

[106115.635587] DR3:  DR6: fffe0ff0 DR7: 
0400
[106115.635587] Call Trace:
[106115.635587]  f2fs_mpage_readpages+0x4e4/0xac0 [f2fs]
[106115.635587]  f2fs_readahead+0x47/0x90 [f2fs]
[106115.635587]  read_pages+0x8e/0x280
[106115.635587]  page_cache_ra_unbounded+0x11f/0x1f0
[106115.665909]  do_page_cache_ra+0x3d/0x40
[106115.670756]  ondemand_readahead+0x2c1/0x2e0
[106115.671682]  page_cache_sync_ra+0xd4/0xe0
[106115.675622]  generic_file_buffered_read_get_pages+0x126/0x8d0
[106115.679158]  generic_file_buffered_read+0x113/0x4a0
[106115.679158]  ? 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-13 Thread Chao Yu

On 2021/1/13 23:41, Jaegeuk Kim wrote:

[58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page of 
f2fs_quota_write+0x150/0x1f0 [f2fs]
[58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
[58691.077338] [ cut here ]
[58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr intel_rapl_common 
sb_edac kvm_intel kvm irqbypass joydev parport_pc parport input_leds serio_raw 
mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables autofs4 btrfs 
blake2b_generic raid10 raid456 async_raid6_recov async_memcpy asy
[58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
5.11.0-rc3-custom #1
[58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
[58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 89 f2 31 
c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 <0f> 0b 31 c0 e9 
5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
[58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
[58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
[58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 9c3bbbd58940
[58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: b429047afaa8
[58691.155266] R10: 001ba090 R11: 0003 R12: 7952
[58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
[58691.161160] FS:  () GS:9c3bbbd4() 
knlGS:
[58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
[58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 00370ee0
[58691.169714] DR0:  DR1:  DR2: 
[58691.173102] DR3:  DR6: fffe0ff0 DR7: 0400
[58691.176163] Call Trace:
[58691.177948]  f2fs_cache_compressed_page+0x69/0x280 [f2fs]
[58691.180549]  ? newidle_balance+0x253/0x3d0
[58691.183238]  f2fs_end_read_compressed_page+0x5a/0x70 [f2fs]
[58691.188205]  f2fs_post_read_work+0x11d/0x120 [f2fs]
[58691.192489]  process_one_work+0x221/0x3a0
[58691.194482]  worker_thread+0x4d/0x3f0
[58691.198867]  kthread+0x114/0x150
[58691.202243]  ? process_one_work+0x3a0/0x3a0
[58691.205367]  ? kthread_park+0x90/0x90
[58691.208244]  ret_from_fork+0x22/0x30


Below patch fixes two issues, I expect this can fix above warning at least.

- detect truncation during f2fs_cache_compressed_page()
- don't set PageUptodate for temporary page in f2fs_load_compressed_page()

From: Chao Yu 

Signed-off-by: Chao Yu 
---
 fs/f2fs/compress.c | 20 +---
 fs/f2fs/data.c |  3 +--
 fs/f2fs/f2fs.h |  6 +++---
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 0fec71e40001..f364c10c506c 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1741,7 +1741,7 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, 
struct page *page,
if (!test_opt(sbi, COMPRESS_CACHE))
return;

-   if (!f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE))
+   if (!f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE_READ))
return;

si_meminfo();
@@ -1774,21 +1774,25 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info 
*sbi, struct page *page,
return;
}

-   memcpy(page_address(cpage), page_address(page), PAGE_SIZE);
-   SetPageUptodate(cpage);
-
f2fs_set_page_private(cpage, ino);

+   if (!f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE_READ))
+   goto out;
+
+   memcpy(page_address(cpage), page_address(page), PAGE_SIZE);
+   SetPageUptodate(cpage);
+out:
f2fs_put_page(cpage, 1);
 }

-void f2fs_load_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
+bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
block_t blkaddr)
 {
struct page *cpage;
+   bool hitted = false;

if (!test_opt(sbi, COMPRESS_CACHE))
-   return;
+   return false;

cpage = f2fs_pagecache_get_page(COMPRESS_MAPPING(sbi),
blkaddr, FGP_LOCK | FGP_NOWAIT, GFP_NOFS);
@@ -1797,10 +1801,12 @@ void f2fs_load_compressed_page(struct f2fs_sb_info 
*sbi, struct page *page,
atomic_inc(>compress_page_hit);
memcpy(page_address(page),
page_address(cpage), PAGE_SIZE);
-   SetPageUptodate(page);
+  

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-13 Thread Jaegeuk Kim
On 01/13, Chao Yu wrote:
> On 2021/1/13 6:36, Jaegeuk Kim wrote:
> > On 01/12, Chao Yu wrote:
> > > On 2021/1/12 10:04, Jaegeuk Kim wrote:
> > > > On 01/12, Chao Yu wrote:
> > > > > On 2021/1/11 19:45, Chao Yu wrote:
> > > > > > On 2021/1/11 18:31, Chao Yu wrote:
> > > > > > > On 2021/1/11 17:48, Jaegeuk Kim wrote:
> > > > > > > > Hi Chao,
> > > > > > > > 
> > > > > > > > After quick test of fsstress w/ fault injection, it gave wrong 
> > > > > > > > block address
> > > > > > > > errors. Could you please run the test a bit?
> > > > > > > 
> > > > > > > Jaegeuk,
> > > > > > > 
> > > > > > > Oh, I've covered with fstest cases and there is no such error 
> > > > > > > message, let me
> > > > > > > try fault injection + SPO case soon.
> > > > > > 
> > > > > > Till now, I haven't see any problem... will let the test run for 
> > > > > > longer time in
> > > > > > this night.
> > > > > > 
> > > > > > Could you share me detailed error message you encounter?
> > > > > 
> > > > > Still, I don't see wrong block address error...
> > > > > 
> > > > > Did the error occur from below path:
> > > > > 
> > > > > - f2fs_end_read_compressed_page
> > > > >- f2fs_cache_compressed_page
> > > > > - f2fs_is_valid_blkaddr
> > > > 
> > > > [58690.176668] general protection fault, probably for non-canonical 
> > > > address 0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
> > > > [58690.180563] CPU: 0 PID: 29371 Comm: fsstress Tainted: G   O  
> > > > 5.11.0-rc3-custom #1
> > > > [58690.186466] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
> > > > BIOS 1.14.0-1 04/01/2014
> > > > [58690.189352] RIP: 0010:f2fs_read_multi_pages+0x413/0xa70 [f2fs]
> > > > [58690.193366] Code: ad 54 ff ff ff 4c 8b ad 68 ff ff ff 25 00 00 08 00 
> > > > 89 85 78 ff ff ff 49 8d 47 6c 48 89 85 70 ff ff ff 48 63 45 a0 49 8b 57 
> > > > 30 <4c> 8b 34 c2 8b 45 c4 8d 50 01 48 8b 45 b8 48 2b 05 98 56 40 c8 48
> > > > [58690.212479] RSP: 0018:b429022dfa60 EFLAGS: 00010206
> > > > [58690.218410] RAX: 0001 RBX: 78af RCX: 
> > > > 0020
> > > > [58690.222473] RDX: 6b6b6b6b6b6b6b6b RSI: c0a6872f RDI: 
> > > > 0246
> > > > [58690.227349] RBP: b429022dfb10 R08:  R09: 
> > > > 
> > > > [58690.234425] R10: 9c3af1f78200 R11: 0001 R12: 
> > > > 
> > > > [58690.238503] R13: 9c3b84041000 R14: f5cc8166f5c0 R15: 
> > > > 9c3af1f78200
> > > > [58690.242455] FS:  7f0fee9d4b80() GS:9c3bbbc0() 
> > > > knlGS:
> > > > [58690.246401] CS:  0010 DS:  ES:  CR0: 80050033
> > > > [58690.250471] CR2: 563b839c1000 CR3: 2cb0e004 CR4: 
> > > > 00370ef0
> > > > [58690.250471] DR0:  DR1:  DR2: 
> > > > 
> > > > [58690.258758] DR3:  DR6: fffe0ff0 DR7: 
> > > > 0400
> > > > [58690.262464] Call Trace:
> > > > [58690.262464]  prepare_compress_overwrite+0x380/0x510 [f2fs]
> > > > [58690.266489]  ? xas_load+0x9/0x80
> > > > [58690.270452]  f2fs_prepare_compress_overwrite+0x5f/0x80 [f2fs]
> > > > [58690.274466]  f2fs_write_begin+0x81e/0x1120 [f2fs]
> > > > [58690.277213]  generic_perform_write+0xc2/0x1c0
> > > > [58690.278698]  __generic_file_write_iter+0x167/0x1d0
> > > > [58690.286472]  f2fs_file_write_iter+0x39e/0x590 [f2fs]
> > > > [58690.290398]  new_sync_write+0x117/0x1b0
> > > > [58690.290461]  vfs_write+0x185/0x250
> > > > [58690.295197]  ksys_write+0x67/0xe0
> > > > [58690.298173]  __x64_sys_write+0x1a/0x20
> > > > [58690.298437]  do_syscall_64+0x38/0x90
> > > > [58690.298437]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > > > 
> > > > [58690.961685] F2FS-fs (vdb) : inject page get in 
> > > > f2fs_pagecache_get_page of f2fs_quota_write+0x150/0x1f0 [f2fs]
> > > > [58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit 
> > > > bitmap:0
> > > > [58691.077338] [ cut here ]
> > > > [58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
> > > > f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > > > [58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree 
> > > > dm_multipath scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr 
> > > > intel_rapl_common sb_edac kvm_intel kvm irqbypass joydev parport_pc 
> > > > parport input_leds serio_raw mac_hid qemu_fw_cfg sch_fq_codel ip_tables 
> > > > x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov 
> > > > async_memcpy asy
> > > > [58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  D   
> > > >  O  5.11.0-rc3-custom #1
> > > > [58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
> > > > BIOS 1.14.0-1 04/01/2014
> > > > [58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
> > > > [58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > > > [58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-12 Thread Chao Yu

On 2021/1/13 6:36, Jaegeuk Kim wrote:

On 01/12, Chao Yu wrote:

On 2021/1/12 10:04, Jaegeuk Kim wrote:

On 01/12, Chao Yu wrote:

On 2021/1/11 19:45, Chao Yu wrote:

On 2021/1/11 18:31, Chao Yu wrote:

On 2021/1/11 17:48, Jaegeuk Kim wrote:

Hi Chao,

After quick test of fsstress w/ fault injection, it gave wrong block address
errors. Could you please run the test a bit?


Jaegeuk,

Oh, I've covered with fstest cases and there is no such error message, let me
try fault injection + SPO case soon.


Till now, I haven't see any problem... will let the test run for longer time in
this night.

Could you share me detailed error message you encounter?


Still, I don't see wrong block address error...

Did the error occur from below path:

- f2fs_end_read_compressed_page
   - f2fs_cache_compressed_page
- f2fs_is_valid_blkaddr


[58690.176668] general protection fault, probably for non-canonical address 
0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
[58690.180563] CPU: 0 PID: 29371 Comm: fsstress Tainted: G   O  
5.11.0-rc3-custom #1
[58690.186466] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58690.189352] RIP: 0010:f2fs_read_multi_pages+0x413/0xa70 [f2fs]
[58690.193366] Code: ad 54 ff ff ff 4c 8b ad 68 ff ff ff 25 00 00 08 00 89 85 78 ff 
ff ff 49 8d 47 6c 48 89 85 70 ff ff ff 48 63 45 a0 49 8b 57 30 <4c> 8b 34 c2 8b 
45 c4 8d 50 01 48 8b 45 b8 48 2b 05 98 56 40 c8 48
[58690.212479] RSP: 0018:b429022dfa60 EFLAGS: 00010206
[58690.218410] RAX: 0001 RBX: 78af RCX: 0020
[58690.222473] RDX: 6b6b6b6b6b6b6b6b RSI: c0a6872f RDI: 0246
[58690.227349] RBP: b429022dfb10 R08:  R09: 
[58690.234425] R10: 9c3af1f78200 R11: 0001 R12: 
[58690.238503] R13: 9c3b84041000 R14: f5cc8166f5c0 R15: 9c3af1f78200
[58690.242455] FS:  7f0fee9d4b80() GS:9c3bbbc0() 
knlGS:
[58690.246401] CS:  0010 DS:  ES:  CR0: 80050033
[58690.250471] CR2: 563b839c1000 CR3: 2cb0e004 CR4: 00370ef0
[58690.250471] DR0:  DR1:  DR2: 
[58690.258758] DR3:  DR6: fffe0ff0 DR7: 0400
[58690.262464] Call Trace:
[58690.262464]  prepare_compress_overwrite+0x380/0x510 [f2fs]
[58690.266489]  ? xas_load+0x9/0x80
[58690.270452]  f2fs_prepare_compress_overwrite+0x5f/0x80 [f2fs]
[58690.274466]  f2fs_write_begin+0x81e/0x1120 [f2fs]
[58690.277213]  generic_perform_write+0xc2/0x1c0
[58690.278698]  __generic_file_write_iter+0x167/0x1d0
[58690.286472]  f2fs_file_write_iter+0x39e/0x590 [f2fs]
[58690.290398]  new_sync_write+0x117/0x1b0
[58690.290461]  vfs_write+0x185/0x250
[58690.295197]  ksys_write+0x67/0xe0
[58690.298173]  __x64_sys_write+0x1a/0x20
[58690.298437]  do_syscall_64+0x38/0x90
[58690.298437]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

[58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page of 
f2fs_quota_write+0x150/0x1f0 [f2fs]
[58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
[58691.077338] [ cut here ]
[58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr intel_rapl_common 
sb_edac kvm_intel kvm irqbypass joydev parport_pc parport input_leds serio_raw 
mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables autofs4 btrfs 
blake2b_generic raid10 raid456 async_raid6_recov async_memcpy asy
[58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
5.11.0-rc3-custom #1
[58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
[58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 89 f2 31 
c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 <0f> 0b 31 c0 e9 
5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
[58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
[58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
[58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 9c3bbbd58940
[58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: b429047afaa8
[58691.155266] R10: 001ba090 R11: 0003 R12: 7952
[58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
[58691.161160] FS:  () GS:9c3bbbd4() 
knlGS:
[58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
[58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 00370ee0
[58691.169714] DR0:  DR1:  DR2: 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-12 Thread Jaegeuk Kim
On 01/12, Chao Yu wrote:
> On 2021/1/12 10:04, Jaegeuk Kim wrote:
> > On 01/12, Chao Yu wrote:
> > > On 2021/1/11 19:45, Chao Yu wrote:
> > > > On 2021/1/11 18:31, Chao Yu wrote:
> > > > > On 2021/1/11 17:48, Jaegeuk Kim wrote:
> > > > > > Hi Chao,
> > > > > > 
> > > > > > After quick test of fsstress w/ fault injection, it gave wrong 
> > > > > > block address
> > > > > > errors. Could you please run the test a bit?
> > > > > 
> > > > > Jaegeuk,
> > > > > 
> > > > > Oh, I've covered with fstest cases and there is no such error 
> > > > > message, let me
> > > > > try fault injection + SPO case soon.
> > > > 
> > > > Till now, I haven't see any problem... will let the test run for longer 
> > > > time in
> > > > this night.
> > > > 
> > > > Could you share me detailed error message you encounter?
> > > 
> > > Still, I don't see wrong block address error...
> > > 
> > > Did the error occur from below path:
> > > 
> > > - f2fs_end_read_compressed_page
> > >   - f2fs_cache_compressed_page
> > >- f2fs_is_valid_blkaddr
> > 
> > [58690.176668] general protection fault, probably for non-canonical address 
> > 0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
> > [58690.180563] CPU: 0 PID: 29371 Comm: fsstress Tainted: G   O  
> > 5.11.0-rc3-custom #1
> > [58690.186466] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> > 1.14.0-1 04/01/2014
> > [58690.189352] RIP: 0010:f2fs_read_multi_pages+0x413/0xa70 [f2fs]
> > [58690.193366] Code: ad 54 ff ff ff 4c 8b ad 68 ff ff ff 25 00 00 08 00 89 
> > 85 78 ff ff ff 49 8d 47 6c 48 89 85 70 ff ff ff 48 63 45 a0 49 8b 57 30 
> > <4c> 8b 34 c2 8b 45 c4 8d 50 01 48 8b 45 b8 48 2b 05 98 56 40 c8 48
> > [58690.212479] RSP: 0018:b429022dfa60 EFLAGS: 00010206
> > [58690.218410] RAX: 0001 RBX: 78af RCX: 
> > 0020
> > [58690.222473] RDX: 6b6b6b6b6b6b6b6b RSI: c0a6872f RDI: 
> > 0246
> > [58690.227349] RBP: b429022dfb10 R08:  R09: 
> > 
> > [58690.234425] R10: 9c3af1f78200 R11: 0001 R12: 
> > 
> > [58690.238503] R13: 9c3b84041000 R14: f5cc8166f5c0 R15: 
> > 9c3af1f78200
> > [58690.242455] FS:  7f0fee9d4b80() GS:9c3bbbc0() 
> > knlGS:
> > [58690.246401] CS:  0010 DS:  ES:  CR0: 80050033
> > [58690.250471] CR2: 563b839c1000 CR3: 2cb0e004 CR4: 
> > 00370ef0
> > [58690.250471] DR0:  DR1:  DR2: 
> > 
> > [58690.258758] DR3:  DR6: fffe0ff0 DR7: 
> > 0400
> > [58690.262464] Call Trace:
> > [58690.262464]  prepare_compress_overwrite+0x380/0x510 [f2fs]
> > [58690.266489]  ? xas_load+0x9/0x80
> > [58690.270452]  f2fs_prepare_compress_overwrite+0x5f/0x80 [f2fs]
> > [58690.274466]  f2fs_write_begin+0x81e/0x1120 [f2fs]
> > [58690.277213]  generic_perform_write+0xc2/0x1c0
> > [58690.278698]  __generic_file_write_iter+0x167/0x1d0
> > [58690.286472]  f2fs_file_write_iter+0x39e/0x590 [f2fs]
> > [58690.290398]  new_sync_write+0x117/0x1b0
> > [58690.290461]  vfs_write+0x185/0x250
> > [58690.295197]  ksys_write+0x67/0xe0
> > [58690.298173]  __x64_sys_write+0x1a/0x20
> > [58690.298437]  do_syscall_64+0x38/0x90
> > [58690.298437]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > 
> > [58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page 
> > of f2fs_quota_write+0x150/0x1f0 [f2fs]
> > [58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
> > [58691.077338] [ cut here ]
> > [58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
> > f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > [58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
> > scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr 
> > intel_rapl_common sb_edac kvm_intel kvm irqbypass joydev parport_pc parport 
> > input_leds serio_raw mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables 
> > autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy 
> > asy
> > [58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
> > 5.11.0-rc3-custom #1
> > [58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> > 1.14.0-1 04/01/2014
> > [58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
> > [58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
> > [58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 
> > 89 f2 31 c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 
> > <0f> 0b 31 c0 e9 5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
> > [58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
> > [58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
> > 
> > [58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 
> > 9c3bbbd58940
> > [58691.152130] RBP: b429047afd48 R08: 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-12 Thread Chao Yu

On 2021/1/12 10:04, Jaegeuk Kim wrote:

On 01/12, Chao Yu wrote:

On 2021/1/11 19:45, Chao Yu wrote:

On 2021/1/11 18:31, Chao Yu wrote:

On 2021/1/11 17:48, Jaegeuk Kim wrote:

Hi Chao,

After quick test of fsstress w/ fault injection, it gave wrong block address
errors. Could you please run the test a bit?


Jaegeuk,

Oh, I've covered with fstest cases and there is no such error message, let me
try fault injection + SPO case soon.


Till now, I haven't see any problem... will let the test run for longer time in
this night.

Could you share me detailed error message you encounter?


Still, I don't see wrong block address error...

Did the error occur from below path:

- f2fs_end_read_compressed_page
  - f2fs_cache_compressed_page
   - f2fs_is_valid_blkaddr


[58690.176668] general protection fault, probably for non-canonical address 
0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
[58690.180563] CPU: 0 PID: 29371 Comm: fsstress Tainted: G   O  
5.11.0-rc3-custom #1
[58690.186466] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58690.189352] RIP: 0010:f2fs_read_multi_pages+0x413/0xa70 [f2fs]
[58690.193366] Code: ad 54 ff ff ff 4c 8b ad 68 ff ff ff 25 00 00 08 00 89 85 78 ff 
ff ff 49 8d 47 6c 48 89 85 70 ff ff ff 48 63 45 a0 49 8b 57 30 <4c> 8b 34 c2 8b 
45 c4 8d 50 01 48 8b 45 b8 48 2b 05 98 56 40 c8 48
[58690.212479] RSP: 0018:b429022dfa60 EFLAGS: 00010206
[58690.218410] RAX: 0001 RBX: 78af RCX: 0020
[58690.222473] RDX: 6b6b6b6b6b6b6b6b RSI: c0a6872f RDI: 0246
[58690.227349] RBP: b429022dfb10 R08:  R09: 
[58690.234425] R10: 9c3af1f78200 R11: 0001 R12: 
[58690.238503] R13: 9c3b84041000 R14: f5cc8166f5c0 R15: 9c3af1f78200
[58690.242455] FS:  7f0fee9d4b80() GS:9c3bbbc0() 
knlGS:
[58690.246401] CS:  0010 DS:  ES:  CR0: 80050033
[58690.250471] CR2: 563b839c1000 CR3: 2cb0e004 CR4: 00370ef0
[58690.250471] DR0:  DR1:  DR2: 
[58690.258758] DR3:  DR6: fffe0ff0 DR7: 0400
[58690.262464] Call Trace:
[58690.262464]  prepare_compress_overwrite+0x380/0x510 [f2fs]
[58690.266489]  ? xas_load+0x9/0x80
[58690.270452]  f2fs_prepare_compress_overwrite+0x5f/0x80 [f2fs]
[58690.274466]  f2fs_write_begin+0x81e/0x1120 [f2fs]
[58690.277213]  generic_perform_write+0xc2/0x1c0
[58690.278698]  __generic_file_write_iter+0x167/0x1d0
[58690.286472]  f2fs_file_write_iter+0x39e/0x590 [f2fs]
[58690.290398]  new_sync_write+0x117/0x1b0
[58690.290461]  vfs_write+0x185/0x250
[58690.295197]  ksys_write+0x67/0xe0
[58690.298173]  __x64_sys_write+0x1a/0x20
[58690.298437]  do_syscall_64+0x38/0x90
[58690.298437]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

[58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page of 
f2fs_quota_write+0x150/0x1f0 [f2fs]
[58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
[58691.077338] [ cut here ]
[58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr intel_rapl_common 
sb_edac kvm_intel kvm irqbypass joydev parport_pc parport input_leds serio_raw 
mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables autofs4 btrfs 
blake2b_generic raid10 raid456 async_raid6_recov async_memcpy asy
[58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
5.11.0-rc3-custom #1
[58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
[58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 89 f2 31 
c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 <0f> 0b 31 c0 e9 
5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
[58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
[58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
[58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 9c3bbbd58940
[58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: b429047afaa8
[58691.155266] R10: 001ba090 R11: 0003 R12: 7952
[58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
[58691.161160] FS:  () GS:9c3bbbd4() 
knlGS:
[58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
[58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 00370ee0
[58691.169714] DR0:  DR1:  DR2: 
[58691.173102] DR3:  DR6: 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-11 Thread Jaegeuk Kim
On 01/12, Chao Yu wrote:
> On 2021/1/11 19:45, Chao Yu wrote:
> > On 2021/1/11 18:31, Chao Yu wrote:
> > > On 2021/1/11 17:48, Jaegeuk Kim wrote:
> > > > Hi Chao,
> > > > 
> > > > After quick test of fsstress w/ fault injection, it gave wrong block 
> > > > address
> > > > errors. Could you please run the test a bit?
> > > 
> > > Jaegeuk,
> > > 
> > > Oh, I've covered with fstest cases and there is no such error message, 
> > > let me
> > > try fault injection + SPO case soon.
> > 
> > Till now, I haven't see any problem... will let the test run for longer 
> > time in
> > this night.
> > 
> > Could you share me detailed error message you encounter?
> 
> Still, I don't see wrong block address error...
> 
> Did the error occur from below path:
> 
> - f2fs_end_read_compressed_page
>  - f2fs_cache_compressed_page
>   - f2fs_is_valid_blkaddr

[58690.176668] general protection fault, probably for non-canonical address 
0x6b6b6b6b6b6b6b73:  [#1] SMP PTI
[58690.180563] CPU: 0 PID: 29371 Comm: fsstress Tainted: G   O  
5.11.0-rc3-custom #1
[58690.186466] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58690.189352] RIP: 0010:f2fs_read_multi_pages+0x413/0xa70 [f2fs]
[58690.193366] Code: ad 54 ff ff ff 4c 8b ad 68 ff ff ff 25 00 00 08 00 89 85 
78 ff ff ff 49 8d 47 6c 48 89 85 70 ff ff ff 48 63 45 a0 49 8b 57 30 <4c> 8b 34 
c2 8b 45 c4 8d 50 01 48 8b 45 b8 48 2b 05 98 56 40 c8 48
[58690.212479] RSP: 0018:b429022dfa60 EFLAGS: 00010206
[58690.218410] RAX: 0001 RBX: 78af RCX: 0020
[58690.222473] RDX: 6b6b6b6b6b6b6b6b RSI: c0a6872f RDI: 0246
[58690.227349] RBP: b429022dfb10 R08:  R09: 
[58690.234425] R10: 9c3af1f78200 R11: 0001 R12: 
[58690.238503] R13: 9c3b84041000 R14: f5cc8166f5c0 R15: 9c3af1f78200
[58690.242455] FS:  7f0fee9d4b80() GS:9c3bbbc0() 
knlGS:
[58690.246401] CS:  0010 DS:  ES:  CR0: 80050033
[58690.250471] CR2: 563b839c1000 CR3: 2cb0e004 CR4: 00370ef0
[58690.250471] DR0:  DR1:  DR2: 
[58690.258758] DR3:  DR6: fffe0ff0 DR7: 0400
[58690.262464] Call Trace:
[58690.262464]  prepare_compress_overwrite+0x380/0x510 [f2fs]
[58690.266489]  ? xas_load+0x9/0x80
[58690.270452]  f2fs_prepare_compress_overwrite+0x5f/0x80 [f2fs]
[58690.274466]  f2fs_write_begin+0x81e/0x1120 [f2fs]
[58690.277213]  generic_perform_write+0xc2/0x1c0
[58690.278698]  __generic_file_write_iter+0x167/0x1d0
[58690.286472]  f2fs_file_write_iter+0x39e/0x590 [f2fs]
[58690.290398]  new_sync_write+0x117/0x1b0
[58690.290461]  vfs_write+0x185/0x250
[58690.295197]  ksys_write+0x67/0xe0
[58690.298173]  __x64_sys_write+0x1a/0x20
[58690.298437]  do_syscall_64+0x38/0x90
[58690.298437]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

[58690.961685] F2FS-fs (vdb) : inject page get in f2fs_pagecache_get_page of 
f2fs_quota_write+0x150/0x1f0 [f2fs]
[58691.071481] F2FS-fs (vdb): Inconsistent error blkaddr:31058, sit bitmap:0
[58691.077338] [ cut here ]
[58691.081461] WARNING: CPU: 5 PID: 8308 at fs/f2fs/checkpoint.c:151 
f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.086734] Modules linked in: f2fs(O) quota_v2 quota_tree dm_multipath 
scsi_dh_rdac scsi_dh_emc scsi_dh_alua ppdev intel_rapl_msr intel_rapl_common 
sb_edac kvm_intel kvm irqbypass joydev parport_pc parport input_leds serio_raw 
mac_hid qemu_fw_cfg sch_fq_codel ip_tables x_tables autofs4 btrfs 
blake2b_generic raid10 raid456 async_raid6_recov async_memcpy asy
[58691.120632] CPU: 5 PID: 8308 Comm: kworker/u17:5 Tainted: G  DO  
5.11.0-rc3-custom #1
[58691.125438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.14.0-1 04/01/2014
[58691.129625] Workqueue: f2fs_post_read_wq f2fs_post_read_work [f2fs]
[58691.133142] RIP: 0010:f2fs_is_valid_blkaddr+0x1e9/0x280 [f2fs]
[58691.136221] Code: 3c 07 b8 01 00 00 00 d3 e0 21 f8 75 57 83 fa 07 75 52 89 
f2 31 c9 48 c7 c6 20 6a a7 c0 48 89 df e8 bc d6 03 00 f0 80 4b 48 04 <0f> 0b 31 
c0 e9 5e fe ff ff 48 8b 57 10 8b 42 30 d3 e0 03 42 48 39
[58691.143142] RSP: 0018:b429047afd40 EFLAGS: 00010206
[58691.145639] RAX:  RBX: 9c3b84041000 RCX: 
[58691.148899] RDX:  RSI: 9c3bbbd58940 RDI: 9c3bbbd58940
[58691.152130] RBP: b429047afd48 R08: 9c3bbbd58940 R09: b429047afaa8
[58691.155266] R10: 001ba090 R11: 0003 R12: 7952
[58691.158304] R13: f5cc81266ac0 R14: 00db R15: 
[58691.161160] FS:  () GS:9c3bbbd4() 
knlGS:
[58691.164286] CS:  0010 DS:  ES:  CR0: 80050033
[58691.166869] CR2: 7f0fee9d3000 CR3: 5ee76001 CR4: 00370ee0
[58691.169714] DR0:  DR1: 

Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-11 Thread Chao Yu

On 2021/1/11 19:45, Chao Yu wrote:

On 2021/1/11 18:31, Chao Yu wrote:

On 2021/1/11 17:48, Jaegeuk Kim wrote:

Hi Chao,

After quick test of fsstress w/ fault injection, it gave wrong block address
errors. Could you please run the test a bit?


Jaegeuk,

Oh, I've covered with fstest cases and there is no such error message, let me
try fault injection + SPO case soon.


Till now, I haven't see any problem... will let the test run for longer time in
this night.

Could you share me detailed error message you encounter?


Still, I don't see wrong block address error...

Did the error occur from below path:

- f2fs_end_read_compressed_page
 - f2fs_cache_compressed_page
  - f2fs_is_valid_blkaddr



Thanks,



Thanks,



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




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



Re: [f2fs-dev] [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-11 Thread Chao Yu

On 2021/1/11 18:31, Chao Yu wrote:

On 2021/1/11 17:48, Jaegeuk Kim wrote:

Hi Chao,

After quick test of fsstress w/ fault injection, it gave wrong block address
errors. Could you please run the test a bit?


Jaegeuk,

Oh, I've covered with fstest cases and there is no such error message, let me
try fault injection + SPO case soon.


Till now, I haven't see any problem... will let the test run for longer time in
this night.

Could you share me detailed error message you encounter?

Thanks,



Thanks,



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



Re: [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-11 Thread Chao Yu

On 2021/1/11 17:48, Jaegeuk Kim wrote:

Hi Chao,

After quick test of fsstress w/ fault injection, it gave wrong block address
errors. Could you please run the test a bit?


Jaegeuk,

Oh, I've covered with fstest cases and there is no such error message, let me
try fault injection + SPO case soon.

Thanks,



Re: [PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-11 Thread Jaegeuk Kim
Hi Chao,

After quick test of fsstress w/ fault injection, it gave wrong block address
errors. Could you please run the test a bit?

Thanks,

On 01/07, Chao Yu wrote:
> Support to use address space of inner inode to cache compressed block,
> in order to improve cache hit ratio of random read.
> 
> Signed-off-by: Chao Yu 
> ---
> v3:
> - rebase to last dev branch.
> - add blkaddr sanity check in f2fs_cache_compressed_page()
>  Documentation/filesystems/f2fs.rst |   3 +
>  fs/f2fs/compress.c | 171 -
>  fs/f2fs/data.c |  19 +++-
>  fs/f2fs/debug.c|  13 +++
>  fs/f2fs/f2fs.h |  39 ++-
>  fs/f2fs/gc.c   |   1 +
>  fs/f2fs/inode.c|  21 +++-
>  fs/f2fs/segment.c  |   6 +-
>  fs/f2fs/super.c|  19 +++-
>  include/linux/f2fs_fs.h|   1 +
>  10 files changed, 282 insertions(+), 11 deletions(-)
> 
> diff --git a/Documentation/filesystems/f2fs.rst 
> b/Documentation/filesystems/f2fs.rst
> index 5eff4009e77e..cd1e5b826ba3 100644
> --- a/Documentation/filesystems/f2fs.rst
> +++ b/Documentation/filesystems/f2fs.rst
> @@ -273,6 +273,9 @@ compress_mode=%s   Control file compression mode. This 
> supports "fs" and "user"
>choosing the target file and the timing. The user can 
> do manual
>compression/decompression on the compression enabled 
> files using
>ioctls.
> +compress_cacheSupport to use address space of a filesystem 
> managed inode to
> +  cache compressed block, in order to improve cache hit 
> ratio of
> +  random read.
>  inlinecrypt   When possible, encrypt/decrypt the contents of 
> encrypted
>files using the blk-crypto framework rather than
>filesystem-layer encryption. This allows the use of
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index 1696f9183ff5..cb16b0437bd4 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -12,9 +12,11 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "f2fs.h"
>  #include "node.h"
> +#include "segment.h"
>  #include 
>  
>  static struct kmem_cache *cic_entry_slab;
> @@ -756,7 +758,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
>   return ret;
>  }
>  
> -static void f2fs_decompress_cluster(struct decompress_io_ctx *dic)
> +void f2fs_decompress_cluster(struct decompress_io_ctx *dic)
>  {
>   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
>   struct f2fs_inode_info *fi = F2FS_I(dic->inode);
> @@ -855,7 +857,8 @@ static void f2fs_decompress_cluster(struct 
> decompress_io_ctx *dic)
>   * page being waited on in the cluster, and if so, it decompresses the 
> cluster
>   * (or in the case of a failure, cleans up without actually decompressing).
>   */
> -void f2fs_end_read_compressed_page(struct page *page, bool failed)
> +void f2fs_end_read_compressed_page(struct page *page, bool failed,
> + block_t blkaddr)
>  {
>   struct decompress_io_ctx *dic =
>   (struct decompress_io_ctx *)page_private(page);
> @@ -865,6 +868,9 @@ void f2fs_end_read_compressed_page(struct page *page, 
> bool failed)
>  
>   if (failed)
>   WRITE_ONCE(dic->failed, true);
> + else if (blkaddr)
> + f2fs_cache_compressed_page(sbi, page,
> + dic->inode->i_ino, blkaddr);
>  
>   if (atomic_dec_and_test(>remaining_pages))
>   f2fs_decompress_cluster(dic);
> @@ -1702,6 +1708,167 @@ void f2fs_put_page_dic(struct page *page)
>   f2fs_put_dic(dic);
>  }
>  
> +const struct address_space_operations f2fs_compress_aops = {
> + .releasepage = f2fs_release_page,
> + .invalidatepage = f2fs_invalidate_page,
> +};
> +
> +struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi)
> +{
> + return sbi->compress_inode->i_mapping;
> +}
> +
> +void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr)
> +{
> + if (!sbi->compress_inode)
> + return;
> + invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr);
> +}
> +
> +void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
> + nid_t ino, block_t blkaddr)
> +{
> + struct page *cpage;
> + int ret;
> + struct sysinfo si;
> + unsigned long free_ram, avail_ram;
> +
> + if (!test_opt(sbi, COMPRESS_CACHE))
> + return;
> +
> + if (!f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE))
> + return;
> +
> + si_meminfo();
> + free_ram = si.freeram;
> + avail_ram = si.totalram - si.totalhigh;
> +
> + /* free memory is lower than watermark, deny caching compress page */
> + if (free_ram <= 

[PATCH v3 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-07 Thread Chao Yu
Support to use address space of inner inode to cache compressed block,
in order to improve cache hit ratio of random read.

Signed-off-by: Chao Yu 
---
v3:
- rebase to last dev branch.
- add blkaddr sanity check in f2fs_cache_compressed_page()
 Documentation/filesystems/f2fs.rst |   3 +
 fs/f2fs/compress.c | 171 -
 fs/f2fs/data.c |  19 +++-
 fs/f2fs/debug.c|  13 +++
 fs/f2fs/f2fs.h |  39 ++-
 fs/f2fs/gc.c   |   1 +
 fs/f2fs/inode.c|  21 +++-
 fs/f2fs/segment.c  |   6 +-
 fs/f2fs/super.c|  19 +++-
 include/linux/f2fs_fs.h|   1 +
 10 files changed, 282 insertions(+), 11 deletions(-)

diff --git a/Documentation/filesystems/f2fs.rst 
b/Documentation/filesystems/f2fs.rst
index 5eff4009e77e..cd1e5b826ba3 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -273,6 +273,9 @@ compress_mode=%s Control file compression mode. This 
supports "fs" and "user"
 choosing the target file and the timing. The user can 
do manual
 compression/decompression on the compression enabled 
files using
 ioctls.
+compress_cache  Support to use address space of a filesystem managed 
inode to
+cache compressed block, in order to improve cache hit 
ratio of
+random read.
 inlinecrypt When possible, encrypt/decrypt the contents of 
encrypted
 files using the blk-crypto framework rather than
 filesystem-layer encryption. This allows the use of
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 1696f9183ff5..cb16b0437bd4 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -12,9 +12,11 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "f2fs.h"
 #include "node.h"
+#include "segment.h"
 #include 
 
 static struct kmem_cache *cic_entry_slab;
@@ -756,7 +758,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
return ret;
 }
 
-static void f2fs_decompress_cluster(struct decompress_io_ctx *dic)
+void f2fs_decompress_cluster(struct decompress_io_ctx *dic)
 {
struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
struct f2fs_inode_info *fi = F2FS_I(dic->inode);
@@ -855,7 +857,8 @@ static void f2fs_decompress_cluster(struct 
decompress_io_ctx *dic)
  * page being waited on in the cluster, and if so, it decompresses the cluster
  * (or in the case of a failure, cleans up without actually decompressing).
  */
-void f2fs_end_read_compressed_page(struct page *page, bool failed)
+void f2fs_end_read_compressed_page(struct page *page, bool failed,
+   block_t blkaddr)
 {
struct decompress_io_ctx *dic =
(struct decompress_io_ctx *)page_private(page);
@@ -865,6 +868,9 @@ void f2fs_end_read_compressed_page(struct page *page, bool 
failed)
 
if (failed)
WRITE_ONCE(dic->failed, true);
+   else if (blkaddr)
+   f2fs_cache_compressed_page(sbi, page,
+   dic->inode->i_ino, blkaddr);
 
if (atomic_dec_and_test(>remaining_pages))
f2fs_decompress_cluster(dic);
@@ -1702,6 +1708,167 @@ void f2fs_put_page_dic(struct page *page)
f2fs_put_dic(dic);
 }
 
+const struct address_space_operations f2fs_compress_aops = {
+   .releasepage = f2fs_release_page,
+   .invalidatepage = f2fs_invalidate_page,
+};
+
+struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi)
+{
+   return sbi->compress_inode->i_mapping;
+}
+
+void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr)
+{
+   if (!sbi->compress_inode)
+   return;
+   invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr);
+}
+
+void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
+   nid_t ino, block_t blkaddr)
+{
+   struct page *cpage;
+   int ret;
+   struct sysinfo si;
+   unsigned long free_ram, avail_ram;
+
+   if (!test_opt(sbi, COMPRESS_CACHE))
+   return;
+
+   if (!f2fs_is_valid_blkaddr(sbi, blkaddr, DATA_GENERIC_ENHANCE))
+   return;
+
+   si_meminfo();
+   free_ram = si.freeram;
+   avail_ram = si.totalram - si.totalhigh;
+
+   /* free memory is lower than watermark, deny caching compress page */
+   if (free_ram <= sbi->compress_watermark / 100 * avail_ram)
+   return;
+
+   /* cached page count exceed threshold, deny caching compress page */
+   if (COMPRESS_MAPPING(sbi)->nrpages >=
+   free_ram / 100 * sbi->compress_percent)
+   return;
+
+   cpage = find_get_page(COMPRESS_MAPPING(sbi), blkaddr);
+