linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] libfrog: take over platform code headers
@ 2019-10-22 18:48 Darrick J. Wong
  2019-10-22 18:48 ` [PATCH 1/4] libfrog: clean up platform_nproc Darrick J. Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Darrick J. Wong @ 2019-10-22 18:48 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

Hi all,

This series cleans up a couple of libfrog platform problems, removes
unnecessary libxfs wrappers of libfrog functions, and finishes by moving
headers for libfrog's platform code into libfrog/platform.h.

If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything.  Enjoy!
Comments and questions are, as always, welcome.

--D

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=libfrog-migrate-platform-code

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] libfrog: clean up platform_nproc
  2019-10-22 18:48 [PATCH 0/4] libfrog: take over platform code headers Darrick J. Wong
@ 2019-10-22 18:48 ` Darrick J. Wong
  2019-11-01 20:35   ` Eric Sandeen
  2019-10-22 18:48 ` [PATCH 2/4] libxfs: remove libxfs_nproc Darrick J. Wong
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2019-10-22 18:48 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

The platform_nproc function should check for error returns and obviously
garbage values and deal with them appropriately.  Fix the header
declaration since it's part of the libfrog platform support code, not
libxfs.  xfs_scrub will make use of it in the next patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 include/libxfs.h           |    1 -
 include/platform_defs.h.in |    2 ++
 libfrog/linux.c            |    9 ++++++++-
 3 files changed, 10 insertions(+), 2 deletions(-)


diff --git a/include/libxfs.h b/include/libxfs.h
index 63696df5..227084ae 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -135,7 +135,6 @@ extern void	libxfs_device_close (dev_t);
 extern int	libxfs_device_alignment (void);
 extern void	libxfs_report(FILE *);
 extern void	platform_findsizes(char *path, int fd, long long *sz, int *bsz);
-extern int	platform_nproc(void);
 
 /* check or write log footer: specify device, log size in blocks & uuid */
 typedef char	*(libxfs_get_block_t)(char *, int, void *);
diff --git a/include/platform_defs.h.in b/include/platform_defs.h.in
index d111ec6d..adb00181 100644
--- a/include/platform_defs.h.in
+++ b/include/platform_defs.h.in
@@ -77,4 +77,6 @@ typedef unsigned short umode_t;
 # define ASSERT(EX)	((void) 0)
 #endif
 
+extern int	platform_nproc(void);
+
 #endif	/* __XFS_PLATFORM_DEFS_H__ */
diff --git a/libfrog/linux.c b/libfrog/linux.c
index b6c24879..79bd79eb 100644
--- a/libfrog/linux.c
+++ b/libfrog/linux.c
@@ -242,10 +242,17 @@ platform_align_blockdev(void)
 	return max_block_alignment;
 }
 
