[f2fs-dev] [PATCH v2 3/3] f2fs-tools: cache free segments count to improve perfmance

2023-09-28 Thread Wu Bo via Linux-f2fs-devel
'get_free_segments()' is implemented by traversing all segments to calculate the total free segments. It cosume much time. Every time when call 'find_next_free_block()' this calculation will do it again. So if we cache the free segments count, it will greatly improve performance of dfrag & resize

[f2fs-dev] [PATCH v2 2/3] f2fs-tools: skip not matched segment when finding free block

2023-09-28 Thread Wu Bo via Linux-f2fs-devel
If the segment type is not matched, goto next segment to save time. --- fsck/mount.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index e4372cf..098e73d 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -2852,8 +2852,10 @@ next_segment:

[f2fs-dev] [PATCH v2 0/3] f2fs-tools: cache free segments count to improve perfmance

2023-09-28 Thread Wu Bo via Linux-f2fs-devel
The performance flame graph of resize shows that 'get_free_segments()' consum most user space time: https://linkthinking.cn/images/resize_flame.jpg Every calling 'get_free_segments()', it will traverses all segments to calculate the free segments count. And this path is called a lot in resize & sl

[f2fs-dev] [PATCH v2 1/3] f2fs-tools: use 'IS_CUR_SEGNO()' to check if it is current segment

2023-09-28 Thread Wu Bo via Linux-f2fs-devel
Use IS_CUR_SEGNO() here can make code more concise and readable. --- fsck/mount.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index df0314d..e4372cf 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -2532,16 +2532,8 @@ void build_sit_area

[f2fs-dev] [PATCH 00/87] fs: new accessor methods for atime and mtime

2023-09-28 Thread Jeff Layton
While working on the multigrain timestamp changes, Linus suggested adding some similar wrappers for accessing the atime and mtime that we have for the ctime. With that, we could then move to using discrete integers instead of timespec64 in struct inode, and shrink it. Linus suggested using macros

[f2fs-dev] [PATCH 01/87] fs: new accessor methods for atime and mtime

2023-09-28 Thread Jeff Layton
Recently, we converted the ctime accesses in the kernel to use new accessor functions. Linus recently pointed out though that if we add accessors for the atime and mtime, then that would allow us to seamlessly change how these timestamps are stored in the inode. Add new accessor functions for the

[f2fs-dev] [PATCH 35/87] fs/f2fs: convert to new inode {a, m}time accessors

2023-09-28 Thread Jeff Layton
Signed-off-by: Jeff Layton --- fs/f2fs/dir.c | 6 +++--- fs/f2fs/f2fs.h | 10 ++ fs/f2fs/file.c | 14 +++--- fs/f2fs/inline.c | 2 +- fs/f2fs/inode.c| 20 ++-- fs/f2fs/namei.c| 4 ++-- fs/f2fs/recovery.c | 8 fs/f2fs/super.c|

[f2fs-dev] [PATCH 85/87] fs: rename i_atime and i_mtime fields to __i_atime and __i_mtime

2023-09-28 Thread Jeff Layton
Make it clear that these fields are private now, and that the accessors should be used instead. Signed-off-by: Jeff Layton --- include/linux/fs.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 12d247b82aa0..8316570

