xfsprogs-4.15: common library for misc. routines
cover xfsprogs-4.15: common library for misc. routines
Hi all,
This patch series refactors miscellaneous data structures and runtime support code out of libxfs and libxcmd into a new library to contain all of the funny random other gunk ("libfrog") that doesn't fit anywhere else. Initially, libfrog will contain routines for bit manipulation, device topology, threaded workqueues, an avl tree, and file path detection. Existing programs are modified to pull from libfrog; the future xfs_scrub program will also take advantage of it.
This whole mess sits atop the libxfs-4.15-sync branch; see the djwong-devel branch in my repo[1] for something pullable.
--D
[1] https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=djwong-devel
PATCH 1/12 libfrog: move all the userspace support stuff into a new library
From: Darrick J. Wong <[email protected]>
This library is meant to contain all the Funny Random Other Gunk that the xfsprogs utilities rely on. Move all that stuff into this library to reduce the pollution in the other libraries.
Ribbit! Ribbit!
--- Makefile | 2 +- debian/rules | 2 +- include/builddefs.in | 1 + libfrog/Makefile | 21 +++++++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 libfrog/Makefile
Makefile +1 -1
@@ -44,7 +44,7 @@ endif # header install rules to populate include/xfs correctly HDR_SUBDIRS = include libxfs -DLIB_SUBDIRS = libxlog libxcmd libhandle +DLIB_SUBDIRS = libfrog libxlog libxcmd libhandle LIB_SUBDIRS = libxfs $(DLIB_SUBDIRS) TOOL_SUBDIRS = copy db estimate fsck growfs io logprint mkfs quota \ mdrestore repair rtcp m4 man doc debian spaceman
debian/rules +1 -1
@@ -48,7 +48,7 @@ dibuild: for dir in include libxfs; do \ $(MAKE) -C $$dir NODEP=1 install-headers; \ done; \ - for dir in include libxfs libxcmd mkfs; do \ + for dir in include libxfs libxcmd libfrog mkfs; do \ $(MAKE) -C $$dir; \ done; \ mv mkfs/mkfs.xfs mkfs/mkfs.xfs-$(bootpkg); \
include/builddefs.in +1 -0
@@ -36,6 +36,7 @@ LIBEDITLINE = @libeditline@ LIBREADLINE = @libreadline@ LIBBLKID = @libblkid@ LIBXFS = $(TOPDIR)/libxfs/libxfs.la +LIBFROG = $(TOPDIR)/libfrog/libfrog.la LIBXCMD = $(TOPDIR)/libxcmd/libxcmd.la LIBXLOG = $(TOPDIR)/libxlog/libxlog.la LIBHANDLE = $(TOPDIR)/libhandle/libhandle.la
libfrog/Makefile new file +21 -0
@@ -0,0 +1,21 @@ +# +# Copyright (c) 2017 Oracle. All Rights Reserved. +# + +TOPDIR = .. +include $(TOPDIR)/include/builddefs + +LTLIBRARY = libfrog.la +LT_CURRENT = 0 +LT_REVISION = 0 +LT_AGE = 0 + +CFILES = + +default: ltdepend $(LTLIBRARY) + +include $(BUILDRULES) + +install install-dev: default + +-include .ltdep
PATCH 2/12 libfrog: move libxfs_log2_roundup to libfrog
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Move libxfs_log2_roundup to libfrog and remove the 'libxfs_' prefix.
--- include/libfrog.h | 25 +++++++++++++++++++++++++ include/libxfs.h | 1 - libfrog/Makefile | 3 ++- libfrog/util.c | 38 ++++++++++++++++++++++++++++++++++++++ libxfs/util.c | 12 ------------ mkfs/Makefile | 5 +++-- mkfs/maxtrres.c | 4 ++-- mkfs/xfs_mkfs.c | 4 ++-- repair/Makefile | 6 +++--- repair/sb.c | 4 ++-- 10 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 include/libfrog.h create mode 100644 libfrog/util.c
include/libfrog.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef __LIBFROG_UTIL_H_ +#define __LIBFROG_UTIL_H_ + +unsigned int log2_roundup (unsigned int i); + +#endif /* __LIBFROG_UTIL_H_ */
include/libxfs.h +0 -1
@@ -165,7 +165,6 @@ extern int libxfs_log_header(char *, uuid_t *, int, int, int, xfs_lsn_t,/* Shared utility routines */ -extern unsigned int libxfs_log2_roundup (unsigned int i);extern int libxfs_alloc_file_space (struct xfs_inode *,xfs_off_t ,xfs_off_t ,int ,int );
libfrog/Makefile +2 -1
@@ -10,7 +10,8 @@ LT_CURRENT = 0 LT_REVISION = 0 LT_AGE = 0 -CFILES = +CFILES = \ +util.c default: ltdepend $(LTLIBRARY)
libfrog/util.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "platform_defs.h" +#include "libfrog.h" + +/* +* libfrog is a collection of miscellaneous userspace utilities. +* It's a library of Funny Random Oddball Gunk <cough>. +*/ + +unsigned int +log2_roundup (unsigned int i) +{ +unsigned int rval; + +for (rval =0 ; rval <NBBY *sizeof (i); rval++) { +if ((1 << rval) >= i) +break ; + } +return rval; +}
libxfs/util.c +0 -12
@@ -631,18 +631,6 @@ libxfs_alloc_file_space(return error; } -unsigned int -libxfs_log2_roundup (unsigned int i) -{ -unsigned int rval; - -for (rval =0 ; rval <NBBY *sizeof (i); rval++) { -if ((1 << rval) >= i) -break ; - } -return rval; -} -/* * Wrapper around call to libxfs_ialloc. Takes care of committing and * allocating a new transaction as needed.
mkfs/Makefile +3 -2
@@ -10,8 +10,9 @@ LTCOMMAND = mkfs.xfs HFILES = CFILES = maxtrres.c proto.c xfs_mkfs.c -LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) $(LIBUUID) -LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) +LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) \ + $(LIBUUID) +LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND)
mkfs/maxtrres.c +2 -2
@@ -23,7 +23,7 @@* of sector size, block size, inode size, directory version, and * directory block size. */ - +#include "libfrog.h" #include "libxfs.h" #include "xfs_multidisk.h"
@@ -55,7 +55,7 @@ max_trans_res( sbp->sb_blocklog = blocklog; sbp->sb_blocksize =1 << blocklog; sbp->sb_agblocks = agsize; - sbp->sb_agblklog = (uint8_t )libxfs_log2_roundup ((unsigned int )agsize); + sbp->sb_agblklog = (uint8_t )log2_roundup ((unsigned int )agsize); sbp->sb_inodelog = inodelog; sbp->sb_inopblog = blocklog - inodelog; sbp->sb_inodesize =1 << inodelog;
mkfs/xfs_mkfs.c +2 -2
@@ -15,7 +15,7 @@* along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "libfrog.h" #include "libxfs.h" #include <ctype.h> #include "xfs_multidisk.h"
@@ -2720,7 +2720,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),memset (mp,0 ,sizeof (xfs_mount_t)); sbp->sb_blocklog = (uint8_t )blocklog; sbp->sb_sectlog = (uint8_t )sectorlog; - sbp->sb_agblklog = (uint8_t )libxfs_log2_roundup ((unsigned int )agsize); + sbp->sb_agblklog = (uint8_t )log2_roundup ((unsigned int )agsize); sbp->sb_agblocks = (xfs_agblock_t )agsize; mp->m_blkbb_log = sbp->sb_blocklog -BBSHIFT ; mp->m_sectbb_log = sbp->sb_sectlog -BBSHIFT ;
repair/Makefile +3 -3
@@ -20,9 +20,9 @@ CFILES = agheader.c attr_repair.c avl.c avl64.c bmap.c btree.c \ progress.c prefetch.c rmap.c rt.c sb.c scan.c slab.c threads.c \ versions.c xfs_repair.c -LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBUUID) \ - $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) -LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) +LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) $(LIBUUID) $(LIBRT) \ + $(LIBPTHREAD) $(LIBBLKID) +LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND)
repair/sb.c +2 -2
@@ -15,7 +15,7 @@* along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "libfrog.h" #include "libxfs.h" #include "libxcmd.h" #include "libxlog.h"
@@ -399,7 +399,7 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb) sb->sb_dblocks < XFS_MIN_DBLOCKS(sb))return (XR_BAD_FS_SIZE_DATA ); -if (sb->sb_agblklog != (uint8_t )libxfs_log2_roundup (sb->sb_agblocks)) +if (sb->sb_agblklog != (uint8_t )log2_roundup (sb->sb_agblocks))return (XR_BAD_FS_SIZE_DATA ); if (sb->sb_inodesize < XFS_DINODE_MIN_SIZE ||
PATCH v2 2/12 libfrog: move libxfs_log2_roundup to libfrog
From: Darrick J. Wong <[email protected]>
Move libxfs_log2_roundup to libfrog and remove the 'libxfs_' prefix.
---
v2: fix copyright problems
--- include/libfrog.h | 23 +++++++++++++++++++++++ include/libxfs.h | 1 - libfrog/Makefile | 3 ++- libfrog/util.c | 36 ++++++++++++++++++++++++++++++++++++ libxfs/util.c | 12 ------------ mkfs/Makefile | 5 +++-- mkfs/maxtrres.c | 4 ++-- mkfs/xfs_mkfs.c | 4 ++-- repair/Makefile | 6 +++--- repair/sb.c | 4 ++-- 10 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 include/libfrog.h create mode 100644 libfrog/util.c
include/libfrog.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (c) 2000-2005 Silicon Graphics, Inc. +* All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef __LIBFROG_UTIL_H_ +#define __LIBFROG_UTIL_H_ + +unsigned int log2_roundup (unsigned int i); + +#endif /* __LIBFROG_UTIL_H_ */
include/libxfs.h +0 -1
@@ -165,7 +165,6 @@ extern int libxfs_log_header(char *, uuid_t *, int, int, int, xfs_lsn_t,/* Shared utility routines */ -extern unsigned int libxfs_log2_roundup (unsigned int i);extern int libxfs_alloc_file_space (struct xfs_inode *,xfs_off_t ,xfs_off_t ,int ,int );
libfrog/Makefile +2 -1
@@ -10,7 +10,8 @@ LT_CURRENT = 0 LT_REVISION = 0 LT_AGE = 0 -CFILES = +CFILES = \ +util.c default: ltdepend $(LTLIBRARY)
libfrog/util.c new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (c) 2000-2005 Silicon Graphics, Inc. +* All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "platform_defs.h" +#include "libfrog.h" + +/* +* libfrog is a collection of miscellaneous userspace utilities. +* It's a library of Funny Random Oddball Gunk <cough>. +*/ + +unsigned int +log2_roundup (unsigned int i) +{ +unsigned int rval; + +for (rval =0 ; rval <NBBY *sizeof (i); rval++) { +if ((1 << rval) >= i) +break ; + } +return rval; +}
libxfs/util.c +0 -12
@@ -631,18 +631,6 @@ libxfs_alloc_file_space(return error; } -unsigned int -libxfs_log2_roundup (unsigned int i) -{ -unsigned int rval; - -for (rval =0 ; rval <NBBY *sizeof (i); rval++) { -if ((1 << rval) >= i) -break ; - } -return rval; -} -/* * Wrapper around call to libxfs_ialloc. Takes care of committing and * allocating a new transaction as needed.
mkfs/Makefile +3 -2
@@ -10,8 +10,9 @@ LTCOMMAND = mkfs.xfs HFILES = CFILES = maxtrres.c proto.c xfs_mkfs.c -LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) $(LIBUUID) -LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) +LLDLIBS += $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) \ + $(LIBUUID) +LTDEPENDENCIES += $(LIBXFS) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND)
mkfs/maxtrres.c +2 -2
@@ -23,7 +23,7 @@* of sector size, block size, inode size, directory version, and * directory block size. */ - +#include "libfrog.h" #include "libxfs.h" #include "xfs_multidisk.h"
@@ -55,7 +55,7 @@ max_trans_res( sbp->sb_blocklog = blocklog; sbp->sb_blocksize =1 << blocklog; sbp->sb_agblocks = agsize; - sbp->sb_agblklog = (uint8_t )libxfs_log2_roundup ((unsigned int )agsize); + sbp->sb_agblklog = (uint8_t )log2_roundup ((unsigned int )agsize); sbp->sb_inodelog = inodelog; sbp->sb_inopblog = blocklog - inodelog; sbp->sb_inodesize =1 << inodelog;
mkfs/xfs_mkfs.c +2 -2
@@ -15,7 +15,7 @@* along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "libfrog.h" #include "libxfs.h" #include <ctype.h> #include "xfs_multidisk.h"
@@ -2720,7 +2720,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),memset (mp,0 ,sizeof (xfs_mount_t)); sbp->sb_blocklog = (uint8_t )blocklog; sbp->sb_sectlog = (uint8_t )sectorlog; - sbp->sb_agblklog = (uint8_t )libxfs_log2_roundup ((unsigned int )agsize); + sbp->sb_agblklog = (uint8_t )log2_roundup ((unsigned int )agsize); sbp->sb_agblocks = (xfs_agblock_t )agsize; mp->m_blkbb_log = sbp->sb_blocklog -BBSHIFT ; mp->m_sectbb_log = sbp->sb_sectlog -BBSHIFT ;
repair/Makefile +3 -3
@@ -20,9 +20,9 @@ CFILES = agheader.c attr_repair.c avl.c avl64.c bmap.c btree.c \ progress.c prefetch.c rmap.c rt.c sb.c scan.c slab.c threads.c \ versions.c xfs_repair.c -LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBUUID) \ - $(LIBRT) $(LIBPTHREAD) $(LIBBLKID) -LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) +LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) $(LIBUUID) $(LIBRT) \ + $(LIBPTHREAD) $(LIBBLKID) +LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND)
repair/sb.c +2 -2
@@ -15,7 +15,7 @@* along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "libfrog.h" #include "libxfs.h" #include "libxcmd.h" #include "libxlog.h"
@@ -399,7 +399,7 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb) sb->sb_dblocks < XFS_MIN_DBLOCKS(sb))return (XR_BAD_FS_SIZE_DATA ); -if (sb->sb_agblklog != (uint8_t )libxfs_log2_roundup (sb->sb_agblocks)) +if (sb->sb_agblklog != (uint8_t )log2_roundup (sb->sb_agblocks))return (XR_BAD_FS_SIZE_DATA ); if (sb->sb_inodesize < XFS_DINODE_MIN_SIZE ||
PATCH 3/12 libfrog: add bit manipulation functions
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Duplicate the libxfs bit manipulation functions -- this is for programs that don't need libxfs.
--- include/bitops.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
include/bitops.h +58 -0
@@ -56,4 +56,62 @@ static inline unsigned fls_long(unsigned long l)*/ #define ffz (x) ffs(~(x)) +/* +* XFS bit manipulation routines. Repeated here so that some programs +* don't have to link in all of libxfs just to have bit manipulation. +*/ + +/* +* masks with n high/low bits set, 64-bit values +*/ +static inline uint64_t mask64hi (int n) +{ +return (uint64_t )-1 << (64 - (n)); +} +static inline uint32_t mask32lo (int n) +{ +return ((uint32_t )1 << (n)) -1 ; +} +static inline uint64_t mask64lo (int n) +{ +return ((uint64_t )1 << (n)) -1 ; +} + +/* Get high bit set out of 32-bit argument, -1 if none set */ +static inline int highbit32 (uint32_t v) +{ +return fls (v) -1 ; +} + +/* Get high bit set out of 64-bit argument, -1 if none set */ +static inline int highbit64 (uint64_t v) +{ +return fls64 (v) -1 ; +} + +/* Get low bit set out of 32-bit argument, -1 if none set */ +static inline int lowbit32 (uint32_t v) +{ +return ffs (v) -1 ; +} + +/* Get low bit set out of 64-bit argument, -1 if none set */ +static inline int lowbit64 (uint64_t v) +{ +uint32_t w = (uint32_t )v; +int n =0 ; + +if (w) {/* lower bits */ + n =ffs (w); + }else {/* upper bits */ + w = (uint32_t )(v >>32 ); +if (w) { + n =ffs (w); +if (n) + n +=32 ; + } + } +return n -1 ; +} +#endif
PATCH 4/12 libfrog: move list_sort out of libxfs
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
List operations aren't really a part of libxfs, so move them to libfrog. This is purely a directory tree restructuring; no functional changes, though some indentation fixes are included.
--- Makefile | 8 copy/Makefile | 4 db/Makefile | 4 growfs/Makefile | 4 io/Makefile | 4 libfrog/Makefile | 2 libfrog/list_sort.c | 140 +++++++++ libfrog/radix-tree.c | 810 ++++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/Makefile | 2 libxfs/list_sort.c | 141 --------- libxfs/radix-tree.c | 808 -------------------------------------------------- logprint/Makefile | 4 mdrestore/Makefile | 4 13 files changed, 969 insertions(+), 966 deletions(-) create mode 100644 libfrog/list_sort.c create mode 100644 libfrog/radix-tree.c delete mode 100644 libxfs/list_sort.c delete mode 100644 libxfs/radix-tree.c
Makefile +5 -3
@@ -44,7 +44,8 @@ endif # header install rules to populate include/xfs correctly HDR_SUBDIRS = include libxfs -DLIB_SUBDIRS = libfrog libxlog libxcmd libhandle +LIBFROG_SUBDIR = libfrog +DLIB_SUBDIRS = libxlog libxcmd libhandle LIB_SUBDIRS = libxfs $(DLIB_SUBDIRS) TOOL_SUBDIRS = copy db estimate fsck growfs io logprint mkfs quota \ mdrestore repair rtcp m4 man doc debian spaceman
@@ -66,7 +67,7 @@ LIBTOOLIZE_BIN=glibtoolize endif # include is listed last so it is processed last in clean rules. -SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include +SUBDIRS = $(LIBFROG_SUBDIR) $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include default: include/builddefs include/platform_defs.h ifeq ($(HAVE_BUILDDEFS), no)
@@ -78,7 +79,8 @@ endif # tool/lib dependencies # note: include/xfs is set up by libxfs, too, so everything is dependent on it. -$(LIB_SUBDIRS) $(TOOL_SUBDIRS): include +$(LIBFROG_SUBDIR): include +$(LIB_SUBDIRS) $(TOOL_SUBDIRS): include libfrog $(DLIB_SUBDIRS) $(TOOL_SUBDIRS): libxfs db logprint: libxlog fsr: libhandle
copy/Makefile +2 -2
@@ -9,8 +9,8 @@ LTCOMMAND = xfs_copy CFILES = xfs_copy.c HFILES = xfs_copy.h -LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBUUID) $(LIBPTHREAD) $(LIBRT) -LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) +LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBPTHREAD) $(LIBRT) +LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND)
db/Makefile +2 -2
@@ -17,8 +17,8 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \ CFILES = $(HFILES:.h=.c) btdump.c LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh -LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) -LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) +LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) +LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBFROG) LLDFLAGS += -static-libtool-libs ifeq ($(ENABLE_READLINE),yes)
growfs/Makefile +2 -2
@@ -9,7 +9,7 @@ LTCOMMAND = xfs_growfs CFILES = xfs_growfs.c -LLDLIBS = $(LIBXFS) $(LIBXCMD) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) +LLDLIBS = $(LIBXFS) $(LIBXCMD) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) ifeq ($(ENABLE_READLINE),yes) LLDLIBS += $(LIBREADLINE) $(LIBTERMCAP) endif
@@ -18,7 +18,7 @@ ifeq ($(ENABLE_EDITLINE),yes) LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP) endif -LTDEPENDENCIES = $(LIBXFS) $(LIBXCMD) +LTDEPENDENCIES = $(LIBXFS) $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static-libtool-libs LSRCFILES = xfs_info.sh
io/Makefile +2 -2
@@ -14,8 +14,8 @@ CFILES = init.c \ pwrite.c reflink.c scrub.c seek.c shutdown.c stat.c sync.c truncate.c \ utimes.c -LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBPTHREAD) -LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) +LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD) +LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) LLDFLAGS = -static-libtool-libs ifeq ($(HAVE_FADVISE),yes)
libfrog/Makefile +2 -0
@@ -11,6 +11,8 @@ LT_REVISION = 0 LT_AGE = 0 CFILES = \ +list_sort.c \ +radix-tree.c \ util.c default: ltdepend $(LTLIBRARY)
libfrog/list_sort.c new file +140 -0
140 lines not on this page · raw message
libfrog/radix-tree.c new file +810 -0
810 lines not on this page · raw message
libxfs/Makefile +0 -2
@@ -58,9 +58,7 @@ CFILES = cache.c \ defer_item.c \ init.c \ kmem.c \ - list_sort.c \ logitem.c \ - radix-tree.c \ rdwr.c \ trans.c \ util.c \
libxfs/list_sort.c deleted +0 -141
141 lines not on this page · raw message
libxfs/radix-tree.c deleted +0 -808
808 lines not on this page · raw message
logprint/Makefile +2 -2
@@ -12,8 +12,8 @@ CFILES = logprint.c \ log_copy.c log_dump.c log_misc.c \ log_print_all.c log_print_trans.c log_redo.c -LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) -LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) +LLDLIBS = $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBPTHREAD) +LTDEPENDENCIES = $(LIBXFS) $(LIBXLOG) $(LIBFROG) LLDFLAGS = -static-libtool-libs default: depend $(LTCOMMAND)
mdrestore/Makefile +2 -2
@@ -8,8 +8,8 @@ include $(TOPDIR)/include/builddefs LTCOMMAND = xfs_mdrestore CFILES = xfs_mdrestore.c -LLDLIBS = $(LIBXFS) $(LIBRT) $(LIBPTHREAD) $(LIBUUID) -LTDEPENDENCIES = $(LIBXFS) +LLDLIBS = $(LIBXFS) $(LIBFROG) $(LIBRT) $(LIBPTHREAD) $(LIBUUID) +LTDEPENDENCIES = $(LIBXFS) $(LIBFROG) LLDFLAGS = -static default: depend $(LTCOMMAND)
PATCH 5/12 libfrog: promote avl64 code from xfs_repair
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
xfs_scrub will make use of the avl64 code, so promote it out of repair and into libfrog.
--- include/avl64.h | 133 +++++ libfrog/Makefile | 1 libfrog/avl64.c | 1418 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ repair/Makefile | 4 repair/avl64.c | 1418 ------------------------------------------------------ repair/avl64.h | 133 ----- 6 files changed, 1554 insertions(+), 1553 deletions(-) create mode 100644 include/avl64.h create mode 100644 libfrog/avl64.c delete mode 100644 repair/avl64.c delete mode 100644 repair/avl64.h
include/avl64.h new file +133 -0
@@ -0,0 +1,133 @@ +/* +* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. +* All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#ifndef __XR_AVL64_H__ +#define __XR_AVL64_H__ + +#include <sys/types.h> + +typedef struct avl64node { +struct avl64node *avl_forw;/* pointer to right child (> parent) */ +struct avl64node *avl_back;/* pointer to left child (< parent) */ +struct avl64node *avl_parent;/* parent pointer */ +struct avl64node *avl_nextino;/* next in-order; NULL terminated list*/ +char avl_balance;/* tree balance */ +}avl64node_t ; + +/* +* avl-tree operations +*/ +typedef struct avl64ops { +uint64_t (*avl_start)(avl64node_t *); +uint64_t (*avl_end)(avl64node_t *); +}avl64ops_t ; + +/* +* avoid complaints about multiple def's since these are only used by +* the avl code internally +*/ +#ifndef AVL_START +#define AVL_START (tree, n) (*(tree)->avl_ops->avl_start)(n) +#define AVL_END (tree, n) (*(tree)->avl_ops->avl_end)(n) +#endif + +/* +* tree descriptor: +* root points to the root of the tree. +* firstino points to the first in the ordered list. +*/ +typedef struct avl64tree_desc { +avl64node_t *avl_root; +avl64node_t *avl_firstino; +avl64ops_t *avl_ops; +}avl64tree_desc_t ; + +/* possible values for avl_balance */ + +#define AVL_BACK 1 +#define AVL_BALANCE 0 +#define AVL_FORW 2 + +/* +* 'Exported' avl tree routines +*/ +avl64node_t +*avl64_insert ( +avl64tree_desc_t *tree, +avl64node_t *newnode); + +void +avl64_delete ( +avl64tree_desc_t *tree, +avl64node_t *np); + +void +avl64_insert_immediate ( +avl64tree_desc_t *tree, +avl64node_t *afterp, +avl64node_t *newnode); + +void +avl64_init_tree ( +avl64tree_desc_t *tree, +avl64ops_t *ops); + +avl64node_t * +avl64_findrange ( +avl64tree_desc_t *tree, +uint64_t value); + +avl64node_t * +avl64_find ( +avl64tree_desc_t *tree, +uint64_t value); + +avl64node_t * +avl64_findanyrange ( +avl64tree_desc_t *tree, +uint64_t start, +uint64_t end, +int checklen); + + +avl64node_t * +avl64_findadjacent ( +avl64tree_desc_t *tree, +uint64_t value, +int dir); + +void +avl64_findranges ( +avl64tree_desc_t *tree, +uint64_t start, +uint64_t end, +avl64node_t **startp, +avl64node_t **endp); + +/* +* avoid complaints about multiple def's since these are only used by +* the avl code internally +*/ +#ifndef AVL_PRECEED +#define AVL_PRECEED 0x1 +#define AVL_SUCCEED 0x2 + +#define AVL_INCLUDE_ZEROLEN 0x0000 +#define AVL_EXCLUDE_ZEROLEN 0x0001 +#endif + +#endif /* __XR_AVL64_H__ */
libfrog/Makefile +1 -0
@@ -11,6 +11,7 @@ LT_REVISION = 0 LT_AGE = 0 CFILES = \ +avl64.c \ list_sort.c \ radix-tree.c \ util.c
libfrog/avl64.c new file +1418 -0
1,418 lines not on this page · raw message
repair/Makefile +2 -2
@@ -9,11 +9,11 @@ LSRCFILES = README LTCOMMAND = xfs_repair -HFILES = agheader.h attr_repair.h avl.h avl64.h bmap.h btree.h \ +HFILES = agheader.h attr_repair.h avl.h bmap.h btree.h \ da_util.h dinode.h dir2.h err_protos.h globals.h incore.h protos.h \ rt.h progress.h scan.h versions.h prefetch.h rmap.h slab.h threads.h -CFILES = agheader.c attr_repair.c avl.c avl64.c bmap.c btree.c \ +CFILES = agheader.c attr_repair.c avl.c bmap.c btree.c \ da_util.c dino_chunks.c dinode.c dir2.c globals.c incore.c \ incore_bmc.c init.c incore_ext.c incore_ino.c phase1.c \ phase2.c phase3.c phase4.c phase5.c phase6.c phase7.c \
repair/avl64.c deleted +0 -1418
1,418 lines not on this page · raw message
repair/avl64.h deleted +0 -133
11 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 6/12 libfrog: create a threaded workqueue
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Create a thread pool that queues and runs discrete work items. This will be a namespaced version of the pool in repair/threads.c; a subsequent patch will switch repair over. xfs_scrub will use the generic thread pool.
--- include/workqueue.h | 55 ++++++++++++++++ libfrog/Makefile | 3 + libfrog/workqueue.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 include/workqueue.h create mode 100644 libfrog/workqueue.c
include/workqueue.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +* +* This code was adapted from repair/threads.h. +*/ +#ifndef _WORKQUEUE_H_ +#define _WORKQUEUE_H_ + +struct workqueue ; + +typedef void workqueue_func_t (struct workqueue *wq,uint32_t index,void *arg); + +struct workqueue_item { +struct workqueue *queue; +struct workqueue_item *next; +workqueue_func_t *function; +void *arg; +uint32_t index; +}; + +struct workqueue { +void *wq_ctx; +pthread_t *threads; +struct workqueue_item *next_item; +struct workqueue_item *last_item; +pthread_mutex_t lock; +pthread_cond_t wakeup; +unsigned int item_count; +unsigned int thread_count; +bool terminate; +}; + +int workqueue_create (struct workqueue *wq,void *wq_ctx, +unsigned int nr_workers); +int workqueue_add (struct workqueue *wq,workqueue_func_t fn, +uint32_t index,void *arg); +void workqueue_destroy (struct workqueue *wq); + +#endif /* _WORKQUEUE_H_ */
libfrog/Makefile +2 -1
@@ -14,7 +14,8 @@ CFILES = \ avl64.c \ list_sort.c \ radix-tree.c \ -util.c +util.c \ +workqueue.c default: ltdepend $(LTLIBRARY)
libfrog/workqueue.c new file +177 -0
177 lines not on this page · raw message
PATCH v2 6/12 libfrog: create a threaded workqueue
From: Darrick J. Wong <[email protected]>
Create a thread pool that queues and runs discrete work items. This will be a namespaced version of the pool in repair/threads.c; a subsequent patch will switch repair over. xfs_scrub will use the generic thread pool.
---
v2: updated copyright information
--- include/workqueue.h | 55 ++++++++++++++++ libfrog/Makefile | 3 + libfrog/workqueue.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 include/workqueue.h create mode 100644 libfrog/workqueue.c
include/workqueue.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +* +* This code was adapted from repair/threads.h. +*/ +#ifndef _WORKQUEUE_H_ +#define _WORKQUEUE_H_ + +struct workqueue ; + +typedef void workqueue_func_t (struct workqueue *wq,uint32_t index,void *arg); + +struct workqueue_item { +struct workqueue *queue; +struct workqueue_item *next; +workqueue_func_t *function; +void *arg; +uint32_t index; +}; + +struct workqueue { +void *wq_ctx; +pthread_t *threads; +struct workqueue_item *next_item; +struct workqueue_item *last_item; +pthread_mutex_t lock; +pthread_cond_t wakeup; +unsigned int item_count; +unsigned int thread_count; +bool terminate; +}; + +int workqueue_create (struct workqueue *wq,void *wq_ctx, +unsigned int nr_workers); +int workqueue_add (struct workqueue *wq,workqueue_func_t fn, +uint32_t index,void *arg); +void workqueue_destroy (struct workqueue *wq); + +#endif /* _WORKQUEUE_H_ */
libfrog/Makefile +2 -1
@@ -14,7 +14,8 @@ CFILES = \ avl64.c \ list_sort.c \ radix-tree.c \ -util.c +util.c \ +workqueue.c default: ltdepend $(LTLIBRARY)
libfrog/workqueue.c new file +174 -0
174 lines not on this page · raw message
PATCH 7/12 libfrog: move topology code out of libxcmd
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Move the filesystem topology code out of libxcmd.
--- libfrog/Makefile | 1 libfrog/topology.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libxcmd/Makefile | 2 libxcmd/topology.c | 342 ---------------------------------------------------- 4 files changed, 344 insertions(+), 343 deletions(-) create mode 100644 libfrog/topology.c delete mode 100644 libxcmd/topology.c
libfrog/Makefile +1 -0
@@ -14,6 +14,7 @@ CFILES = \ avl64.c \ list_sort.c \ radix-tree.c \ +topology.c \ util.c \ workqueue.c
libfrog/topology.c new file +342 -0
342 lines not on this page · raw message
libxcmd/Makefile +1 -1
@@ -10,7 +10,7 @@ LT_CURRENT = 0 LT_REVISION = 0 LT_AGE = 0 -CFILES = command.c input.c paths.c projects.c help.c quit.c topology.c +CFILES = command.c input.c paths.c projects.c help.c quit.c ifeq ($(HAVE_GETMNTENT),yes) LCFLAGS += -DHAVE_GETMNTENT
libxcmd/topology.c deleted +0 -342
342 lines not on this page · raw message
PATCH 8/12 libfrog: move conversion factors out of libxcmd
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Move all the conversion functions out of libxcmd since they'll be used by scrub, which doesn't have a commandline.
--- include/convert.h | 39 ++++++ include/input.h | 15 -- libfrog/Makefile | 1 libfrog/convert.c | 373 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 414 insertions(+), 14 deletions(-) create mode 100644 include/convert.h create mode 100644 libfrog/convert.c
include/convert.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef __CONVERT_H__ +#define __CONVERT_H__ + +extern int64_t cvt_s64 (char *s,int base); +extern int32_t cvt_s32 (char *s,int base); +extern int16_t cvt_s16 (char *s,int base); + +extern uint64_t cvt_u64 (char *s,int base); +extern uint32_t cvt_u32 (char *s,int base); +extern uint16_t cvt_u16 (char *s,int base); + +extern long long cvtnum (size_t blocksize,size_t sectorsize,char *s); +extern void cvtstr (double value,char *str,size_t sz); +extern unsigned long cvttime (char *s); + +extern uid_t uid_from_string (char *user); +extern gid_t gid_from_string (char *group); +extern prid_t prid_from_string (char *project); + +#endif /* __CONVERT_H__ */
include/input.h +1 -14
@@ -22,24 +22,14 @@#include <grp.h> #include <sys/types.h> #include "project.h" +#include "convert.h" #include <stdbool.h> extern char **breakline (char *input,int *count);extern void doneline (char *input,char **vec);extern char *fetchline (void ); -extern int64_t cvt_s64 (char *s,int base); -extern int32_t cvt_s32 (char *s,int base); -extern int16_t cvt_s16 (char *s,int base); - -extern uint64_t cvt_u64 (char *s,int base); -extern uint32_t cvt_u32 (char *s,int base); -extern uint16_t cvt_u16 (char *s,int base); -extern size_t numlen (uint64_t val,size_t base); -extern long long cvtnum (size_t blocksize,size_t sectorsize,char *s); -extern void cvtstr (double value,char *str,size_t sz); -extern unsigned long cvttime (char *s);extern struct timeval tadd (struct timeval t1,struct timeval t2);extern struct timeval tsub (struct timeval t1,struct timeval t2);
@@ -53,9 +43,6 @@ enum {extern void timestr (struct timeval *tv,char *str,size_t sz,int flags); -extern uid_t uid_from_string (char *user); -extern gid_t gid_from_string (char *group); -extern prid_t prid_from_string (char *project);extern bool isdigits_only (const char *str);extern int timespec_from_string (const char *sec,const char *nsec,struct timespec *ts);
libfrog/Makefile +1 -0
@@ -12,6 +12,7 @@ LT_AGE = 0 CFILES = \ avl64.c \ +convert.c \ list_sort.c \ radix-tree.c \ topology.c \
libfrog/convert.c new file +373 -0
373 lines not on this page · raw message
Re: [PATCH 08/12] libfrog: move conversion factors out of libxcmd
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Move all the conversion functions out of libxcmd since they'll be used by scrub, which doesn't have a commandline.
This doesn't actually move anything, it just duplicates it?
-Eric
Re: [PATCH 08/12] libfrog: move conversion factors out of libxcmd
Quoted 7 lines · Eric Sandeen
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Move all the conversion functions out of libxcmd since they'll be used by scrub, which doesn't have a commandline.
This doesn't actually move anything, it just duplicates it?
rrrgh, the libxcmd/input.c changes fell off... :(
Lemme resend.
--D
Quoted 7 lines
-Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 8/12 libfrog: move conversion factors out of libxcmd
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Move all the conversion functions out of libxcmd since they'll be used by scrub, which doesn't have a commandline.
---
v2: actually include all of the patch <cough>
--- include/convert.h | 39 +++++ include/input.h | 15 -- libfrog/Makefile | 1 libfrog/convert.c | 386 +++++++++++++++++++++++++++++++++++++++++++++++++++++ libxcmd/input.c | 375 --------------------------------------------------- quota/Makefile | 4 - spaceman/Makefile | 4 - 7 files changed, 431 insertions(+), 393 deletions(-) create mode 100644 include/convert.h create mode 100644 libfrog/convert.c
include/convert.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (C) 2017 Oracle. All Rights Reserved. +* +* Author: Darrick J. Wong <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef __CONVERT_H__ +#define __CONVERT_H__ + +extern int64_t cvt_s64 (char *s,int base); +extern int32_t cvt_s32 (char *s,int base); +extern int16_t cvt_s16 (char *s,int base); + +extern uint64_t cvt_u64 (char *s,int base); +extern uint32_t cvt_u32 (char *s,int base); +extern uint16_t cvt_u16 (char *s,int base); + +extern long long cvtnum (size_t blocksize,size_t sectorsize,char *s); +extern void cvtstr (double value,char *str,size_t sz); +extern unsigned long cvttime (char *s); + +extern uid_t uid_from_string (char *user); +extern gid_t gid_from_string (char *group); +extern prid_t prid_from_string (char *project); + +#endif /* __CONVERT_H__ */
include/input.h +1 -14
@@ -22,24 +22,14 @@#include <grp.h> #include <sys/types.h> #include "project.h" +#include "convert.h" #include <stdbool.h> extern char **breakline (char *input,int *count);extern void doneline (char *input,char **vec);extern char *fetchline (void ); -extern int64_t cvt_s64 (char *s,int base); -extern int32_t cvt_s32 (char *s,int base); -extern int16_t cvt_s16 (char *s,int base); - -extern uint64_t cvt_u64 (char *s,int base); -extern uint32_t cvt_u32 (char *s,int base); -extern uint16_t cvt_u16 (char *s,int base); -extern size_t numlen (uint64_t val,size_t base); -extern long long cvtnum (size_t blocksize,size_t sectorsize,char *s); -extern void cvtstr (double value,char *str,size_t sz); -extern unsigned long cvttime (char *s);extern struct timeval tadd (struct timeval t1,struct timeval t2);extern struct timeval tsub (struct timeval t1,struct timeval t2);
@@ -53,9 +43,6 @@ enum {extern void timestr (struct timeval *tv,char *str,size_t sz,int flags); -extern uid_t uid_from_string (char *user); -extern gid_t gid_from_string (char *group); -extern prid_t prid_from_string (char *project);extern bool isdigits_only (const char *str);extern int timespec_from_string (const char *sec,const char *nsec,struct timespec *ts);
libfrog/Makefile +1 -0
@@ -12,6 +12,7 @@ LT_AGE = 0 CFILES = \ avl64.c \ +convert.c \ list_sort.c \ radix-tree.c \ topology.c \
libfrog/convert.c new file +386 -0
386 lines not on this page · raw message
libxcmd/input.c +0 -375
387 lines not on this page · raw message
quota/Makefile +2 -2
@@ -14,8 +14,8 @@ CFILES += $(PKG_PLATFORM).c PCFILES = darwin.c freebsd.c irix.c linux.c LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g") -LLDLIBS = $(LIBXCMD) -LTDEPENDENCIES = $(LIBXCMD) +LLDLIBS = $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes)
spaceman/Makefile +2 -2
@@ -9,8 +9,8 @@ LTCOMMAND = xfs_spaceman HFILES = init.h space.h CFILES = init.c file.c prealloc.c trim.c -LLDLIBS = $(LIBXCMD) -LTDEPENDENCIES = $(LIBXCMD) +LLDLIBS = $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes)
PATCH v3 8/12 libfrog: move conversion factors out of libxcmd
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Move all the conversion functions out of libxcmd since they'll be used by scrub, which doesn't have a commandline.
---
v3: fix copyright/licensing statements
v2: actually include all of the patch <cough>
--- include/convert.h | 37 +++++ include/input.h | 15 -- libfrog/Makefile | 1 libfrog/convert.c | 384 +++++++++++++++++++++++++++++++++++++++++++++++++++++ libxcmd/input.c | 375 ---------------------------------------------------- quota/Makefile | 4 - spaceman/Makefile | 4 - 7 files changed, 427 insertions(+), 393 deletions(-) create mode 100644 include/convert.h create mode 100644 libfrog/convert.c
include/convert.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (c) 2000-2005 Silicon Graphics, Inc. +* All Rights Reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef __CONVERT_H__ +#define __CONVERT_H__ + +extern int64_t cvt_s64 (char *s,int base); +extern int32_t cvt_s32 (char *s,int base); +extern int16_t cvt_s16 (char *s,int base); + +extern uint64_t cvt_u64 (char *s,int base); +extern uint32_t cvt_u32 (char *s,int base); +extern uint16_t cvt_u16 (char *s,int base); + +extern long long cvtnum (size_t blocksize,size_t sectorsize,char *s); +extern void cvtstr (double value,char *str,size_t sz); +extern unsigned long cvttime (char *s); + +extern uid_t uid_from_string (char *user); +extern gid_t gid_from_string (char *group); +extern prid_t prid_from_string (char *project); + +#endif /* __CONVERT_H__ */
include/input.h +1 -14
@@ -22,24 +22,14 @@#include <grp.h> #include <sys/types.h> #include "project.h" +#include "convert.h" #include <stdbool.h> extern char **breakline (char *input,int *count);extern void doneline (char *input,char **vec);extern char *fetchline (void ); -extern int64_t cvt_s64 (char *s,int base); -extern int32_t cvt_s32 (char *s,int base); -extern int16_t cvt_s16 (char *s,int base); - -extern uint64_t cvt_u64 (char *s,int base); -extern uint32_t cvt_u32 (char *s,int base); -extern uint16_t cvt_u16 (char *s,int base); -extern size_t numlen (uint64_t val,size_t base); -extern long long cvtnum (size_t blocksize,size_t sectorsize,char *s); -extern void cvtstr (double value,char *str,size_t sz); -extern unsigned long cvttime (char *s);extern struct timeval tadd (struct timeval t1,struct timeval t2);extern struct timeval tsub (struct timeval t1,struct timeval t2);
@@ -53,9 +43,6 @@ enum {extern void timestr (struct timeval *tv,char *str,size_t sz,int flags); -extern uid_t uid_from_string (char *user); -extern gid_t gid_from_string (char *group); -extern prid_t prid_from_string (char *project);extern bool isdigits_only (const char *str);extern int timespec_from_string (const char *sec,const char *nsec,struct timespec *ts);
libfrog/Makefile +1 -0
@@ -12,6 +12,7 @@ LT_AGE = 0 CFILES = \ avl64.c \ +convert.c \ list_sort.c \ radix-tree.c \ topology.c \
libfrog/convert.c new file +384 -0
384 lines not on this page · raw message
libxcmd/input.c +0 -375
387 lines not on this page · raw message
quota/Makefile +2 -2
@@ -14,8 +14,8 @@ CFILES += $(PKG_PLATFORM).c PCFILES = darwin.c freebsd.c irix.c linux.c LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g") -LLDLIBS = $(LIBXCMD) -LTDEPENDENCIES = $(LIBXCMD) +LLDLIBS = $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes)
spaceman/Makefile +2 -2
@@ -9,8 +9,8 @@ LTCOMMAND = xfs_spaceman HFILES = init.h space.h CFILES = init.c file.c prealloc.c trim.c -LLDLIBS = $(LIBXCMD) -LTDEPENDENCIES = $(LIBXCMD) +LLDLIBS = $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes)
PATCH 9/12 libfrog: move paths.c out of libxcmd
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Move the fs_table code into libfrog since it's not really a command.
--- libfrog/Makefile | 10 + libfrog/paths.c | 586 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libfrog/projects.c | 201 ++++++++++++++++++ libxcmd/Makefile | 10 - libxcmd/paths.c | 586 ---------------------------------------------------- libxcmd/projects.c | 201 ------------------ quota/Makefile | 4 spaceman/Makefile | 4 8 files changed, 802 insertions(+), 800 deletions(-) create mode 100644 libfrog/paths.c create mode 100644 libfrog/projects.c delete mode 100644 libxcmd/paths.c delete mode 100644 libxcmd/projects.c
libfrog/Makefile +10 -0
@@ -14,11 +14,21 @@ CFILES = \ avl64.c \ convert.c \ list_sort.c \ +paths.c \ +projects.c \ radix-tree.c \ topology.c \ util.c \ workqueue.c +ifeq ($(HAVE_GETMNTENT),yes) +LCFLAGS += -DHAVE_GETMNTENT +endif + +ifeq ($(HAVE_GETMNTINFO),yes) +LCFLAGS += -DHAVE_GETMNTINFO +endif + default: ltdepend $(LTLIBRARY) include $(BUILDRULES)
libfrog/paths.c new file +586 -0
586 lines not on this page · raw message
libfrog/projects.c new file +201 -0
201 lines not on this page · raw message
libxcmd/Makefile +1 -9
@@ -10,15 +10,7 @@ LT_CURRENT = 0 LT_REVISION = 0 LT_AGE = 0 -CFILES = command.c input.c paths.c projects.c help.c quit.c - -ifeq ($(HAVE_GETMNTENT),yes) -LCFLAGS += -DHAVE_GETMNTENT -endif - -ifeq ($(HAVE_GETMNTINFO),yes) -LCFLAGS += -DHAVE_GETMNTINFO -endif +CFILES = command.c input.c help.c quit.c ifeq ($(ENABLE_READLINE),yes) LCFLAGS += -DENABLE_READLINE
libxcmd/paths.c deleted +0 -586
586 lines not on this page · raw message
libxcmd/projects.c deleted +0 -201
201 lines not on this page · raw message
quota/Makefile +2 -2
@@ -14,8 +14,8 @@ CFILES += $(PKG_PLATFORM).c PCFILES = darwin.c freebsd.c irix.c linux.c LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g") -LLDLIBS = $(LIBXCMD) -LTDEPENDENCIES = $(LIBXCMD) +LLDLIBS = $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes)
spaceman/Makefile +2 -2
@@ -9,8 +9,8 @@ LTCOMMAND = xfs_spaceman HFILES = init.h space.h CFILES = init.c file.c prealloc.c trim.c -LLDLIBS = $(LIBXCMD) -LTDEPENDENCIES = $(LIBXCMD) +LLDLIBS = $(LIBXCMD) $(LIBFROG) +LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG) LLDFLAGS = -static ifeq ($(ENABLE_READLINE),yes)
PATCH 10/12 libfrog: add missing function fs_table_destroy
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Add a function to tear down the fs_table when we're done messing with paths.
--- libfrog/paths.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
libfrog/paths.c +20 -0
@@ -206,6 +206,26 @@ fs_table_insert(return error; } +/* Remove all the cached entries in the fs table. */ +void +fs_table_destroy (void ) +{ +int i; +struct fs_path *fsp; + +for (i =0 , fsp = fs_table; i < fs_count; i++, fsp++) { +free (fsp->fs_name); +free (fsp->fs_dir); +free (fsp->fs_log); +free (fsp->fs_rt); + } + + fs_count =0 ; + xfs_fs_count =0 ; +free (fs_table); + fs_table =NULL ; +} +/* * Table iteration (cursor-based) interfaces */
PATCH 11/12 libhandle: add missing destructor
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Make it so that we can tear down the file descriptor hash table.
--- include/handle.h | 2 ++ libhandle/handle.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)
include/handle.h +2 -0
@@ -50,6 +50,8 @@ extern int parentpaths_by_handle(void *__hanp, size_t __hlen,extern int fssetdm_by_handle (void *__hanp,size_t __hlen,struct fsdmidata *__fsdmi); +void fshandle_destroy (void ); + #ifdef __cplusplus }#endif
libhandle/handle.c +13 -0
@@ -62,6 +62,19 @@ struct fdhash {static struct fdhash *fdhash_head =NULL ; +void +fshandle_destroy (void ) +{ +struct fdhash *nexth; +struct fdhash *h = fdhash_head; + +while (h) { + nexth = h->fnxt; +free (h); + h = nexth; + } +} + int path_to_fshandle( char *path, /* input, path to convert */
PATCH 12/12 xfs_repair: remove old workqueue implementation in favor of libfrog code
In reply to Darrick J. WongFrom: Darrick J. Wong <[email protected]>
Now that we've made a generic workqueue in libfrog, we can remove the implementation in xfs_repair and turn the old functions into do_error wrappers. There are no functional changes in this patch, though some of the names and types have changed.
--- repair/phase3.c | 16 +++---- repair/phase4.c | 26 ++++++----- repair/phase6.c | 4 +- repair/phase7.c | 9 ++-- repair/prefetch.c | 20 ++++---- repair/prefetch.h | 4 +- repair/scan.c | 16 +++---- repair/slab.c | 4 +- repair/threads.c | 125 +++++++---------------------------------------------- repair/threads.h | 38 +++------------- 10 files changed, 74 insertions(+), 188 deletions(-)
repair/phase3.c +8 -8
@@ -66,7 +66,7 @@ process_agi_unlinked(static void process_ag_func ( -work_queue_t *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {
@@ -76,7 +76,7 @@ process_ag_func(*/ wait_for_inode_prefetch (arg);do_log (_ (" - agno = %d\n" ), agno); -process_aginodes (wq->mp, arg, agno,1 ,0 ,1 ); +process_aginodes (wq->wq_ctx, arg, agno,1 ,0 ,1 );blkmap_free_final ();cleanup_inode_prefetch (arg); }
@@ -90,13 +90,13 @@ process_ags(static void do_uncertain_aginodes ( -work_queue_t *wq, -xfs_agnumber_t agno, -void *arg) +struct workqueue *wq, +xfs_agnumber_t agno, +void *arg) { -int *count = arg; +int *count = arg; - *count =process_uncertain_aginodes (wq->mp, agno); + *count =process_uncertain_aginodes (wq->wq_ctx, agno);#ifdef XR_INODE_TRACE fprintf(stderr,
@@ -114,7 +114,7 @@ phase3( {int i, j;int *counts; -work_queue_t wq; +struct workqueue wq;do_log (_ ("Phase 3 - for each AG...\n" ));if (!no_modify)
repair/phase4.c +13 -13
@@ -134,13 +134,13 @@ quota_sb_check(xfs_mount_t *mp)static void process_ag_func ( -work_queue_t *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {wait_for_inode_prefetch (arg);do_log (_ (" - agno = %d\n" ), agno); -process_aginodes (wq->mp, arg, agno,0 ,1 ,0 ); +process_aginodes (wq->wq_ctx, arg, agno,0 ,1 ,0 );blkmap_free_final ();cleanup_inode_prefetch (arg);
@@ -169,23 +169,23 @@ _("unable to finish adding attr/data fork reverse-mapping data for AG %u.\n"),static void check_rmap_btrees ( -work_queue_t *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {int error; - error =rmap_add_fixed_ag_rec (wq->mp, agno); + error =rmap_add_fixed_ag_rec (wq->wq_ctx, agno);if (error)do_error (_ ("unable to add AG %u metadata reverse-mapping data.\n" ), agno); - error =rmap_fold_raw_recs (wq->mp, agno); + error =rmap_fold_raw_recs (wq->wq_ctx, agno);if (error)do_error (_ ("unable to merge AG %u metadata reverse-mapping data.\n" ), agno); - error =rmaps_verify_btree (wq->mp, agno); + error =rmaps_verify_btree (wq->wq_ctx, agno);if (error) do_error( _("%s while checking reverse-mappings"),
@@ -194,13 +194,13 @@ _("%s while checking reverse-mappings"),static void compute_ag_refcounts ( -work_queue_t *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {int error; - error =compute_refcounts (wq->mp, agno); + error =compute_refcounts (wq->wq_ctx, agno);if (error) do_error( _("%s while computing reference count records.\n"),
@@ -209,13 +209,13 @@ _("%s while computing reference count records.\n"),static void process_inode_reflink_flags ( -struct work_queue *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {int error; - error =fix_inode_reflink_flags (wq->mp, agno); + error =fix_inode_reflink_flags (wq->wq_ctx, agno);if (error) do_error( _("%s while fixing inode reflink flags.\n"),
@@ -224,13 +224,13 @@ _("%s while fixing inode reflink flags.\n"),static void check_refcount_btrees ( -work_queue_t *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {int error; - error =check_refcounts (wq->mp, agno); + error =check_refcounts (wq->wq_ctx, agno);if (error) do_error( _("%s while checking reference counts"),
@@ -241,7 +241,7 @@ static voidprocess_rmap_data ( struct xfs_mount *mp) { -struct work_queue wq; +struct workqueue wq;xfs_agnumber_t i;if (!rmap_needs_work (mp))
repair/phase6.c +2 -2
@@ -3125,7 +3125,7 @@ check_for_orphaned_inodes(static void traverse_function ( -work_queue_t *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {
@@ -3154,7 +3154,7 @@ traverse_function(for (i =0 ; i <XFS_INODES_PER_CHUNK ; i++) {if (inode_isadir (irec, i)) -process_dir_inode (wq->mp, agno, irec, i); +process_dir_inode (wq->wq_ctx, agno, irec, i); } }cleanup_inode_prefetch (pf_args);
repair/phase7.c +5 -4
@@ -98,10 +98,11 @@ update_inode_nlinks(*/ static void do_link_updates ( -struct work_queue *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) { +struct xfs_mount *mp = wq->wq_ctx;ino_tree_node_t *irec;int j;uint32_t nrefs;
@@ -120,8 +121,8 @@ do_link_updates(ASSERT (no_modify || nrefs >0 );if (get_inode_disk_nlinks (irec, j) != nrefs) -update_inode_nlinks (wq->mp, -XFS_AGINO_TO_INO (wq->mp, agno, +update_inode_nlinks (wq->wq_ctx, +XFS_AGINO_TO_INO (mp, agno, irec->ino_startnum + j), nrefs); }
@@ -135,7 +136,7 @@ phase7( struct xfs_mount *mp, int scan_threads) { -struct work_queue wq; +struct workqueue wq;int agno;if (!no_modify)
repair/prefetch.c +10 -10
@@ -943,11 +943,11 @@ start_inode_prefetch(*/ static void prefetch_ag_range ( -struct work_queue *work, +struct workqueue *work,xfs_agnumber_t start_ag,xfs_agnumber_t end_ag,bool dirs_only, -void (*func)(struct work_queue *, +void (*func)(struct workqueue *,xfs_agnumber_t ,void *)) {int i;
@@ -967,12 +967,12 @@ struct pf_work_args {xfs_agnumber_t start_ag;xfs_agnumber_t end_ag;bool dirs_only; -void (*func)(struct work_queue *,xfs_agnumber_t ,void *); +void (*func)(struct workqueue *,xfs_agnumber_t ,void *); };static void prefetch_ag_range_work ( -struct work_queue *work, +struct workqueue *work,xfs_agnumber_t unused,void *args) {
@@ -991,14 +991,14 @@ voiddo_inode_prefetch ( struct xfs_mount *mp, int stride, - void (*func)(struct work_queue *, + void (*func)(struct workqueue *, xfs_agnumber_t,void *), bool check_cache, bool dirs_only) { int i; -struct work_queue queue; -struct work_queue *queues; +struct workqueue queue; +struct workqueue *queues;int queues_started =0 ;/*
@@ -1008,7 +1008,7 @@ do_inode_prefetch(* CPU to maximise parallelism of the queue to be processed. */ if (check_cache && !libxfs_bcache_overflowed ()) { - queue.mp = mp; + queue.wq_ctx = mp;create_work_queue (&queue, mp,libxfs_nproc ());for (i =0 ; i < mp->m_sb.sb_agcount; i++)queue_work (&queue, func, i,NULL );
@@ -1021,7 +1021,7 @@ do_inode_prefetch(* directly after each AG is queued. */ if (!stride) { - queue.mp = mp; + queue.wq_ctx = mp;prefetch_ag_range (&queue,0 , mp->m_sb.sb_agcount, dirs_only, func);return ;
@@ -1030,7 +1030,7 @@ do_inode_prefetch(/* * create one worker thread for each segment of the volume */ - queues =malloc (thread_count *sizeof (work_queue_t)); + queues =malloc (thread_count *sizeof (struct workqueue ));for (i =0 ; i < thread_count; i++) {struct pf_work_args *wargs;
repair/prefetch.h +2 -2
@@ -4,7 +4,7 @@#include <semaphore.h> #include "incore.h" -struct work_queue ; +struct workqueue ;extern int do_prefetch;
@@ -45,7 +45,7 @@ voiddo_inode_prefetch ( struct xfs_mount *mp, int stride, - void (*func)(struct work_queue *, + void (*func)(struct workqueue *, xfs_agnumber_t,void *), bool check_cache, bool dirs_only);
repair/scan.c +8 -8
@@ -2342,7 +2342,7 @@ validate_agi(*/ static void scan_ag ( -work_queue_t *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {
@@ -2504,13 +2504,13 @@ scan_ags( struct xfs_mount *mp, int scan_threads) { -struct aghdr_cnts *agcnts; -uint64_t fdblocks =0 ; -uint64_t icount =0 ; -uint64_t ifreecount =0 ; -uint64_t usedblocks =0 ; -xfs_agnumber_t i; -work_queue_t wq; +struct aghdr_cnts *agcnts; +uint64_t fdblocks =0 ; +uint64_t icount =0 ; +uint64_t ifreecount =0 ; +uint64_t usedblocks =0 ; +xfs_agnumber_t i; +struct workqueue wq; agcnts =malloc (mp->m_sb.sb_agcount *sizeof (*agcnts));if (!agcnts) {
repair/slab.c +2 -2
@@ -211,7 +211,7 @@ struct qsort_slab {static void qsort_slab_helper ( -struct work_queue *wq, +struct workqueue *wq,xfs_agnumber_t agno,void *arg) {
@@ -231,7 +231,7 @@ qsort_slab( struct xfs_slab *slab, int (*compare_fn)(const void *, const void *)) { - struct work_queue wq; + struct workqueue wq;struct xfs_slab_hdr *hdr;struct qsort_slab *qs;
repair/threads.c +16 -109
151 lines not on this page · raw message
repair/threads.h +8 -30
@@ -1,47 +1,25 @@#ifndef _XFS_REPAIR_THREADS_H_#define _XFS_REPAIR_THREADS_H_ -void thread_init (void ); - -struct work_queue ; - -typedef void work_func_t (struct work_queue *,xfs_agnumber_t ,void *); +#include "workqueue.h" -typedef struct work_item { -struct work_item *next; -work_func_t *function; -struct work_queue *queue; -xfs_agnumber_t agno; -void *arg; -}work_item_t ; - -typedef struct work_queue { -work_item_t *next_item; -work_item_t *last_item; -int item_count; -int thread_count; -pthread_t *threads; -xfs_mount_t *mp; -pthread_mutex_t lock; -pthread_cond_t wakeup; -int terminate; -}work_queue_t ; +void thread_init (void );void create_work_queue ( -work_queue_t *wq, -xfs_mount_t *mp, -int nworkers); +struct workqueue *wq, +struct xfs_mount *mp, +unsigned int nworkers);void queue_work ( -work_queue_t *wq, -work_func_t func, +struct workqueue *wq, +workqueue_func_t func,xfs_agnumber_t agno,void *arg);void destroy_work_queue ( -work_queue_t *wq); +struct workqueue *wq);#endif /* _XFS_REPAIR_THREADS_H_ */
Ok, for latest versions of all this:
Quoted 16 lines · Darrick J. Wong
Hi all,
This patch series refactors miscellaneous data structures and runtime support code out of libxfs and libxcmd into a new library to contain all of the funny random other gunk ("libfrog") that doesn't fit anywhere else. Initially, libfrog will contain routines for bit manipulation, device topology, threaded workqueues, an avl tree, and file path detection. Existing programs are modified to pull from libfrog; the future
xfs_scrubprogram will also take advantage of it.This whole mess sits atop the libxfs-4.15-sync branch; see the djwong-devel branch in my repo[1] for something pullable.
--D
[1] https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=djwong-devel