Only load filesystem details for the mount points that we're actually
going to write to. This reduces our syscall count considerably. In the
case of installation, we would actually stat every mountpoint twice (an
extra round for download diskspace) which means (on my system) a total
of 60 syscalls to write to 3 partitions when installing the kernel
package. This change reduces the 60 syscalls down to the expected 3.
A slight debug output change is added here to discern between a
mountpoint added to our linked list versus when we actually load the fs
info.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
The original impetus for this was to placate automounters (lolsystemd), but
even without that, it makes sense to only touch what we're interested in.
+ /* don't check a mount that we know we can't stat */
+ if(mp && mp->fsinfo_loaded == MOUNT_FSINFO_FAIL) {
+ continue;
+ }
+
+ /* lazy load filesystem info */
+ if(mp->fsinfo_loaded == MOUNT_FSINFO_UNLOADED) {
+ if(mount_point_load_fsinfo(handle, mp) < 0) {
+ continue;
+ }
+ }
+
/* the addition of (divisor - 1) performs ceil() with integer division */
remove_size = (st.st_size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
mp->blocks_needed -= remove_size;
@@ -292,6 +300,18 @@ static int calculate_installed_size(alpm_handle_t *handle,
continue;
}
+ /* don't check a mount that we know we can't stat */
+ if(mp && mp->fsinfo_loaded == MOUNT_FSINFO_FAIL) {
+ continue;
+ }
+
+ /* lazy load filesystem info */
+ if(mp->fsinfo_loaded == MOUNT_FSINFO_UNLOADED) {
+ if(mount_point_load_fsinfo(handle, mp) < 0) {
+ continue;
+ }
+ }
+
/* the addition of (divisor - 1) performs ceil() with integer division */
install_size = (file->size + mp->fsp.f_bsize - 1) / mp->fsp.f_bsize;
mp->blocks_needed += install_size;
@@ -344,6 +364,13 @@ int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
goto finish;
}
+ if(cachedir_mp->fsinfo_loaded == MOUNT_FSINFO_UNLOADED) {
+ if(mount_point_load_fsinfo(handle, cachedir_mp)) {
+ error = 1;
+ goto finish;
+ }
+ }
+
/* there's no need to check for a R/O mounted filesystem here, as
* _alpm_filecache_setup will never give us a non-writable directory */