[f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Jeff Layton
This shaves 8 bytes off struct inode, according to pahole. Signed-off-by: Jeff Layton --- include/linux/fs.h | 32 +++- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 831657011036..de902ff2938b 100644 --- a

[f2fs-dev] [PATCH 87/87] fs: move i_blocks up a few places in struct inode

2023-09-28 Thread Jeff Layton
The recent change to use discrete integers instead of struct timespec64 in struct inode shaved 8 bytes off of it, but it also moves the i_lock into the previous cacheline, away from the fields that it protects. Move i_blocks up above the i_lock, which moves the new 4 byte hole to just after the ti

Re: [f2fs-dev] [PATCH 87/87] fs: move i_blocks up a few places in struct inode

2023-09-28 Thread Amir Goldstein
On Thu, Sep 28, 2023 at 2:06 PM Jeff Layton wrote: > > The recent change to use discrete integers instead of struct timespec64 > in struct inode shaved 8 bytes off of it, but it also moves the i_lock > into the previous cacheline, away from the fields that it protects. > > Move i_blocks up above t

Re: [f2fs-dev] [PATCH 87/87] fs: move i_blocks up a few places in struct inode

2023-09-28 Thread Jeff Layton
On Thu, 2023-09-28 at 14:35 +0300, Amir Goldstein wrote: > On Thu, Sep 28, 2023 at 2:06 PM Jeff Layton wrote: > > > > The recent change to use discrete integers instead of struct timespec64 > > in struct inode shaved 8 bytes off of it, but it also moves the i_lock > > into the previous cacheline,

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Arnd Bergmann
On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote: > This shaves 8 bytes off struct inode, according to pahole. > > Signed-off-by: Jeff Layton FWIW, this is similar to the approach that Deepa suggested back in 2016: https://lore.kernel.org/lkml/1452144972-15802-3-git-send-email-deepa.ker...@gmai

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Jeff Layton
On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote: > On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote: > > This shaves 8 bytes off struct inode, according to pahole. > > > > Signed-off-by: Jeff Layton > > FWIW, this is similar to the approach that Deepa suggested > back in 2016: > > https

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Jeff Layton
On Thu, 2023-09-28 at 07:05 -0400, Jeff Layton wrote: > This shaves 8 bytes off struct inode, according to pahole. > > Signed-off-by: Jeff Layton > --- > include/linux/fs.h | 32 +++- > 1 file changed, 23 insertions(+), 9 deletions(-) > > diff --git a/include/linux/f

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Darrick J. Wong
On Thu, Sep 28, 2023 at 01:06:03PM -0400, Jeff Layton wrote: > On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote: > > On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote: > > > This shaves 8 bytes off struct inode, according to pahole. > > > > > > Signed-off-by: Jeff Layton > > > > FWIW, this

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Jeff Layton
On Thu, 2023-09-28 at 10:19 -0700, Darrick J. Wong wrote: > On Thu, Sep 28, 2023 at 01:06:03PM -0400, Jeff Layton wrote: > > On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote: > > > On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote: > > > > This shaves 8 bytes off struct inode, according to pa

[f2fs-dev] [PATCH] f2fs-tools: do not support user-space cache

2023-09-28 Thread Daeho Jeong
From: Daeho Jeong We don't have lots of benefits from this, since block devices already have page caches in the kernel. Moreover, this feature has some stability issues corrupting metadata. So, we better make this deprecated. Signed-off-by: Daeho Jeong --- fsck/main.c | 18 +-- include/

Re: [f2fs-dev] [PATCH 87/87] fs: move i_blocks up a few places in struct inode

2023-09-28 Thread Jeff Layton
On Thu, 2023-09-28 at 10:41 -0700, Linus Torvalds wrote: > On Thu, 28 Sept 2023 at 04:06, Jeff Layton wrote: > > > > Move i_blocks up above the i_lock, which moves the new 4 byte hole to > > just after the timestamps, without changing the size of the structure. > > I'm sure others have mentioned

Re: [f2fs-dev] [PATCH 87/87] fs: move i_blocks up a few places in struct inode

2023-09-28 Thread Linus Torvalds
On Thu, 28 Sept 2023 at 04:06, Jeff Layton wrote: > > Move i_blocks up above the i_lock, which moves the new 4 byte hole to > just after the timestamps, without changing the size of the structure. I'm sure others have mentioned this, but 'struct inode' is marked with __randomize_layout, so the ac

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Arnd Bergmann
On Thu, Sep 28, 2023, at 13:40, Jeff Layton wrote: > On Thu, 2023-09-28 at 10:19 -0700, Darrick J. Wong wrote: >> >> > I remember seeing those patches go by. I don't remember that change >> > being NaK'ed, but I wasn't paying close attention at the time >> > >> > Looking at it objectively now, I

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Theodore Ts'o
On Thu, Sep 28, 2023 at 01:40:55PM -0400, Jeff Layton wrote: > > Correct. We'd lose some fidelity in currently stored timestamps, but as > Linus and Ted pointed out, anything below ~100ns granularity is > effectively just noise, as that's the floor overhead for calling into > the kernel. It's hard

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Linus Torvalds
On Thu, 28 Sept 2023 at 14:28, Theodore Ts'o wrote: > > I don't think anyone will complain about breaking the userspace API > --- especially since if, say, the CIA was using this for their spies' > drop boxes, they probably wouldn't want to admit it. :-) Well, you will find that real apps do kin

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Amir Goldstein
On Thu, Sep 28, 2023 at 8:19 PM Darrick J. Wong wrote: > > On Thu, Sep 28, 2023 at 01:06:03PM -0400, Jeff Layton wrote: > > On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote: > > > On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote: > > > > This shaves 8 bytes off struct inode, according to pa

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread Amir Goldstein
On Fri, Sep 29, 2023 at 3:19 AM Linus Torvalds wrote: ... > So yes, real programs to cache stat information, and it matters for > performance. > > But I don't think any actual reasonable program will have > *correctness* issues, though - I beg to disagree. > because there are certainly filesyst

Re: [f2fs-dev] [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers

2023-09-28 Thread David Howells
Jeff Layton wrote: > Correct. We'd lose some fidelity in currently stored timestamps, but as > Linus and Ted pointed out, anything below ~100ns granularity is > effectively just noise, as that's the floor overhead for calling into > the kernel. It's hard to argue that any application needs that