On Sat, Jan 29, 2022 at 2:53 AM Goffredo Baroncelli <kreijack@xxxxxxxxx> wrote: > > I think that for the systemd uses cases (singled device FS), a simpler > approach would be: > > fstatfs(fd, &sfs) > needed = sfs.f_blocks - sfs.f_bavail; > needed *= sfs.f_bsize > > needed = roundup_64(needed, 3*(1024*1024*1024)) > > Comparing the original systemd-homed code, I made the following changes > - 1) f_bfree is replaced by f_bavail (which seem to be more consistent to the disk usage; to me it seems to consider also the metadata chunk allocation) > - 2) the needing value is rounded up of 3GB in order to consider a further 1 data chunk and 2 metadata chunk (DUP)) > > Comments ? I'm still wondering if such a significant shrink is even indicated, in lieu of trim. Isn't it sufficient to just trim on logout, thus returning unused blocks to the underlying filesystem? And then do an fs resize (shrink or grow) as needed on login, so that the user home shows ~80% of the free space in the underlying file system? homework-luks.c:3407: /* Before we shrink, let's trim the file system, so that we need less space on disk during the shrinking */ -- Chris Murphy