Re: [f2fs-dev] [syzbot] INFO: trying to register non-static key in f2fs_handle_error

2022-11-11 Thread Eric Biggers
On Sat, Nov 12, 2022 at 12:15:08AM +, 'Nick Terrell' via syzkaller-bugs 
wrote:
> 
> Not quite sure why I am CC'd here, I don't see anything related to zstd or 
> compression in this stack.
> Just want to check that it is likely unrelated, and that I'm not missing 
> something.
> 
> Best,
> Nick Terrell

It's because:

$ ./scripts/get_maintainer.pl fs/f2fs/super.c
Jaegeuk Kim  (maintainer:F2FS FILE SYSTEM)
Chao Yu  (maintainer:F2FS FILE SYSTEM)
Nick Terrell  (maintainer:ZSTD)
linux-f2fs-devel@lists.sourceforge.net (open list:F2FS FILE SYSTEM)
linux-ker...@vger.kernel.org (open list)

Do *not* use content regexes (K: zstd) in MAINTAINERS unless you are absolutely
sure you want to be notified about every file that contains your regex.

If you do want to use a content regex anyway, you might want to look into
changing get_maintainer.pl to make them only apply to patches that contain the
regex, as I think that might be what people are expecting it does.

- Eric



___
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 1/2] f2fs: fix to enable compress for newly created file if extension matches

2022-11-11 Thread Jaegeuk Kim
Does thes make sense?

https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test=608460dfae20b9d23aa222f7448710a086778222
https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test=962379487b5cb9f3b85ea367b130c2c6ca584edf

Second one is needed to address build error.

