Page MenuHomeFreeBSD

vfs: stop always overwriting ->mnt_stat in VFS_STATFS
ClosedPublic

Authored by mjg on Aug 18 2019, 5:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 5:14 AM
Unknown Object (File)
Sep 6 2023, 10:12 PM
Unknown Object (File)
Sep 6 2023, 10:11 PM
Unknown Object (File)
Sep 6 2023, 10:10 PM
Unknown Object (File)
Sep 1 2023, 3:24 PM
Unknown Object (File)
Aug 26 2023, 3:56 PM
Unknown Object (File)
Aug 8 2023, 5:19 PM
Unknown Object (File)
Aug 8 2023, 5:11 PM
Subscribers

Details

Summary

statfs is called a lot and currently the code does the following:

int
__vfs_statfs(struct mount *mp, struct statfs *sbp)
{
        int error;

        error = mp->mnt_op->vfs_statfs(mp, &mp->mnt_stat);
        if (sbp != &mp->mnt_stat)
                *sbp = mp->mnt_stat;
        return (error);
}

i.e. all callers ovewrrite the content at the same time. Apart from this being a bottleneck, it does not appear to be of any user either. To the best of my grep all fields are either constant since mount/remount or not used by filesystems in the first place, Also note both mount and remount code do VFS_STATFS(mp, &mp->mnt_stat) to populate it.

There are infrequent callers who use it as means to avoid having to allocate a new buffer. I left them alone.

This came when I tried to benchmark statfs after removing mount mtx from the code path (to be posted later).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 25946