From f7f0b104bcf3827ffe9025a2347f0147c2103809 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Mon, 23 Nov 2020 13:26:22 +1100 Subject: [PATCH] LU-14289 ptlrpc: move heap.c from libcfs to ptlrpc cfs_binheap is only used by the nrs code in ptlrpc, so move it out of libcfs to the one place it is used. Test-Parameters: trivial Signed-off-by: Mr NeilBrown Change-Id: I4687d4de0a83e0ce106d4f4cfd5ea95faef27dfc Reviewed-on: https://review.whamcloud.com/41129 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/Makefile.am | 1 - libcfs/include/libcfs/libcfs.h | 1 - libcfs/libcfs/Makefile.in | 2 +- libcfs/libcfs/autoMakefile.am | 2 +- lustre/include/lustre_nrs.h | 10 ++++++++++ lustre/ptlrpc/Makefile.in | 4 ++-- {libcfs/libcfs => lustre/ptlrpc}/heap.c | 14 ++++++-------- .../libcfs/libcfs_heap.h => lustre/ptlrpc/heap.h | 17 +---------------- lustre/ptlrpc/ptlrpc_internal.h | 1 + 9 files changed, 22 insertions(+), 30 deletions(-) rename {libcfs/libcfs => lustre/ptlrpc}/heap.c (96%) rename libcfs/include/libcfs/libcfs_heap.h => lustre/ptlrpc/heap.h (91%) diff --git a/libcfs/include/libcfs/Makefile.am b/libcfs/include/libcfs/Makefile.am index 66d1f73..1e65107 100644 --- a/libcfs/include/libcfs/Makefile.am +++ b/libcfs/include/libcfs/Makefile.am @@ -14,7 +14,6 @@ EXTRA_DIST = \ libcfs_debug.h \ libcfs_fail.h \ libcfs_hash.h \ - libcfs_heap.h \ libcfs_private.h \ libcfs_string.h \ libcfs_workitem.h diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index 2bbc8206..df7234d 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -54,7 +54,6 @@ #include #include #include -#include #include #include "curproc.h" diff --git a/libcfs/libcfs/Makefile.in b/libcfs/libcfs/Makefile.in index f8e645e..3587ba6 100644 --- a/libcfs/libcfs/Makefile.in +++ b/libcfs/libcfs/Makefile.in @@ -16,7 +16,7 @@ libcfs-crypto-objs := $(addprefix crypto/,$(libcfs-crypto-objs)) libcfs-objs-$(CONFIG_SMP) = libcfs_cpu.o libcfs-all-objs := debug.o fail.o module.o tracefile.o \ - libcfs_string.o hash.o heap.o \ + libcfs_string.o hash.o \ workitem.o \ libcfs_mem.o libcfs_lock.o \ linux-crypto.o linux-crypto-adler.o \ diff --git a/libcfs/libcfs/autoMakefile.am b/libcfs/libcfs/autoMakefile.am index 7d6553c..d465984 100644 --- a/libcfs/libcfs/autoMakefile.am +++ b/libcfs/libcfs/autoMakefile.am @@ -60,5 +60,5 @@ endif # MODULES MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux/*.o libcfs crypto/*.o EXTRA_DIST := $(libcfs-all-objs:%.o=%.c) tracefile.h \ workitem.c fail.c libcfs_cpu.c \ - heap.c libcfs_mem.c libcfs_lock.c \ + libcfs_mem.c libcfs_lock.c \ linux-crypto.h diff --git a/lustre/include/lustre_nrs.h b/lustre/include/lustre_nrs.h index 8223c08..4f08eab 100644 --- a/lustre/include/lustre_nrs.h +++ b/lustre/include/lustre_nrs.h @@ -672,6 +672,16 @@ enum { }; #include +/** + * Binary heap node. + * + * Objects of this type are embedded into objects of the ordered set that is to + * be maintained by a \e struct cfs_binheap instance. + */ +struct cfs_binheap_node { + /** Index into the binary tree */ + unsigned int chn_index; +}; #ifdef HAVE_SERVER_SUPPORT #include #include diff --git a/lustre/ptlrpc/Makefile.in b/lustre/ptlrpc/Makefile.in index aeea155..6eee21f 100644 --- a/lustre/ptlrpc/Makefile.in +++ b/lustre/ptlrpc/Makefile.in @@ -22,7 +22,7 @@ ptlrpc_objs += events.o ptlrpc_module.o service.o pinger.o ptlrpc_objs += llog_net.o llog_client.o llog_server.o import.o ptlrpcd.o ptlrpc_objs += pers.o lproc_ptlrpc.o wiretest.o layout.o ptlrpc_objs += sec.o sec_ctx.o sec_bulk.o sec_gc.o sec_config.o sec_lproc.o -ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o nrs_delay.o +ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o nrs_delay.o heap.o ptlrpc_objs += errno.o nrs_server_objs := nrs_crr.o nrs_orr.o nrs_tbf.o @@ -54,7 +54,7 @@ barrier.c: @LUSTRE@/target/barrier.c ln -sf $< $@ EXTRA_DIST := $(ptlrpc_objs:.o=.c) ptlrpc_internal.h -EXTRA_DIST += $(nodemap_objs:.o=.c) nodemap_internal.h +EXTRA_DIST += $(nodemap_objs:.o=.c) nodemap_internal.h heap.h EXTRA_DIST += $(nrs_server_objs:.o=.c) EXTRA_PRE_CFLAGS := -I@LUSTRE@/ldlm -I@LUSTRE@/target diff --git a/libcfs/libcfs/heap.c b/lustre/ptlrpc/heap.c similarity index 96% rename from libcfs/libcfs/heap.c rename to lustre/ptlrpc/heap.c index d625cbc..ddeca8b 100644 --- a/libcfs/libcfs/heap.c +++ b/lustre/ptlrpc/heap.c @@ -13,10 +13,6 @@ * GNU General Public License version 2 for more details. A copy is * included in the COPYING file that accompanied this code. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * * GPL HEADER END */ /* @@ -36,6 +32,8 @@ #define DEBUG_SUBSYSTEM S_LNET #include +#include +#include "heap.h" #define CBH_ALLOC(ptr, h) \ do { \ @@ -51,7 +49,7 @@ do { \ if ((h)->cbh_flags & CBH_FLAG_ATOMIC_GROW) \ LIBCFS_ALLOC_ATOMIC((ptr), CBH_NOB); \ else \ - LIBCFS_ALLOC((ptr), CBH_NOB); \ + LIBCFS_ALLOC((ptr), CBH_NOB); \ } \ } while (0) @@ -165,7 +163,7 @@ cfs_binheap_grow(struct cfs_binheap *h) */ struct cfs_binheap * cfs_binheap_create(struct cfs_binheap_ops *ops, unsigned int flags, - unsigned count, void *arg, struct cfs_cpt_table *cptab, + unsigned int count, void *arg, struct cfs_cpt_table *cptab, int cptid) { struct cfs_binheap *h; @@ -274,8 +272,8 @@ cfs_binheap_pointer(struct cfs_binheap *h, unsigned int idx) return &(h->cbh_elements2[idx >> CBH_SHIFT][idx & CBH_MASK]); idx -= CBH_SIZE * CBH_SIZE; - return &(h->cbh_elements3[idx >> (2 * CBH_SHIFT)]\ - [(idx >> CBH_SHIFT) & CBH_MASK]\ + return &(h->cbh_elements3[idx >> (2 * CBH_SHIFT)] + [(idx >> CBH_SHIFT) & CBH_MASK] [idx & CBH_MASK]); } diff --git a/libcfs/include/libcfs/libcfs_heap.h b/lustre/ptlrpc/heap.h similarity index 91% rename from libcfs/include/libcfs/libcfs_heap.h rename to lustre/ptlrpc/heap.h index 239e9e0..36899a8 100644 --- a/libcfs/include/libcfs/libcfs_heap.h +++ b/lustre/ptlrpc/heap.h @@ -13,10 +13,6 @@ * GNU General Public License version 2 for more details. A copy is * included in the COPYING file that accompanied this code. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * * GPL HEADER END */ /* @@ -57,17 +53,6 @@ * @{ */ -/** - * Binary heap node. - * - * Objects of this type are embedded into objects of the ordered set that is to - * be maintained by a \e struct cfs_binheap instance. - */ -struct cfs_binheap_node { - /** Index into the binary tree */ - unsigned int chn_index; -}; - #define CBH_SHIFT 9 #define CBH_SIZE (1 << CBH_SHIFT) /* # ptrs per level */ #define CBH_MASK (CBH_SIZE - 1) @@ -162,7 +147,7 @@ struct cfs_binheap { void cfs_binheap_destroy(struct cfs_binheap *h); struct cfs_binheap * cfs_binheap_create(struct cfs_binheap_ops *ops, unsigned int flags, - unsigned count, void *arg, struct cfs_cpt_table *cptab, + unsigned int count, void *arg, struct cfs_cpt_table *cptab, int cptid); struct cfs_binheap_node * cfs_binheap_find(struct cfs_binheap *h, unsigned int idx); diff --git a/lustre/ptlrpc/ptlrpc_internal.h b/lustre/ptlrpc/ptlrpc_internal.h index c702767..04cbabf 100644 --- a/lustre/ptlrpc/ptlrpc_internal.h +++ b/lustre/ptlrpc/ptlrpc_internal.h @@ -36,6 +36,7 @@ #define PTLRPC_INTERNAL_H #include "../ldlm/ldlm_internal.h" +#include "heap.h" struct ldlm_namespace; struct obd_import; -- 1.8.3.1