[PATCH v2 29/29] xfsprogs: Stop using platform_physmem()

Pavel Reichl
2021-08-06T21:24:06Z

---
libfrog/linux.c | 8 +++++++-
libfrog/platform.h | 1 +
repair/xfs_repair.c | 2 +-
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libfrog/linux.c b/libfrog/linux.c
index 43ca1e7d..9b99d1a7 100644
--- a/libfrog/linux.c
+++ b/libfrog/linux.c
@@ -338,7 +338,7 @@ platform_nproc(void)
}

unsigned long
-platform_physmem(void)
+physmem(void)
{
struct sysinfo si;

@@ -349,3 +349,9 @@ platform_physmem(void)
}
return (si.totalram >> 10) * si.mem_unit; /* kilobytes */
}
+
+unsigned long
+platform_physmem(void)
+{
+ return physmem();
+}
diff --git a/libfrog/platform.h b/libfrog/platform.h
index 42b0d753..b034d652 100644
--- a/libfrog/platform.h
+++ b/libfrog/platform.h
@@ -26,6 +26,7 @@ int direct_blockdev(void);
int platform_align_blockdev(void);
int align_blockdev(void);
unsigned long platform_physmem(void); /* in kilobytes */
+unsigned long physmem(void); /* in kilobytes */
void platform_findsizes(char *path, int fd, long long *sz, int *bsz);
void findsizes(char *path, int fd, long long *sz, int *bsz);
int platform_nproc(void);
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index fbbc8c6f..b8d56d9d 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -1081,7 +1081,7 @@ main(int argc, char **argv)
(mp->m_sb.sb_dblocks >> (10 + 1)) +
50000; /* rough estimate of 50MB overhead */
max_mem = max_mem_specified ? max_mem_specified * 1024 :
- platform_physmem() * 3 / 4;
+ physmem() * 3 / 4;

if (getrlimit(RLIMIT_AS, &rlim) != -1 &&
rlim.rlim_cur != RLIM_INFINITY) {
--
2.31.1