+/* How many CPUs are online? */
 int
 platform_nproc(void)
 {
-	return sysconf(_SC_NPROCESSORS_ONLN);
+	long nproc = sysconf(_SC_NPROCESSORS_ONLN);
+
+	if (nproc < 1)
+		return 1;
+	if (nproc >= INT_MAX)
+		return INT_MAX;
+	return nproc;
 }
 
 unsigned long


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] libxfs: remove libxfs_nproc
  2019-10-22 18:48 [PATCH 0/4] libfrog: take over platform code headers Darrick J. Wong
  2019-10-22 18:48 ` [PATCH 1/4] libfrog: clean up platform_nproc Darrick J. Wong
@ 2019-10-22 18:48 ` Darrick J. Wong
  2019-11-01 20:35   ` Eric Sandeen
  2019-10-22 18:48 ` [PATCH 3/4] libxfs: remove libxfs_physmem Darrick J. Wong
  2019-10-22 18:48 ` [PATCH 4/4] libfrog: take over platform headers Darrick J. Wong
  3 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2019-10-22 18:48 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Remove libxfs_nproc since it's a wrapper around a libfrog function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 include/libxfs.h  |    1 -
 libxfs/init.c     |   11 -----------
 repair/phase4.c   |    6 +++---
 repair/prefetch.c |    2 +-
 repair/slab.c     |    2 +-
 5 files changed, 5 insertions(+), 17 deletions(-)


diff --git a/include/libxfs.h b/include/libxfs.h
index 227084ae..405572ee 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -161,7 +161,6 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
 #endif
 
 
-extern int		libxfs_nproc(void);
 extern unsigned long	libxfs_physmem(void);	/* in kilobytes */
 
 #include "xfs_ialloc.h"
diff --git a/libxfs/init.c b/libxfs/init.c
index 4446a62a..9e762435 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -853,17 +853,6 @@ libxfs_report(FILE *fp)
 	fprintf(fp, "%s", c);
 }
 
-int
-libxfs_nproc(void)
-{
-	int	nr;
-
-	nr = platform_nproc();
-	if (nr < 1)
-		nr = 1;
-	return nr;
-}
-
 unsigned long
 libxfs_physmem(void)
 {
diff --git a/repair/phase4.c b/repair/phase4.c
index 66e69db7..e1ba778f 100644
--- a/repair/phase4.c
+++ b/repair/phase4.c
@@ -235,7 +235,7 @@ process_rmap_data(
 	if (!rmap_needs_work(mp))
 		return;
 
-	create_work_queue(&wq, mp, libxfs_nproc());
+	create_work_queue(&wq, mp, platform_nproc());
 	for (i = 0; i < mp->m_sb.sb_agcount; i++)
 		queue_work(&wq, check_rmap_btrees, i, NULL);
 	destroy_work_queue(&wq);
@@ -243,12 +243,12 @@ process_rmap_data(
 	if (!xfs_sb_version_hasreflink(&mp->m_sb))
 		return;
 
-	create_work_queue(&wq, mp, libxfs_nproc());
+	create_work_queue(&wq, mp, platform_nproc());
 	for (i = 0; i < mp->m_sb.sb_agcount; i++)
 		queue_work(&wq, compute_ag_refcounts, i, NULL);
 	destroy_work_queue(&wq);
 
-	create_work_queue(&wq, mp, libxfs_nproc());
+	create_work_queue(&wq, mp, platform_nproc());
 	for (i = 0; i < mp->m_sb.sb_agcount; i++) {
 		queue_work(&wq, process_inode_reflink_flags, i, NULL);
 		queue_work(&wq, check_refcount_btrees, i, NULL);
diff --git a/repair/prefetch.c b/repair/prefetch.c
index beb36cd6..8e3772ed 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -1015,7 +1015,7 @@ do_inode_prefetch(
 	 */
 	if (check_cache && !libxfs_bcache_overflowed()) {
 		queue.wq_ctx = mp;
-		create_work_queue(&queue, mp, libxfs_nproc());
+		create_work_queue(&queue, mp, platform_nproc());
 		for (i = 0; i < mp->m_sb.sb_agcount; i++)
 			queue_work(&queue, func, i, NULL);
 		destroy_work_queue(&queue);
diff --git a/repair/slab.c b/repair/slab.c
index ba5c2327..f075ee5b 100644
--- a/repair/slab.c
+++ b/repair/slab.c
@@ -234,7 +234,7 @@ qsort_slab(
 		return;
 	}
 
-	create_work_queue(&wq, NULL, libxfs_nproc());
+	create_work_queue(&wq, NULL, platform_nproc());
 	hdr = slab->s_first;
 	while (hdr) {
 		qs = malloc(sizeof(struct qsort_slab));


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] libxfs: remove libxfs_physmem
  2019-10-22 18:48 [PATCH 0/4] libfrog: take over platform code headers Darrick J. Wong
  2019-10-22 18:48 ` [PATCH 1/4] libfrog: clean up platform_nproc Darrick J. Wong
  2019-10-22 18:48 ` [PATCH 2/4] libxfs: remove libxfs_nproc Darrick J. Wong
@ 2019-10-22 18:48 ` Darrick J. Wong
  2019-11-01 20:35   ` Eric Sandeen
  2019-10-22 18:48 ` [PATCH 4/4] libfrog: take over platform headers Darrick J. Wong
  3 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2019-10-22 18:48 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Remove this thin wrapper too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 include/libxfs.h    |    3 ---
 libxfs/init.c       |    6 ------
 repair/xfs_repair.c |    2 +-
 3 files changed, 1 insertion(+), 10 deletions(-)