On 11/11, Sheng Yong wrote:
> If compress_extension is set, and a newly created file matches the
> extension, the file could be marked as compression file. However,
> if inline_data is also enabled, there is no chance to check its
> extension since f2fs_should_compress() always returns false.
> 
> This patch moves set_compress_inode(), which do extension check, in
> f2fs_should_compress() to check extensions before setting inline
> data flag.
> 
> Fixes: 7165841d578e ("f2fs: fix to check inline_data during compressed inode 
> conversion")
> Signed-off-by: Sheng Yong 
> ---
>  fs/f2fs/namei.c | 27 +--
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> ---
> v1->v2: add filename parameter for f2fs_new_inode, and move
> set_compress_inode into f2fs_new_inode
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index e104409c3a0e5..36e251f438568 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -22,8 +22,12 @@
>  #include "acl.h"
>  #include 
>  
> +static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
> + const unsigned char *name);
> +
>  static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
> - struct inode *dir, umode_t mode)
> + struct inode *dir, umode_t mode,
> + const char *name)
>  {
>   struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
>   nid_t ino;
> @@ -119,6 +123,8 @@ static struct inode *f2fs_new_inode(struct user_namespace 
> *mnt_userns,
>   if ((F2FS_I(dir)->i_flags & F2FS_COMPR_FL) &&
>   f2fs_may_compress(inode))
>   set_compress_context(inode);
> + if (name)
> + set_compress_inode(sbi, inode, name);
>   }
>  
>   /* Should enable inline_data after compression set */
> @@ -293,8 +299,7 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, 
> struct inode *inode,
>   unsigned char noext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt;
>   int i, cold_count, hot_count;
>  
> - if (!f2fs_sb_has_compression(sbi) ||
> - F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
> + if (F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
>   !f2fs_may_compress(inode) ||
>   (!ext_cnt && !noext_cnt))
>   return;
> @@ -326,10 +331,6 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, 
> struct inode *inode,
>   for (i = 0; i < ext_cnt; i++) {
>   if (!is_extension_exist(name, ext[i], false))
>   continue;
> -
> - /* Do not use inline_data with compression */
> - stat_dec_inline_inode(inode);
> - clear_inode_flag(inode, FI_INLINE_DATA);
>   set_compress_context(inode);
>   return;
>   }
> @@ -352,15 +353,13 @@ static int f2fs_create(struct user_namespace 
> *mnt_userns, struct inode *dir,
>   if (err)
>   return err;
>  
> - inode = f2fs_new_inode(mnt_userns, dir, mode);
> + inode = f2fs_new_inode(mnt_userns, dir, mode, dentry->d_name.name);
>   if (IS_ERR(inode))
>   return PTR_ERR(inode);
>  
>   if (!test_opt(sbi, DISABLE_EXT_IDENTIFY))
>   set_file_temperature(sbi, inode, dentry->d_name.name);
>  
> - set_compress_inode(sbi, inode, dentry->d_name.name);
> -
>   inode->i_op = _file_inode_operations;
>   inode->i_fop = _file_operations;
>   inode->i_mapping->a_ops = _dblock_aops;
> @@ -689,7 +688,7 @@ static int f2fs_symlink(struct user_namespace 
> *mnt_userns, struct inode *dir,
>   if (err)
>   return err;
>  
> - inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO);
> + inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO, NULL);
>   if (IS_ERR(inode))
>   return PTR_ERR(inode);
>  
> @@ -760,7 +759,7 @@ static int f2fs_mkdir(struct user_namespace *mnt_userns, 
> struct inode *dir,
>   if (err)
>   return err;
>  
> - inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode);
> + inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode, NULL);
>   if (IS_ERR(inode))
>   return PTR_ERR(inode);
>  
> @@ -817,7 +816,7 @@ static int f2fs_mknod(struct user_namespace *mnt_userns, 
> struct inode *dir,
>   if (err)
>   return err;
>  
> - inode = f2fs_new_inode(mnt_userns, dir, mode);
> + inode = f2fs_new_inode(mnt_userns, dir, mode, NULL);
>   if 

Re: [f2fs-dev] [syzbot] INFO: trying to register non-static key in f2fs_handle_error

2022-11-11 Thread Nick Terrell via Linux-f2fs-devel



> On Nov 7, 2022, at 4:15 PM, syzbot 
>  wrote:
> 
> !---|
>  This Message Is From an External Sender
> 
> |---!
> 
> syzbot has found a reproducer for the following issue on:
> 
> HEAD commit:f0c4d9fc9cc9 Linux 6.1-rc4
> git tree:   git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git 
> for-kernelci
> console output: https://syzkaller.appspot.com/x/log.txt?x=15e494fe88  
> kernel config:  https://syzkaller.appspot.com/x/.config?x=ff27f0c8b406726e  
> dashboard link: https://syzkaller.appspot.com/bug?extid=40642be9b7e0bb28e0df  
> compiler:   Debian clang version 
> 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU 
> Binutils for Debian) 2.35.2
> userspace arch: arm64
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=1082227188  
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14f4cd5188  
> 
> Downloadable assets:
> disk image: 
> https://storage.googleapis.com/syzbot-assets/92c7e839ac32/disk-f0c4d9fc.raw.xz
>   
> vmlinux: 
> https://storage.googleapis.com/syzbot-assets/b7bedbc08fb4/vmlinux-f0c4d9fc.xz 
>  
> kernel image: 
> https://storage.googleapis.com/syzbot-assets/3fe25e2dfdb7/Image-f0c4d9fc.gz.xz
>   
> mounted in repro #1: 
> https://storage.googleapis.com/syzbot-assets/1f9d740f89a9/mount_1.gz  
> mounted in repro #2: 
> https://storage.googleapis.com/syzbot-assets/6c6db4f39192/mount_2.gz  
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+40642be9b7e0bb28e...@syzkaller.appspotmail.com
> 
> F2FS-fs (loop0): Invalid log_blocksize (16), supports only 12
> F2FS-fs (loop0): Can't find valid F2FS filesystem in 1th superblock
> F2FS-fs (loop0): inaccessible inode: 2, run fsck to repair
> INFO: trying to register non-static key.
> The code is fine but needs lockdep annotation, or maybe
> you didn't initialize this object before use?
> turning off the locking correctness validator.
> CPU: 1 PID: 3141 Comm: syz-executor147 Not tainted 
> 6.1.0-rc4-syzkaller-31833-gf0c4d9fc9cc9 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS 
> Google 09/30/2022
> Call trace:
> dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
> show_stack+0x2c/0x54 arch/arm64/kernel/stacktrace.c:163
> __dump_stack lib/dump_stack.c:88 [inline]
> dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
> dump_stack+0x1c/0x58 lib/dump_stack.c:113
> assign_lock_key+0x134/0x140 kernel/locking/lockdep.c:981
> register_lock_class+0xc4/0x2f8 kernel/locking/lockdep.c:1294
> __lock_acquire+0xa8/0x3084 kernel/locking/lockdep.c:4934
> lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
> __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
> _raw_spin_lock+0x54/0x6c kernel/locking/spinlock.c:154
> spin_lock include/linux/spinlock.h:350 [inline]
> f2fs_save_errors fs/f2fs/super.c:3868 [inline]
> f2fs_handle_error+0x38/0x17c fs/f2fs/super.c:3896
> f2fs_iget+0x138/0x538 fs/f2fs/inode.c:516
> f2fs_fill_super+0x10fc/0x1e90 fs/f2fs/super.c:4222
> mount_bdev+0x1b8/0x210 fs/super.c:1401
> f2fs_mount+0x44/0x58 fs/f2fs/super.c:4580
> legacy_get_tree+0x30/0x74 fs/fs_context.c:610
> vfs_get_tree+0x40/0x140 fs/super.c:1531
> do_new_mount+0x1dc/0x4e4 fs/namespace.c:3040
> path_mount+0x358/0x890 fs/namespace.c:3370
> do_mount fs/namespace.c:3383 [inline]
> __do_sys_mount fs/namespace.c:3591 [inline]
> __se_sys_mount fs/namespace.c:3568 [inline]
> __arm64_sys_mount+0x2c4/0x3c4 fs/namespace.c:3568
> __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
> invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
> el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
> do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
> el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
> el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
> el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581
> F2FS-fs (loop0): Failed to read F2FS meta data inode
> loop0: detected capacity change from 0 to 8192
> REISERFS warning:  read_super_block: reiserfs filesystem is deprecated and 
> scheduled to be removed from the kernel in 2025
> REISERFS (device loop0): found reiserfs format "3.6" with non-standard journal
> REISERFS (device loop0): using ordered data mode
> reiserfs: using flush barriers
> REISERFS (device loop0): journal params: device loop0, size 512, journal 
> first block 18, max trans len 256, max batch 225, max commit age 30, max 
> trans age 30
> REISERFS (device loop0): checking transaction log (loop0)
> REISERFS (device loop0): Using rupasov hash to sort names
> REISERFS warning (device loop0): jdm-20006 create_privroot: xattrs/ACLs 
> enabled and couldn't find/create .reiserfs_priv. Failing mount.

Not quite sure why I am CC'd here, I don't see anything related to zstd or 
compression in this stack.
Just want to check that it is likely 

[f2fs-dev] [Bug 216050] f2fs_gc occupies 100% cpu

2022-11-11 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216050

--- Comment #85 from Guido (guido.iod...@gmail.com) ---
I modified the script to run it on the partition on my choice. No problem with
the home and other partitions. It looks like something in root partition. May
be it is related to the bug?

-- 
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


[f2fs-dev] [Bug 216050] f2fs_gc occupies 100% cpu

2022-11-11 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216050

--- Comment #84 from Guido (guido.iod...@gmail.com) ---
this is the output

Performing GC on /sys/fs/f2fs/nvme0n1p3/
2589
2589
2503
2503
2503
2503
...

and a lot of 2503

-- 
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


[f2fs-dev] [Bug 216050] f2fs_gc occupies 100% cpu

2022-11-11 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216050

--- Comment #83 from Guido (guido.iod...@gmail.com) ---
I tried this script to trigger the GC:
https://github.com/LLJY/f2fs-gc/blob/master/f2fs-gc.sh

It's been running for 10 minutes now, but it's stock to 2503 dirty segments on
the root partition.

But no sign of 100% cpu, everything looks normal.

-- 
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


[f2fs-dev] [Bug 216050] f2fs_gc occupies 100% cpu

2022-11-11 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216050

--- Comment #82 from Guido (guido.iod...@gmail.com) ---
(In reply to Jaegeuk Kim from comment #81)
> I think 1313 would be enough to avoid this issue first.
> 3568 case is after submit IO which could have a chance to get another states.

Thank you, I'm testing 6.0.8 patched.
I will not turn off the PC for several days, so let's see what happens.

-- 
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


[f2fs-dev] [Bug 216050] f2fs_gc occupies 100% cpu

2022-11-11 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216050

--- Comment #81 from Jaegeuk Kim (jaeg...@kernel.org) ---
I think 1313 would be enough to avoid this issue first.
3568 case is after submit IO which could have a chance to get another states.

-- 
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


[f2fs-dev] [PATCH v7] f2fs: introduce F2FS_IOC_START_ATOMIC_REPLACE

2022-11-11 Thread Daeho Jeong
From: Daeho Jeong 

introduce a new ioctl to replace the whole content of a file atomically,
which means it induces truncate and content update at the same time.
We can start it with F2FS_IOC_START_ATOMIC_REPLACE and complete it with
F2FS_IOC_COMMIT_ATOMIC_WRITE. Or abort it with
F2FS_IOC_ABORT_ATOMIC_WRITE.

Signed-off-by: Daeho Jeong 
---
v7: changed where to clear FI_ATOMIC_REPLACE
fixed tentative race condition in f2fs_ioc_start_atomic_write()
v3: move i_size change after setting atomic write flag
v2: add undefined ioctl number reported by 
---
 fs/f2fs/data.c|  3 +++
 fs/f2fs/f2fs.h|  1 +
 fs/f2fs/file.c| 21 +++--
 fs/f2fs/segment.c | 13 -
 include/uapi/linux/f2fs.h |  1 +
 5 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 5f895ddcd64a..bce4dcc3ad78 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3457,6 +3457,9 @@ static int prepare_atomic_write_begin(struct f2fs_sb_info 
*sbi,
else if (*blk_addr != NULL_ADDR)
return 0;
 
+   if (is_inode_flag_set(inode, FI_ATOMIC_REPLACE))
+   goto reserve_block;
+
/* Look for the block in the original inode */
err = __find_data_block(inode, index, _blk_addr);
if (err)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e29f9adf60ca..d513ecd17550 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -765,6 +765,7 @@ enum {
FI_ALIGNED_WRITE,   /* enable aligned write */
FI_COW_FILE,/* indicate COW file */
FI_ATOMIC_COMMITTED,/* indicate atomic commit completed except disk 
sync */
+   FI_ATOMIC_REPLACE,  /* indicate atomic replace */
FI_MAX, /* max flag, never be used */
 };
 
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 7ce629c95f4a..f9a04f6d76cb 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1984,7 +1984,7 @@ static int f2fs_ioc_getversion(struct file *filp, 
unsigned long arg)
return put_user(inode->i_generation, (int __user *)arg);
 }
 
-static int f2fs_ioc_start_atomic_write(struct file *filp)
+static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
 {
struct inode *inode = file_inode(filp);
struct user_namespace *mnt_userns = file_mnt_user_ns(filp);
@@ -2053,15 +2053,22 @@ static int f2fs_ioc_start_atomic_write(struct file 
*filp)
 
f2fs_write_inode(inode, NULL);
 
-   isize = i_size_read(inode);
-   fi->original_i_size = isize;
-   f2fs_i_size_write(fi->cow_inode, isize);
-
stat_inc_atomic_inode(inode);
 
set_inode_flag(inode, FI_ATOMIC_FILE);
set_inode_flag(fi->cow_inode, FI_COW_FILE);
clear_inode_flag(fi->cow_inode, FI_INLINE_DATA);
+
+   isize = i_size_read(inode);
+   fi->original_i_size = isize;
+   if (truncate) {
+   set_inode_flag(inode, FI_ATOMIC_REPLACE);
+   truncate_inode_pages_final(inode->i_mapping);
+   f2fs_i_size_write(inode, 0);
+   isize = 0;
+   }
+   f2fs_i_size_write(fi->cow_inode, isize);
+
f2fs_up_write(>i_gc_rwsem[WRITE]);
 
f2fs_update_time(sbi, REQ_TIME);
@@ -4089,7 +4096,9 @@ static long __f2fs_ioctl(struct file *filp, unsigned int 
cmd, unsigned long arg)
case FS_IOC_GETVERSION:
return f2fs_ioc_getversion(filp, arg);
case F2FS_IOC_START_ATOMIC_WRITE:
-   return f2fs_ioc_start_atomic_write(filp);
+   return f2fs_ioc_start_atomic_write(filp, false);
+   case F2FS_IOC_START_ATOMIC_REPLACE:
+   return f2fs_ioc_start_atomic_write(filp, true);
case F2FS_IOC_COMMIT_ATOMIC_WRITE:
return f2fs_ioc_commit_atomic_write(filp);
case F2FS_IOC_ABORT_ATOMIC_WRITE:
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 9cbf88092c78..f2930fffbc7d 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -197,6 +197,7 @@ void f2fs_abort_atomic_write(struct inode *inode, bool 
clean)
fi->cow_inode = NULL;
release_atomic_write_cnt(inode);
clear_inode_flag(inode, FI_ATOMIC_COMMITTED);
+   clear_inode_flag(inode, FI_ATOMIC_REPLACE);
clear_inode_flag(inode, FI_ATOMIC_FILE);
stat_dec_atomic_inode(inode);
 
@@ -261,14 +262,24 @@ static void __complete_revoke_list(struct inode *inode, 
struct list_head *head,
bool revoke)
 {
struct revoke_entry *cur, *tmp;
+   pgoff_t start_index = 0;
+   bool truncate = is_inode_flag_set(inode, FI_ATOMIC_REPLACE);
 
list_for_each_entry_safe(cur, tmp, head, list) {
-   if (revoke)
+   if (revoke) {
__replace_atomic_write_block(inode, cur->index,
cur->old_addr, NULL, true);
+   } else if (truncate) {
+   f2fs_truncate_hole(inode, 

[f2fs-dev] [PATCH] f2fs: remove submit label in __submit_discard_cmd()

2022-11-11 Thread Yangtao Li via Linux-f2fs-devel
Complaint from Matthew Wilcox in another similar place:

"submit?  You don't submit anything at the 'submit' label.
it should be called 'skip' or something.  But I think this
is just badly written and you don't need a goto at all."

Let's remove submit label for readability.

Signed-off-by: Yangtao Li 
---
 fs/f2fs/segment.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 3654c30e0517..0a72e787c585 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1144,13 +1144,11 @@ static int __submit_discard_cmd(struct f2fs_sb_info 
*sbi,
if (time_to_inject(sbi, FAULT_DISCARD)) {
f2fs_show_injection_info(sbi, FAULT_DISCARD);
err = -EIO;
-   goto submit;
-   }
-   err = __blkdev_issue_discard(bdev,
+   } else
+   err = __blkdev_issue_discard(bdev,
SECTOR_FROM_BLOCK(start),
SECTOR_FROM_BLOCK(len),
GFP_NOFS, );
-submit:
if (err) {
spin_lock_irqsave(>lock, flags);
if (dc->state == D_PARTIAL)
-- 
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] [PATCH v3] f2fs: add proc entry to show discard_plist info

2022-11-11 Thread Yangtao Li via Linux-f2fs-devel
This patch adds a new proc entry to show discard_plist
information in more detail, which is very helpful to
know the discard pend list count clearly.

Such as:

Discard pending list(Show diacrd command count on each entry):
04943 138  66  29  21   
9   8  12
8   4   7   4   6   3   
2   0   1
16  1   2   2   0   0   
1   0   0
24  0   1   1   0   0   
1   1   0
32  0   1   0   0   0   
0   0   0
..

Signed-off-by: Yangtao Li 
---
 fs/f2fs/f2fs.h|  1 +
 fs/f2fs/segment.c | 22 --
 fs/f2fs/sysfs.c   | 29 +
 3 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 04ef4cce3d7f..a0226c970cbc 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -405,6 +405,7 @@ struct discard_cmd_control {
wait_queue_head_t discard_wait_queue;   /* waiting queue for wake-up */
unsigned int discard_wake;  /* to wake up discard thread */
struct mutex cmd_lock;
+   unsigned int nr_pending[MAX_PLIST_NUM]; /* # of pending discards */
unsigned int nr_discards;   /* # of discards in the list */
unsigned int max_discards;  /* max. discards to be issued */
unsigned int max_discard_request;   /* max. discard request per 
round */
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index aa4be7f25963..72e60d5ee70f 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -921,6 +921,7 @@ static struct discard_cmd *__create_discard_cmd(struct 
f2fs_sb_info *sbi,
dc->bio_ref = 0;
atomic_inc(>discard_cmd_cnt);
dcc->undiscard_blks += len;
+   dcc->nr_pending[plist_idx(len)]++;
 
return dc;
 }
@@ -1169,6 +1170,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
submit_bio(bio);
 
atomic_inc(>issued_discard);
+   dcc->nr_pending[plist_idx(len)]--;
 
f2fs_update_iostat(sbi, NULL, FS_DISCARD, 1);
 
@@ -1210,9 +1212,11 @@ static void __insert_discard_tree(struct f2fs_sb_info 
*sbi,
 }
 
 static void __relocate_discard_cmd(struct discard_cmd_control *dcc,
-   struct discard_cmd *dc)
+   struct discard_cmd *dc, 
unsigned int index)
 {
list_move_tail(>list, >pend_list[plist_idx(dc->len)]);
+   dcc->nr_pending[plist_idx(dc->len)]++;
+   dcc->nr_pending[index]--;
 }
 
 static void __punch_discard_cmd(struct f2fs_sb_info *sbi,
@@ -1230,9 +1234,10 @@ static void __punch_discard_cmd(struct f2fs_sb_info *sbi,
dcc->undiscard_blks -= di.len;
 
if (blkaddr > di.lstart) {
+   block_t old_len = dc->len;
dc->len = blkaddr - dc->lstart;
dcc->undiscard_blks += dc->len;
-   __relocate_discard_cmd(dcc, dc);
+   __relocate_discard_cmd(dcc, dc, plist_idx(old_len));
modified = true;
}
 
@@ -1243,11 +1248,12 @@ static void __punch_discard_cmd(struct f2fs_sb_info 
*sbi,
di.lstart + di.len - 1 - blkaddr,
NULL, NULL);
} else {
+   block_t old_len = dc->len;
dc->lstart++;
dc->len--;
dc->start++;
dcc->undiscard_blks += dc->len;
-   __relocate_discard_cmd(dcc, dc);
+   __relocate_discard_cmd(dcc, dc, plist_idx(old_len));
}
}
 }
@@ -1306,9 +1312,10 @@ static void __update_discard_tree_range(struct 
f2fs_sb_info *sbi,
prev_dc->bdev == bdev &&
__is_discard_back_mergeable(, _dc->di,
max_discard_blocks)) {
+   block_t old_len = prev_dc->di.len;
prev_dc->di.len += di.len;
dcc->undiscard_blks += di.len;
-   __relocate_discard_cmd(dcc, prev_dc);
+   __relocate_discard_cmd(dcc, prev_dc, 
plist_idx(old_len));
di = prev_dc->di;
tdc = prev_dc;
merged = true;
@@ -1318,13 +1325,16 @@ static void __update_discard_tree_range(struct 
f2fs_sb_info *sbi,
next_dc->bdev == bdev &&
__is_discard_front_mergeable(, _dc->di,
max_discard_blocks)) {
+   block_t old_len = 

[f2fs-dev] [Bug 216050] f2fs_gc occupies 100% cpu

2022-11-11 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=216050

--- Comment #80 from Guido (guido.iod...@gmail.com) ---
(In reply to Jaegeuk Kim from comment #79)

I tried to apply it to kernel 6.0.8 but failed. I found the code at row 1313 so
I can try to apply there. But there is another identical code at row 3568. Do
we need to patch also there?

-- 
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


[f2fs-dev] [PATCH v2 2/2] f2fs: move set_file_temperature into f2fs_new_inode

2022-11-11 Thread Sheng Yong via Linux-f2fs-devel
Since the file name has already passed to f2fs_new_inode(), let's
move set_file_temperature() into f2fs_new_inode().

Signed-off-by: Sheng Yong 
---
 fs/f2fs/namei.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 36e251f438568..04bc7ec5e29e9 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -131,6 +131,9 @@ static struct inode *f2fs_new_inode(struct user_namespace 
*mnt_userns,
if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode))
set_inode_flag(inode, FI_INLINE_DATA);
 
+   if (name && !test_opt(sbi, DISABLE_EXT_IDENTIFY))
+   set_file_temperature(sbi, inode, name);
+
stat_inc_inline_xattr(inode);
stat_inc_inline_inode(inode);
stat_inc_inline_dir(inode);
@@ -357,9 +360,6 @@ static int f2fs_create(struct user_namespace *mnt_userns, 
struct inode *dir,
if (IS_ERR(inode))
return PTR_ERR(inode);
 
-   if (!test_opt(sbi, DISABLE_EXT_IDENTIFY))
-   set_file_temperature(sbi, inode, dentry->d_name.name);
-
inode->i_op = _file_inode_operations;
inode->i_fop = _file_operations;
inode->i_mapping->a_ops = _dblock_aops;
-- 
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] [PATCH v2 1/2] f2fs: fix to enable compress for newly created file if extension matches

2022-11-11 Thread Sheng Yong via Linux-f2fs-devel
If compress_extension is set, and a newly created file matches the
extension, the file could be marked as compression file. However,
if inline_data is also enabled, there is no chance to check its
extension since f2fs_should_compress() always returns false.

This patch moves set_compress_inode(), which do extension check, in
f2fs_should_compress() to check extensions before setting inline
data flag.

Fixes: 7165841d578e ("f2fs: fix to check inline_data during compressed inode 
conversion")
Signed-off-by: Sheng Yong 
---
 fs/f2fs/namei.c | 27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

---
v1->v2: add filename parameter for f2fs_new_inode, and move
set_compress_inode into f2fs_new_inode

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index e104409c3a0e5..36e251f438568 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -22,8 +22,12 @@
 #include "acl.h"
 #include 
 
+static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
+   const unsigned char *name);
+
 static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
-   struct inode *dir, umode_t mode)
+   struct inode *dir, umode_t mode,
+   const char *name)
 {
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
nid_t ino;
@@ -119,6 +123,8 @@ static struct inode *f2fs_new_inode(struct user_namespace 
*mnt_userns,
if ((F2FS_I(dir)->i_flags & F2FS_COMPR_FL) &&
f2fs_may_compress(inode))
set_compress_context(inode);
+   if (name)
+   set_compress_inode(sbi, inode, name);
}
 
/* Should enable inline_data after compression set */
@@ -293,8 +299,7 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, 
struct inode *inode,
unsigned char noext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt;
int i, cold_count, hot_count;
 
-   if (!f2fs_sb_has_compression(sbi) ||
-   F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
+   if (F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
!f2fs_may_compress(inode) ||
(!ext_cnt && !noext_cnt))
return;
@@ -326,10 +331,6 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, 
struct inode *inode,
for (i = 0; i < ext_cnt; i++) {
if (!is_extension_exist(name, ext[i], false))
continue;
-
-   /* Do not use inline_data with compression */
-   stat_dec_inline_inode(inode);
-   clear_inode_flag(inode, FI_INLINE_DATA);
set_compress_context(inode);
return;
}
@@ -352,15 +353,13 @@ static int f2fs_create(struct user_namespace *mnt_userns, 
struct inode *dir,
if (err)
return err;
 
-   inode = f2fs_new_inode(mnt_userns, dir, mode);
+   inode = f2fs_new_inode(mnt_userns, dir, mode, dentry->d_name.name);
if (IS_ERR(inode))
return PTR_ERR(inode);
 
if (!test_opt(sbi, DISABLE_EXT_IDENTIFY))
set_file_temperature(sbi, inode, dentry->d_name.name);
 
-   set_compress_inode(sbi, inode, dentry->d_name.name);
-
inode->i_op = _file_inode_operations;
inode->i_fop = _file_operations;
inode->i_mapping->a_ops = _dblock_aops;
@@ -689,7 +688,7 @@ static int f2fs_symlink(struct user_namespace *mnt_userns, 
struct inode *dir,
if (err)
return err;
 
-   inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO);
+   inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO, NULL);
if (IS_ERR(inode))
return PTR_ERR(inode);
 
@@ -760,7 +759,7 @@ static int f2fs_mkdir(struct user_namespace *mnt_userns, 
struct inode *dir,
if (err)
return err;
 
-   inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode);
+   inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode, NULL);
if (IS_ERR(inode))
return PTR_ERR(inode);
 
@@ -817,7 +816,7 @@ static int f2fs_mknod(struct user_namespace *mnt_userns, 
struct inode *dir,
if (err)
return err;
 
-   inode = f2fs_new_inode(mnt_userns, dir, mode);
+   inode = f2fs_new_inode(mnt_userns, dir, mode, NULL);
if (IS_ERR(inode))
return PTR_ERR(inode);
 
@@ -856,7 +855,7 @@ static int __f2fs_tmpfile(struct user_namespace 
*mnt_userns, struct inode *dir,
if (err)
return err;
 
-   inode = f2fs_new_inode(mnt_userns, dir, mode);
+   inode = f2fs_new_inode(mnt_userns, dir, mode, NULL);
if (IS_ERR(inode))
return PTR_ERR(inode);
 
-- 
2.25.1



___
Linux-f2fs-devel mailing 

Re: [f2fs-dev] [PATCH v2 1/2] f2fs: fix to enable compress for newly created file if extension matches

2022-11-11 Thread Chao Yu

On 2022/11/11 18:08, Sheng Yong wrote:

If compress_extension is set, and a newly created file matches the
extension, the file could be marked as compression file. However,
if inline_data is also enabled, there is no chance to check its
extension since f2fs_should_compress() always returns false.

This patch moves set_compress_inode(), which do extension check, in
f2fs_should_compress() to check extensions before setting inline
data flag.

Fixes: 7165841d578e ("f2fs: fix to check inline_data during compressed inode 
conversion")
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 2/2] f2fs: move set_file_temperature into f2fs_new_inode

2022-11-11 Thread Chao Yu

On 2022/11/11 18:08, Sheng Yong wrote:

Since the file name has already passed to f2fs_new_inode(), let's
move set_file_temperature() into f2fs_new_inode().

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 atgc bug on issue in 32bits platform

2022-11-11 Thread Arnd Bergmann
On Fri, Nov 11, 2022, at 10:40, Zhiguo Niu wrote:
> Arnd Bergmann  于2022年11月10日周四 21:45写道:
>   I thinks the gcc complier build warning :
> 
> In file included from fs/f2fs/segment.c:24:
>>> fs/f2fs/gc.h:73:1: warning: alignment 1 of 'struct victim_entry' is 
>
>>> less than 8 [-Wpacked-not-aligned]
>
>   73 | } __packed;
>
>  | ^
>
>  ---
>
> It is because struct rb_node has the attribute 
> "__attribute__((aligned(sizeof(long)", it is 8 bytes in 64bits platform.
>
> struct rb_node {
> unsigned long  __rb_parent_color;
> struct rb_node *rb_right;
> struct rb_node *rb_left;
> } __attribute__((aligned(sizeof(long;
>
> so I just try to put __packed on union of struct victim_entry and i 
> also keep consistent with struct rb_entry.

No, that attribute has no effect on any architecture other
than m68k, which defaults to 16-bit alignment for 32-bit
members. I'm fairly sure the alignment attribute on
rb_node is entirely unrelated to the problems you are
seeing in f2fs that come from having a structure with
stricter (4 byte or 8 byte) alignment requirements embedded
in a structure with relaxed (single-byte) alignment:

> struct rb_entry {
> struct rb_node rb_node; /* rb node located in rb-tree */
> union {
> struct {
> unsigned int ofs; /* start offset of the entry */
> unsigned int len; /* length of the entry */
> };
> unsigned long long key; /* 64-bits key */
> } __packed;
> };

This tells the compiler that the anonymous union is 
entirely unconstrained, but the anonymous struct inside
it has the default alignment, which is the contradition
that gcc correctly warns about.

Since the only thing you need here is to lower the
alignment constraint from 8 bytes to 4 bytes, the easiest
way is to have the __packed annotation on the 'key'
member. This avoids all warnings, as long you do not
take the address of the 'key' member and pass it to
a function that expects an aligned 'u64' pointer.

 Arnd


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