diff --git a/include/libxfs.h b/include/libxfs.h
index 405572ee..0cc0820b 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -160,9 +160,6 @@ extern void cmn_err(int, char *, ...);
 enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
 #endif
 
-
-extern unsigned long	libxfs_physmem(void);	/* in kilobytes */
-
 #include "xfs_ialloc.h"
 
 #include "xfs_attr_leaf.h"
diff --git a/libxfs/init.c b/libxfs/init.c
index 9e762435..537b73bd 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -852,9 +852,3 @@ libxfs_report(FILE *fp)
 	c = asctime(localtime(&t));
 	fprintf(fp, "%s", c);
 }
-
-unsigned long
-libxfs_physmem(void)
-{
-	return platform_physmem();
-}
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index 7e810ef4..df65b6c5 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -852,7 +852,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 :
-						libxfs_physmem() * 3 / 4;
+					      platform_physmem() * 3 / 4;
 
 		if (getrlimit(RLIMIT_AS, &rlim) != -1 &&
 					rlim.rlim_cur != RLIM_INFINITY) {


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] libfrog: take over platform headers
  2019-10-22 18:48 [PATCH 0/4] libfrog: take over platform code headers Darrick J. Wong
                   ` (2 preceding siblings ...)
  2019-10-22 18:48 ` [PATCH 3/4] libxfs: remove libxfs_physmem Darrick J. Wong
@ 2019-10-22 18:48 ` Darrick J. Wong
  2019-11-01 20:36   ` Eric Sandeen
  3 siblings, 1 reply; 9+ messages in thread
From: Darrick J. Wong @ 2019-10-22 18:48 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Move all the declarations for platform-specific functions into
libfrog/platform.h, since they're a part of libfrog now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 include/libxfs.h    |    1 -
 libfrog/platform.h  |   26 ++++++++++++++++++++++++++
 libfrog/topology.c  |    1 +
 libxfs/init.c       |    1 +
 libxfs/init.h       |   14 --------------
 repair/xfs_repair.c |    1 +
 6 files changed, 29 insertions(+), 15 deletions(-)
 create mode 100644 libfrog/platform.h


diff --git a/include/libxfs.h b/include/libxfs.h
index 0cc0820b..85ced52a 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -134,7 +134,6 @@ extern dev_t	libxfs_device_open (char *, int, int, int);
 extern void	libxfs_device_close (dev_t);
 extern int	libxfs_device_alignment (void);
 extern void	libxfs_report(FILE *);
-extern void	platform_findsizes(char *path, int fd, long long *sz, int *bsz);
 
 /* check or write log footer: specify device, log size in blocks & uuid */
 typedef char	*(libxfs_get_block_t)(char *, int, void *);
diff --git a/libfrog/platform.h b/libfrog/platform.h
new file mode 100644
index 00000000..76887e5e
--- /dev/null
+++ b/libfrog/platform.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2000-2006 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ */
+
+#ifndef __LIBFROG_PLATFORM_H__
+#define __LIBFROG_PLATFORM_H__
+
+int platform_check_ismounted(char *path, char *block, struct stat *sptr,
+		int verbose);
+int platform_check_iswritable(char *path, char *block, struct stat *sptr);
+int platform_set_blocksize(int fd, char *path, dev_t device, int bsz,
+		int fatal);
+void platform_flush_device(int fd, dev_t device);
+char *platform_findrawpath(char *path);
+char *platform_findblockpath(char *path);
+int platform_direct_blockdev(void);
+int platform_align_blockdev(void);
+unsigned long platform_physmem(void);	/* in kilobytes */
+void platform_findsizes(char *path, int fd, long long *sz, int *bsz);
+int platform_nproc(void);
+
+void platform_findsizes(char *path, int fd, long long *sz, int *bsz);
+
+#endif /* __LIBFROG_PLATFORM_H__ */
diff --git a/libfrog/topology.c b/libfrog/topology.c
index e2f87415..b1b470c9 100644
--- a/libfrog/topology.c
+++ b/libfrog/topology.c
@@ -11,6 +11,7 @@
 #endif /* ENABLE_BLKID */
 #include "xfs_multidisk.h"
 #include "topology.h"
+#include "platform.h"
 
 #define TERABYTES(count, blog)	((uint64_t)(count) << (40 - (blog)))
 #define GIGABYTES(count, blog)	((uint64_t)(count) << (30 - (blog)))
diff --git a/libxfs/init.c b/libxfs/init.c
index 537b73bd..a0d4b7f4 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -21,6 +21,7 @@
 #include "xfs_trans.h"
 #include "xfs_rmap_btree.h"
 #include "xfs_refcount_btree.h"
+#include "libfrog/platform.h"
 
 #include "libxfs.h"		/* for now */
 
diff --git a/libxfs/init.h b/libxfs/init.h
index b23e493c..df49a99a 100644
--- a/libxfs/init.h
+++ b/libxfs/init.h
@@ -9,18 +9,4 @@
 struct stat;
 extern int     use_xfs_buf_lock;
 
-extern int platform_check_ismounted (char *path, char *block,
-					struct stat *sptr, int verbose);
-extern int platform_check_iswritable (char *path, char *block, struct stat *sptr);
-extern int platform_set_blocksize (int fd, char *path, dev_t device, int bsz, int fatal);
-extern void platform_flush_device (int fd, dev_t device);
-extern char *platform_findrawpath(char *path);
-extern char *platform_findrawpath (char *path);
-extern char *platform_findblockpath (char *path);
-extern int platform_direct_blockdev (void);
-extern int platform_align_blockdev (void);
-extern unsigned long platform_physmem(void);	/* in kilobytes */
-extern void platform_findsizes(char *path, int fd, long long *sz, int *bsz);
-extern int platform_nproc(void);
-
 #endif	/* LIBXFS_INIT_H */
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index df65b6c5..3338a7b8 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -23,6 +23,7 @@
 #include "slab.h"
 #include "rmap.h"
 #include "libfrog/fsgeom.h"
+#include "libfrog/platform.h"
 
 /*
  * option tables for getsubopt calls


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] libfrog: clean up platform_nproc
  2019-10-22 18:48 ` [PATCH 1/4] libfrog: clean up platform_nproc Darrick J. Wong
@ 2019-11-01 20:35   ` Eric Sandeen
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Sandeen @ 2019-11-01 20:35 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

On 10/22/19 1:48 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> The platform_nproc function should check for error returns and obviously
> garbage values and deal with them appropriately.  Fix the header
> declaration since it's part of the libfrog platform support code, not
> libxfs.  xfs_scrub will make use of it in the next patch.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] libxfs: remove libxfs_nproc
  2019-10-22 18:48 ` [PATCH 2/4] libxfs: remove libxfs_nproc Darrick J. Wong
@ 2019-11-01 20:35   ` Eric Sandeen
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Sandeen @ 2019-11-01 20:35 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs



On 10/22/19 1:48 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Remove libxfs_nproc since it's a wrapper around a libfrog function.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] libxfs: remove libxfs_physmem
  2019-10-22 18:48 ` [PATCH 3/4] libxfs: remove libxfs_physmem Darrick J. Wong
@ 2019-11-01 20:35   ` Eric Sandeen
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Sandeen @ 2019-11-01 20:35 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

On 10/22/19 1:48 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Remove this thin wrapper too.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] libfrog: take over platform headers
  2019-10-22 18:48 ` [PATCH 4/4] libfrog: take over platform headers Darrick J. Wong
@ 2019-11-01 20:36   ` Eric Sandeen
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Sandeen @ 2019-11-01 20:36 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

On 10/22/19 1:48 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Move all the declarations for platform-specific functions into
> libfrog/platform.h, since they're a part of libfrog now.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-01 20:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22 18:48 [PATCH 0/4] libfrog: take over platform code headers Darrick J. Wong
2019-10-22 18:48 ` [PATCH 1/4] libfrog: clean up platform_nproc Darrick J. Wong
2019-11-01 20:35   ` Eric Sandeen
2019-10-22 18:48 ` [PATCH 2/4] libxfs: remove libxfs_nproc Darrick J. Wong
2019-11-01 20:35   ` Eric Sandeen
2019-10-22 18:48 ` [PATCH 3/4] libxfs: remove libxfs_physmem Darrick J. Wong
2019-11-01 20:35   ` Eric Sandeen
2019-10-22 18:48 ` [PATCH 4/4] libfrog: take over platform headers Darrick J. Wong
2019-11-01 20:36   ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).