Whamcloud - gitweb
b=19856
authornathan <nathan>
Tue, 28 Jul 2009 19:26:47 +0000 (19:26 +0000)
committernathan <nathan>
Tue, 28 Jul 2009 19:26:47 +0000 (19:26 +0000)
i=adilger
i=rread
LustreNetLink (LNL) kernel<->userspace communications path
HSM copytool llapi based on lnl

30 files changed:
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/darwin/libcfs.h
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/linux/libcfs.h
libcfs/include/libcfs/posix/Makefile.am
libcfs/include/libcfs/posix/libcfs.h
libcfs/include/libcfs/winnt/libcfs.h
libcfs/libcfs/Makefile.in
libcfs/libcfs/autoMakefile.am
libcfs/libcfs/linux/Makefile.am
libcfs/libcfs/ulinux/.cvsignore [new file with mode: 0644]
lustre/autoconf/lustre-core.m4
lustre/include/lprocfs_status.h
lustre/include/lustre/liblustreapi.h
lustre/include/lustre/lustre_idl.h
lustre/include/lustre/lustre_user.h
lustre/include/lustre_disk.h
lustre/include/lustre_lib.h
lustre/liblustre/tests/sanity.c
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_request.c
lustre/mgs/mgs_llog.c
lustre/obdclass/genops.c
lustre/ptlrpc/pack_generic.c
lustre/tests/Makefile.am
lustre/tests/sanity.sh
lustre/utils/Makefile.am
lustre/utils/liblustreapi.c

index a78f408..a1c72d3 100644 (file)
@@ -617,6 +617,7 @@ libcfs/include/libcfs/util/Makefile
 libcfs/libcfs/Makefile
 libcfs/libcfs/autoMakefile
 libcfs/libcfs/linux/Makefile
 libcfs/libcfs/Makefile
 libcfs/libcfs/autoMakefile
 libcfs/libcfs/linux/Makefile
+libcfs/libcfs/ulinux/Makefile
 libcfs/libcfs/posix/Makefile
 libcfs/libcfs/util/Makefile
 ])
 libcfs/libcfs/posix/Makefile
 libcfs/libcfs/util/Makefile
 ])
index 7b1959e..b8e5907 100644 (file)
@@ -9,4 +9,5 @@ EXTRA_DIST := curproc.h libcfs_private.h libcfs.h list.h lltrace.h \
                user-tcpip.h user-bitops.h bitmap.h \
                libcfs_prim.h libcfs_time.h libcfs_hash.h \
                libcfs_debug.h libcfsutil.h libcfs_ioctl.h \
                user-tcpip.h user-bitops.h bitmap.h \
                libcfs_prim.h libcfs_time.h libcfs_hash.h \
                libcfs_debug.h libcfsutil.h libcfs_ioctl.h \
-               libcfs_pack.h libcfs_unpack.h libcfs_string.h
+               libcfs_pack.h libcfs_unpack.h libcfs_string.h \
+               libcfs_kernelcomm.h
index ee7b181..92a4a16 100644 (file)
@@ -143,26 +143,26 @@ typedef unsigned long long cycles_t;
  * "continously".
  */
 enum {
  * "continously".
  */
 enum {
-       CDD_MAGIC1 = 0x02128506,
-       CDD_MAGIC2 = 0x42424242
+        CDD_MAGIC1 = 0x02128506,
+        CDD_MAGIC2 = 0x42424242
 };
 
 struct cfs_debug_data {
 };
 
 struct cfs_debug_data {
-       unsigned int           magic1;
-       struct cfs_debug_data *parent;
-       int                    nesting_level;
-       unsigned int           magic2;
+        unsigned int           magic1;
+        struct cfs_debug_data *parent;
+        int                    nesting_level;
+        unsigned int           magic2;
 };
 
 void __entry_nesting(struct cfs_debug_data *child);
 void __exit_nesting(struct cfs_debug_data *child);
 unsigned int __current_nesting_level(void);
 
 };
 
 void __entry_nesting(struct cfs_debug_data *child);
 void __exit_nesting(struct cfs_debug_data *child);
 unsigned int __current_nesting_level(void);
 
-#define ENTRY_NESTING                                          \
-struct cfs_debug_data __cdd = { .magic1        = CDD_MAGIC1,   \
-                               .parent        = NULL,          \
-                                .nesting_level = 0,            \
-                                .magic2        = CDD_MAGIC2 }; \
+#define ENTRY_NESTING                                           \
+struct cfs_debug_data __cdd = { .magic1        = CDD_MAGIC1,    \
+                                .parent        = NULL,          \
+                                .nesting_level = 0,             \
+                                .magic2        = CDD_MAGIC2 };  \
 __entry_nesting(&__cdd);
 
 #define EXIT_NESTING __exit_nesting(&__cdd)
 __entry_nesting(&__cdd);
 
 #define EXIT_NESTING __exit_nesting(&__cdd)
index 598276f..f8b0a82 100644 (file)
@@ -296,6 +296,7 @@ int cfs_univ2oflags(int flags);
 #include <libcfs/libcfs_prim.h>
 #include <libcfs/libcfs_time.h>
 #include <libcfs/libcfs_string.h>
 #include <libcfs/libcfs_prim.h>
 #include <libcfs/libcfs_time.h>
 #include <libcfs/libcfs_string.h>
+#include <libcfs/libcfs_kernelcomm.h>
 
 /* container_of depends on "likely" which is defined in libcfs_private.h */
 static inline void *__container_of(void *ptr, unsigned long shift)
 
 /* container_of depends on "likely" which is defined in libcfs_private.h */
 static inline void *__container_of(void *ptr, unsigned long shift)
index 6f0a9e8..39da4ca 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef __KERNEL__
 #error This include is only for kernel use.
 
 #ifndef __KERNEL__
 #error This include is only for kernel use.
-#endif 
+#endif
 
 #ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
 
 #ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
index feba1d5..3aca75b 100644 (file)
@@ -1 +1 @@
-EXTRA_DIST := libcfs.h posix-wordsize.h posix-types.h
+EXTRA_DIST := libcfs.h posix-wordsize.h posix-types.h posix-kernelcomm.h
index 37072e0..b204213 100644 (file)
 #include <libcfs/user-tcpip.h>
 #include <libcfs/posix/posix-wordsize.h>
 #include <libcfs/user-bitops.h>
 #include <libcfs/user-tcpip.h>
 #include <libcfs/posix/posix-wordsize.h>
 #include <libcfs/user-bitops.h>
+#include <libcfs/posix/posix-kernelcomm.h>
 
 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
 typedef unsigned long long cycles_t;
 
 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
 typedef unsigned long long cycles_t;
@@ -308,17 +309,17 @@ struct radix_tree_node {
         void *item;
 };
 
         void *item;
 };
 
-#define RADIX_TREE_INIT(mask)  {               \
+#define RADIX_TREE_INIT(mask)   {               \
                 NOT_IMPLEMENTED                 \
 }
 
 #define RADIX_TREE(name, mask) \
                 NOT_IMPLEMENTED                 \
 }
 
 #define RADIX_TREE(name, mask) \
-       struct radix_tree_root name = RADIX_TREE_INIT(mask)
+        struct radix_tree_root name = RADIX_TREE_INIT(mask)
 
 
 
 
-#define INIT_RADIX_TREE(root, mask)                                    \
-do {                                                                   \
-       CFS_INIT_LIST_HEAD(&((struct radix_tree_root *)root)->list);    \
+#define INIT_RADIX_TREE(root, mask)                                     \
+do {                                                                    \
+        CFS_INIT_LIST_HEAD(&((struct radix_tree_root *)root)->list);    \
         ((struct radix_tree_root *)root)->rnode = NULL;                 \
 } while (0)
 
         ((struct radix_tree_root *)root)->rnode = NULL;                 \
 } while (0)
 
index cfff406..0423fe9 100644 (file)
 #ifdef __KERNEL__
 
 enum {
 #ifdef __KERNEL__
 
 enum {
-       /* if you change this, update darwin-util.c:cfs_stack_trace_fill() */
-       CFS_STACK_TRACE_DEPTH = 16
+        /* if you change this, update darwin-util.c:cfs_stack_trace_fill() */
+        CFS_STACK_TRACE_DEPTH = 16
 };
 
 struct cfs_stack_trace {
 };
 
 struct cfs_stack_trace {
-       void *frame[CFS_STACK_TRACE_DEPTH];
+        void *frame[CFS_STACK_TRACE_DEPTH];
 };
 
 static inline __u32 query_stack_size()
 };
 
 static inline __u32 query_stack_size()
index d106b09..96a3393 100644 (file)
@@ -4,7 +4,7 @@ libcfs-linux-objs := linux-tracefile.o linux-debug.o
 libcfs-linux-objs += linux-prim.o linux-mem.o
 libcfs-linux-objs += linux-fs.o linux-sync.o linux-tcpip.o
 libcfs-linux-objs += linux-lwt.o linux-proc.o linux-curproc.o
 libcfs-linux-objs += linux-prim.o linux-mem.o
 libcfs-linux-objs += linux-fs.o linux-sync.o linux-tcpip.o
 libcfs-linux-objs += linux-lwt.o linux-proc.o linux-curproc.o
-libcfs-linux-objs += linux-utils.o linux-module.o
+libcfs-linux-objs += linux-utils.o linux-module.o linux-kernelcomm.o
 
 ifeq ($(PATCHLEVEL),6)
 libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
 
 ifeq ($(PATCHLEVEL),6)
 libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
index 92d1618..7f12636 100644 (file)
@@ -34,7 +34,7 @@
 # Lustre is a trademark of Sun Microsystems, Inc.
 #
 
 # Lustre is a trademark of Sun Microsystems, Inc.
 #
 
-SUBDIRS := linux util posix
+SUBDIRS := linux util posix ulinux
 if DARWIN
 SUBDIRS += darwin
 endif
 if DARWIN
 SUBDIRS += darwin
 endif
@@ -42,7 +42,7 @@ DIST_SUBDIRS := $(SUBDIRS)
 
 if LIBLUSTRE
 noinst_LIBRARIES= libcfs.a
 
 if LIBLUSTRE
 noinst_LIBRARIES= libcfs.a
-libcfs_a_SOURCES= posix/posix-debug.c user-prim.c user-lock.c user-tcpip.c user-bitops.c user-mem.c
+libcfs_a_SOURCES= posix/posix-debug.c user-prim.c user-lock.c user-tcpip.c user-bitops.c user-mem.c ulinux/ulinux-kernelcomm.c
 libcfs_a_CPPFLAGS = $(LLCPPFLAGS)
 libcfs_a_CFLAGS = $(LLCFLAGS)
 endif
 libcfs_a_CPPFLAGS = $(LLCPPFLAGS)
 libcfs_a_CFLAGS = $(LLCFLAGS)
 endif
@@ -66,7 +66,8 @@ nodist_libcfs_SOURCES := darwin/darwin-sync.c darwin/darwin-mem.c     \
        darwin/darwin-tcpip.c darwin/darwin-utils.c                     \
        darwin/darwin-debug.c darwin/darwin-proc.c                      \
        darwin/darwin-tracefile.c darwin/darwin-module.c                \
        darwin/darwin-tcpip.c darwin/darwin-utils.c                     \
        darwin/darwin-debug.c darwin/darwin-proc.c                      \
        darwin/darwin-tracefile.c darwin/darwin-module.c                \
-       posix/posix-debug.c module.c tracefile.c nidstrings.c watchdog.c
+       posix/posix-debug.c module.c tracefile.c nidstrings.c watchdog.c \
+       ulinux/ulinux-kernelcomm.c
 
 libcfs_CFLAGS := $(EXTRA_KCFLAGS)
 libcfs_LDFLAGS := $(EXTRA_KLDFLAGS)
 
 libcfs_CFLAGS := $(EXTRA_KCFLAGS)
 libcfs_LDFLAGS := $(EXTRA_KLDFLAGS)
index 8bf35cc..43d0581 100644 (file)
@@ -1,4 +1,5 @@
 EXTRA_DIST := linux-debug.c linux-lwt.c linux-prim.c linux-tracefile.c \
        linux-fs.c linux-mem.c linux-proc.c linux-utils.c linux-lock.c  \
 EXTRA_DIST := linux-debug.c linux-lwt.c linux-prim.c linux-tracefile.c \
        linux-fs.c linux-mem.c linux-proc.c linux-utils.c linux-lock.c  \
-       linux-module.c linux-sync.c linux-curproc.c linux-tcpip.c
+       linux-module.c linux-sync.c linux-curproc.c linux-tcpip.c \
+       linux-kernelcomm.c
 
 
diff --git a/libcfs/libcfs/ulinux/.cvsignore b/libcfs/libcfs/ulinux/.cvsignore
new file mode 100644 (file)
index 0000000..282522d
--- /dev/null
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
index 7f634ec..15fbe17 100644 (file)
@@ -1636,6 +1636,7 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_PERCPU_COUNTER
          LC_QUOTA64
          LC_4ARGS_VFS_SYMLINK
          LC_PERCPU_COUNTER
          LC_QUOTA64
          LC_4ARGS_VFS_SYMLINK
+         LC_NETLINK
 
          # does the kernel have VFS intent patches?
          LC_VFS_INTENT_PATCHES
 
          # does the kernel have VFS intent patches?
          LC_VFS_INTENT_PATCHES
@@ -2013,6 +2014,26 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
 ])
 
 #
+# LC_NETLINK
+#
+# If we have netlink.h
+#
+AC_DEFUN([LC_NETLINK],
+[LB_CHECK_FILE([$LINUX/include/net/netlink.h],[
+        AC_MSG_CHECKING([if netlink.h can be compiled])
+        LB_LINUX_TRY_COMPILE([
+                #include <net/netlink.h>
+        ],[],[
+                AC_MSG_RESULT([yes])
+                AC_DEFINE(HAVE_NETLINK, 1, [net/netlink.h found])
+        ],[
+                AC_MSG_RESULT([no])
+        ])
+],
+[])
+])
+
+#
 # LC_CONFIGURE
 #
 # other configure checks
 # LC_CONFIGURE
 #
 # other configure checks
index 9a35643..15c590e 100644 (file)
@@ -190,6 +190,9 @@ struct lprocfs_stats {
         struct lprocfs_percpu *ls_percpu[0];
 };
 
         struct lprocfs_percpu *ls_percpu[0];
 };
 
+#define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
+
+/* Pack all opcodes down into a single monotonically increasing index */
 static inline int opcode_offset(__u32 opc) {
         if (opc < OST_LAST_OPC) {
                  /* OST opcode */
 static inline int opcode_offset(__u32 opc) {
         if (opc < OST_LAST_OPC) {
                  /* OST opcode */
@@ -197,75 +200,75 @@ static inline int opcode_offset(__u32 opc) {
         } else if (opc < MDS_LAST_OPC) {
                 /* MDS opcode */
                 return (opc - MDS_FIRST_OPC +
         } else if (opc < MDS_LAST_OPC) {
                 /* MDS opcode */
                 return (opc - MDS_FIRST_OPC +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(OST));
         } else if (opc < LDLM_LAST_OPC) {
                 /* LDLM Opcode */
                 return (opc - LDLM_FIRST_OPC +
         } else if (opc < LDLM_LAST_OPC) {
                 /* LDLM Opcode */
                 return (opc - LDLM_FIRST_OPC +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else if (opc < MGS_LAST_OPC) {
                 /* MGS Opcode */
                 return (opc - MGS_FIRST_OPC +
         } else if (opc < MGS_LAST_OPC) {
                 /* MGS Opcode */
                 return (opc - MGS_FIRST_OPC +
-                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(LDLM) +
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else if (opc < OBD_LAST_OPC) {
                 /* OBD Ping */
                 return (opc - OBD_FIRST_OPC +
         } else if (opc < OBD_LAST_OPC) {
                 /* OBD Ping */
                 return (opc - OBD_FIRST_OPC +
-                        (MGS_LAST_OPC - MGS_FIRST_OPC) +
-                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(MGS) +
+                        OPC_RANGE(LDLM) +
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else if (opc < LLOG_LAST_OPC) {
                 /* LLOG Opcode */
                 return (opc - LLOG_FIRST_OPC +
         } else if (opc < LLOG_LAST_OPC) {
                 /* LLOG Opcode */
                 return (opc - LLOG_FIRST_OPC +
-                        (OBD_LAST_OPC - OBD_FIRST_OPC) +
-                        (MGS_LAST_OPC - MGS_FIRST_OPC) +
-                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(OBD) +
+                        OPC_RANGE(MGS) +
+                        OPC_RANGE(LDLM) +
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else if (opc < QUOTA_LAST_OPC) {
                 /* LQUOTA Opcode */
                 return (opc - QUOTA_FIRST_OPC +
         } else if (opc < QUOTA_LAST_OPC) {
                 /* LQUOTA Opcode */
                 return (opc - QUOTA_FIRST_OPC +
-                        (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
-                        (OBD_LAST_OPC - OBD_FIRST_OPC) +
-                        (MGS_LAST_OPC - MGS_FIRST_OPC) +
-                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(LLOG) +
+                        OPC_RANGE(OBD) +
+                        OPC_RANGE(MGS) +
+                        OPC_RANGE(LDLM) +
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else if (opc < SEQ_LAST_OPC) {
                 /* SEQ opcode */
                 return (opc - SEQ_FIRST_OPC +
         } else if (opc < SEQ_LAST_OPC) {
                 /* SEQ opcode */
                 return (opc - SEQ_FIRST_OPC +
-                        (QUOTA_LAST_OPC- QUOTA_FIRST_OPC) +
-                        (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
-                        (OBD_LAST_OPC - OBD_FIRST_OPC) +
-                        (MGS_LAST_OPC - MGS_FIRST_OPC) +
-                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(QUOTA) +
+                        OPC_RANGE(LLOG) +
+                        OPC_RANGE(OBD) +
+                        OPC_RANGE(MGS) +
+                        OPC_RANGE(LDLM) +
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else if (opc < SEC_LAST_OPC) {
                 /* SEC opcode */
                 return (opc - SEC_FIRST_OPC +
         } else if (opc < SEC_LAST_OPC) {
                 /* SEC opcode */
                 return (opc - SEC_FIRST_OPC +
-                        (SEQ_LAST_OPC - SEQ_FIRST_OPC) +
-                        (QUOTA_LAST_OPC- QUOTA_FIRST_OPC) +
-                        (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
-                        (OBD_LAST_OPC - OBD_FIRST_OPC) +
-                        (MGS_LAST_OPC - MGS_FIRST_OPC) +
-                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(SEQ) +
+                        OPC_RANGE(QUOTA) +
+                        OPC_RANGE(LLOG) +
+                        OPC_RANGE(OBD) +
+                        OPC_RANGE(MGS) +
+                        OPC_RANGE(LDLM) +
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else if (opc < FLD_LAST_OPC) {
                 /* FLD opcode */
                  return (opc - FLD_FIRST_OPC +
         } else if (opc < FLD_LAST_OPC) {
                 /* FLD opcode */
                  return (opc - FLD_FIRST_OPC +
-                        (SEC_LAST_OPC - SEC_FIRST_OPC) +
-                        (SEQ_LAST_OPC - SEQ_FIRST_OPC) +
-                        (QUOTA_LAST_OPC- QUOTA_FIRST_OPC) +
-                        (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
-                        (OBD_LAST_OPC - OBD_FIRST_OPC) +
-                        (MGS_LAST_OPC - MGS_FIRST_OPC) +
-                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
-                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
-                        (OST_LAST_OPC - OST_FIRST_OPC));
+                        OPC_RANGE(SEC) +
+                        OPC_RANGE(SEQ) +
+                        OPC_RANGE(QUOTA) +
+                        OPC_RANGE(LLOG) +
+                        OPC_RANGE(OBD) +
+                        OPC_RANGE(MGS) +
+                        OPC_RANGE(LDLM) +
+                        OPC_RANGE(MDS) +
+                        OPC_RANGE(OST));
         } else {
                 /* Unknown Opcode */
                 return -1;
         } else {
                 /* Unknown Opcode */
                 return -1;
@@ -273,19 +276,19 @@ static inline int opcode_offset(__u32 opc) {
 }
 
 
 }
 
 
-#define LUSTRE_MAX_OPCODES ((OST_LAST_OPC - OST_FIRST_OPC)     + \
-                            (MDS_LAST_OPC - MDS_FIRST_OPC)     + \
-                            (LDLM_LAST_OPC - LDLM_FIRST_OPC)   + \
-                            (MGS_LAST_OPC - MGS_FIRST_OPC)     + \
-                            (OBD_LAST_OPC - OBD_FIRST_OPC)     + \
-                            (LLOG_LAST_OPC - LLOG_FIRST_OPC)   + \
-                            (QUOTA_LAST_OPC - QUOTA_FIRST_OPC) + \
-                            (SEQ_LAST_OPC - SEQ_FIRST_OPC)     + \
-                            (SEC_LAST_OPC - SEC_FIRST_OPC)     + \
-                            (FLD_LAST_OPC - FLD_FIRST_OPC))
+#define LUSTRE_MAX_OPCODES (OPC_RANGE(OST)  + \
+                            OPC_RANGE(MDS)  + \
+                            OPC_RANGE(LDLM) + \
+                            OPC_RANGE(MGS)  + \
+                            OPC_RANGE(OBD)  + \
+                            OPC_RANGE(LLOG) + \
+                            OPC_RANGE(SEC)  + \
+                            OPC_RANGE(SEQ)  + \
+                            OPC_RANGE(SEC)  + \
+                            OPC_RANGE(FLD)  )
 
 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR)  + \
 
 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR)  + \
-                           (EXTRA_LAST_OPC - EXTRA_FIRST_OPC))
+                            OPC_RANGE(EXTRA))
 
 enum {
         PTLRPC_REQWAIT_CNTR = 0,
 
 enum {
         PTLRPC_REQWAIT_CNTR = 0,
@@ -357,9 +360,9 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int type)
                 if (type & LPROCFS_GET_NUM_CPU)
                         rc = num_possible_cpus();
                 if (type & LPROCFS_GET_SMP_ID) {
                 if (type & LPROCFS_GET_NUM_CPU)
                         rc = num_possible_cpus();
                 if (type & LPROCFS_GET_SMP_ID) {
-                       stats->ls_flags |= LPROCFS_STATS_GET_SMP_ID;
+                        stats->ls_flags |= LPROCFS_STATS_GET_SMP_ID;
                         rc = cfs_get_cpu();
                         rc = cfs_get_cpu();
-               }
+                }
         }
         return rc;
 }
         }
         return rc;
 }
@@ -368,8 +371,8 @@ static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats)
 {
         if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU)
                 spin_unlock(&stats->ls_lock);
 {
         if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU)
                 spin_unlock(&stats->ls_lock);
-       else if (stats->ls_flags & LPROCFS_STATS_GET_SMP_ID)
-               cfs_put_cpu();
+        else if (stats->ls_flags & LPROCFS_STATS_GET_SMP_ID)
+                cfs_put_cpu();
 }
 
 /* Two optimized LPROCFS counter increment functions are provided:
 }
 
 /* Two optimized LPROCFS counter increment functions are provided:
index f10e697..cde0b68 100644 (file)
@@ -189,5 +189,16 @@ extern int llapi_changelog_register(const char *mdtname);
 extern int llapi_changelog_unregister(const char *mdtname, int id);
 extern int llapi_fid2path(const char *device, const char *fidstr, char *path,
                           int pathlen, long long *recno, int *linkno);
 extern int llapi_changelog_unregister(const char *mdtname, int id);
 extern int llapi_fid2path(const char *device, const char *fidstr, char *path,
                           int pathlen, long long *recno, int *linkno);
+/* HSM copytool interface.  priv is private copytool state, managed internally
+   by these functions */
+extern int llapi_copytool_start(void **priv, int flags, int archive_num_count,
+                                int *archive_nums);
+extern int llapi_copytool_fini(void **priv);
+extern int llapi_copytool_recv(void *priv, struct hsm_action_list **hal,
+                               int *msgsize);
+extern int llapi_copytool_free(struct hsm_action_list **hal);
+
 #endif
 
 #endif
 
+
+
index 89fa719..e2e43c2 100644 (file)
@@ -279,7 +279,7 @@ struct lustre_mdt_attrs {
          * lma_self_fid and lma_flags are always available.
          */
         __u32   lma_compat;
          * lma_self_fid and lma_flags are always available.
          */
         __u32   lma_compat;
-       /**
+        /**
          * Per-file incompat feature list. Lustre version should support all
          * flags set in this field. The supported feature mask is available in
          * LMA_INCOMPAT_SUPP.
          * Per-file incompat feature list. Lustre version should support all
          * flags set in this field. The supported feature mask is available in
          * LMA_INCOMPAT_SUPP.
@@ -2554,7 +2554,7 @@ static inline void lustre_get_wire_obdo(struct obdo *lobdo, struct obdo *wobdo)
         obd_flag local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK;
 
         LASSERT(!(wobdo->o_flags & OBD_FL_LOCAL_MASK));
         obd_flag local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK;
 
         LASSERT(!(wobdo->o_flags & OBD_FL_LOCAL_MASK));
-        
+
         memcpy(lobdo, wobdo, sizeof(*lobdo));
         lobdo->o_flags &= ~OBD_FL_LOCAL_MASK;
         lobdo->o_flags |= local_flags;
         memcpy(lobdo, wobdo, sizeof(*lobdo));
         lobdo->o_flags &= ~OBD_FL_LOCAL_MASK;
         lobdo->o_flags |= local_flags;
@@ -2780,6 +2780,8 @@ struct getinfo_fid2path {
 
 void lustre_swab_fid2path (struct getinfo_fid2path *gf);
 
 
 void lustre_swab_fid2path (struct getinfo_fid2path *gf);
 
+extern void lustre_swab_lnlh(struct lnl_hdr *);
+
 
 #endif
 /** @} lustreidl */
 
 #endif
 /** @} lustreidl */
index 01c03c8..d7f65e3 100644 (file)
@@ -226,6 +226,19 @@ static inline char *obd_uuid2str(struct obd_uuid *uuid)
         return (char *)(uuid->uuid);
 }
 
         return (char *)(uuid->uuid);
 }
 
+/* Extract fsname from uuid (or target name) of a target
+   e.g. (myfs-OST0007_UUID -> myfs)
+   see also deuuidify. */
+static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen)
+{
+        char *p;
+
+        strncpy(buf, uuid, buflen - 1);
+        buf[buflen - 1] = '\0';
+        p = strrchr(buf, '-');
+        if (p)
+           *p = '\0';
+}
 
 /**
  * File IDentifier.
 
 /**
  * File IDentifier.
@@ -403,6 +416,9 @@ struct if_quotactl {
         struct obd_uuid         obd_uuid;
 };
 
         struct obd_uuid         obd_uuid;
 };
 
+
+/********* Misc **********/
+
 struct ioc_changelog_clear {
         __u32 icc_mdtindex;
         __u32 icc_id;
 struct ioc_changelog_clear {
         __u32 icc_mdtindex;
         __u32 icc_id;
@@ -415,4 +431,64 @@ struct ioc_changelog_clear {
 
 #define dot_lustre_name ".lustre"
 
 
 #define dot_lustre_name ".lustre"
 
+
+/********* HSM **********/
+enum hsm_message_type {
+        HMT_ACTION_LIST = 100, /* message is a hsm_action_list */
+};
+
+/* User-generated (ioctl) request types */
+enum hsm_request {
+        HSMR_ARCHIVE = 10, /* copy to hsm */
+        HSMR_RESTORE = 11, /* prestage */
+        HSMR_RELEASE = 12, /* drop ost objects */
+        HSMR_REMOVE  = 13, /* remove from archive */
+        HSMR_CANCEL  = 14
+};
+
+/* Copytool commands */
+enum hsm_action {
+        HSMA_ARCHIVE = 20, /* arbitrary offset */
+        HSMA_RESTORE = 21,
+        HSMA_REMOVE  = 22,
+        HSMA_CANCEL  = 23
+};
+
+/* Copytool item action description */
+struct hsm_action_item {
+        __u32      hai_len;     /* valid size of this struct */
+        __u32      hai_action;  /* enum actually, but use known size */
+        lustre_fid hai_fid;     /* Lustre FID to operated on */
+        __u64      hai_cookie;  /* action cookie from coordinator */
+        __u64      hai_extent_start;  /* byte range to operate on */
+        __u64      hai_extent_end;
+        __u64      hai_gid;     /* grouplock id */
+        char       hai_data[0]; /* variable length */
+} __attribute__((packed));
+
+/* Copytool action list */
+#define HAL_VERSION 1
+#define HAL_MAXSIZE 4096 /* bytes, used in userspace only */
+struct hsm_action_list {
+        __u32 hal_version;
+        __u32 hal_count;       /* number of hai's to follow */
+        __u32 hal_archive_num; /* which archive backend */
+        __u32 padding1;
+        char  hal_fsname[0];   /* null-terminated */
+        /* struct hsm_action_item[hal_count] follows, aligned on 8-byte
+           boundaries. See hai_zero */
+} __attribute__((packed));
+
+/* Return pointer to first hai in action list */
+static inline struct hsm_action_item * hai_zero(struct hsm_action_list *hal) {
+        return (struct hsm_action_item *)(hal->hal_fsname +
+                                          size_round(strlen(hal->hal_fsname)));
+}
+/* Return pointer to next hai */
+static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai) {
+        return (struct hsm_action_item *)((char *)hai +
+                                          size_round(hai->hai_len));
+}
+
+
 #endif /* _LUSTRE_USER_H */
 #endif /* _LUSTRE_USER_H */
index 228cb06..69baf77 100644 (file)
@@ -121,7 +121,8 @@ struct lustre_disk_data {
         __u32      ldd_svindex;         /* server index (0001), must match
                                            svname */
         __u32      ldd_mount_type;      /* target fs type LDD_MT_* */
         __u32      ldd_svindex;         /* server index (0001), must match
                                            svname */
         __u32      ldd_mount_type;      /* target fs type LDD_MT_* */
-        char       ldd_fsname[64];      /* filesystem this server is part of */
+        char       ldd_fsname[64];      /* filesystem this server is part of,
+                                           MTI_NAME_MAXLEN */
         char       ldd_svname[64];      /* this server's name (lustre-mdt0001)*/
         __u8       ldd_uuid[40];        /* server UUID (COMPAT_146) */
 
         char       ldd_svname[64];      /* this server's name (lustre-mdt0001)*/
         __u8       ldd_uuid[40];        /* server UUID (COMPAT_146) */
 
index bbcdd91..668cce1 100644 (file)
@@ -126,7 +126,6 @@ void l_lock(struct lustre_lock *);
 void l_unlock(struct lustre_lock *);
 int l_has_lock(struct lustre_lock *);
 
 void l_unlock(struct lustre_lock *);
 int l_has_lock(struct lustre_lock *);
 
-
 /*
  *   OBD IOCTLS
  */
 /*
  *   OBD IOCTLS
  */
index 929fda6..0fe2645 100644 (file)
@@ -428,12 +428,13 @@ int t14(char *name)
                                 printf("found bad name %s\n", item);
                                 return(-1);
                         }
                                 printf("found bad name %s\n", item);
                                 return(-1);
                         }
-                        printf("[%03d]: %s\n",
+                        printf("[%03d]: %s\t",
                                 index++, item + strlen(prefix));
 iter:
                         pos += ent->d_reclen;
                 }
         }
                                 index++, item + strlen(prefix));
 iter:
                         pos += ent->d_reclen;
                 }
         }
+        printf("\n");
         if (rc < 0) {
                 printf("getdents error %d\n", rc);
                 return(-1);
         if (rc < 0) {
                 printf("getdents error %d\n", rc);
                 return(-1);
index 789b33c..d2af671 100644 (file)
@@ -131,6 +131,60 @@ static struct file_operations mdc_changelog_fops = {
         .release = mdc_changelog_seq_release,
 };
 
         .release = mdc_changelog_seq_release,
 };
 
+/* temporary for testing */
+static int mdc_wr_netlink(struct file *file, const char *buffer,
+                          unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        struct lnl_hdr *lh;
+        struct hsm_action_list *hal;
+        struct hsm_action_item *hai;
+        int len;
+        int pid, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &pid);
+        if (rc)
+                return rc;
+
+        if (pid < 0)
+                return -ERANGE;
+        CWARN("message to pid %d\n", pid);
+
+        len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN +
+                /* for mockup below */ 2 * size_round(sizeof(*hai));
+
+        OBD_ALLOC(lh, len);
+
+        lh->lnl_magic = LNL_MAGIC;
+        lh->lnl_transport = LNL_TRANSPORT_HSM;
+        lh->lnl_msgtype = HMT_ACTION_LIST;
+        lh->lnl_msglen = len;
+
+        hal = (struct hsm_action_list *)(lh + 1);
+        hal->hal_version = HAL_VERSION;
+        hal->hal_archive_num = 1;
+        obd_uuid2fsname(hal->hal_fsname, obd->obd_name, MTI_NAME_MAXLEN);
+
+        /* mock up an action list */
+        hal->hal_count = 2;
+        hai = hai_zero(hal);
+        hai->hai_action = HSMA_ARCHIVE;
+        hai->hai_fid.f_oid = 5;
+        hai->hai_len = sizeof(*hai);
+        hai = hai_next(hai);
+        hai->hai_action = HSMA_RESTORE;
+        hai->hai_fid.f_oid = 10;
+        hai->hai_len = sizeof(*hai);
+
+        /* This works for either broadcast or unicast to a single pid */
+        rc = libcfs_klnl_msg_put(pid, pid == 0 ? LNL_GRP_HSM : 0, lh);
+
+        OBD_FREE(lh, len);
+        if (rc < 0)
+                return rc;
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
         { "uuid",            lprocfs_rd_uuid,        0, 0 },
         { "ping",            0, lprocfs_wr_ping,     0, 0, 0222 },
 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
         { "uuid",            lprocfs_rd_uuid,        0, 0 },
         { "ping",            0, lprocfs_wr_ping,     0, 0, 0222 },
@@ -150,6 +204,7 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
         { "import",          lprocfs_rd_import,      0, 0 },
         { "state",           lprocfs_rd_state,       0, 0 },
         { "changelog",       0, 0, 0, &mdc_changelog_fops, 0400 },
         { "import",          lprocfs_rd_import,      0, 0 },
         { "state",           lprocfs_rd_state,       0, 0 },
         { "changelog",       0, 0, 0, &mdc_changelog_fops, 0400 },
+        { "netlink",         0, mdc_wr_netlink,      0, 0, 0222 },
         { 0 }
 };
 
         { 0 }
 };
 
index a80fa07..4489340 100644 (file)
@@ -48,7 +48,7 @@ static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
         memset(lvars, 0, sizeof(*lvars));
 }
 #endif
         memset(lvars, 0, sizeof(*lvars));
 }
 #endif
+
 void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid,
                    struct obd_capa *oc, __u64 valid, int ea_size,
                    __u32 suppgid, int flags);
 void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid,
                    struct obd_capa *oc, __u64 valid, int ea_size,
                    __u32 suppgid, int flags);
@@ -166,4 +166,5 @@ ldlm_mode_t mdc_lock_match(struct obd_export *exp, int flags,
                            const struct lu_fid *fid, ldlm_type_t type,
                            ldlm_policy_data_t *policy, ldlm_mode_t mode,
                            struct lustre_handle *lockh);
                            const struct lu_fid *fid, ldlm_type_t type,
                            ldlm_policy_data_t *policy, ldlm_mode_t mode,
                            struct lustre_handle *lockh);
+
 #endif
 #endif
index 40f5f53..6693f75 100644 (file)
@@ -1635,6 +1635,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
                 CERROR("failed to setup llogging subsystems\n");
         }
 
                 CERROR("failed to setup llogging subsystems\n");
         }
 
+        /* ignore errors */
+        libcfs_klnl_start(LNL_TRANSPORT_HSM);
+
         RETURN(rc);
 
 err_close_lock:
         RETURN(rc);
 
 err_close_lock:
@@ -1702,6 +1705,8 @@ static int mdc_cleanup(struct obd_device *obd)
 {
         struct client_obd *cli = &obd->u.cli;
 
 {
         struct client_obd *cli = &obd->u.cli;
 
+        libcfs_klnl_stop(LNL_TRANSPORT_HSM, LNL_GRP_HSM);
+
         OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
         OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
         OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
         OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
         OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
         OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
index 62832a5..dc52ab0 100644 (file)
@@ -507,12 +507,19 @@ static __inline__ int next_index(void *index_map, int map_len)
         0  newly marked as in use
         <0 err
         +EALREADY for update of an old index */
         0  newly marked as in use
         <0 err
         +EALREADY for update of an old index */
-static int mgs_set_index(struct fs_db *fsdb, struct mgs_target_info *mti)
+int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
 {
 {
+        struct fs_db *fsdb;
         void *imap;
         int rc = 0;
         ENTRY;
 
         void *imap;
         int rc = 0;
         ENTRY;
 
+        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
+        if (rc) {
+                CERROR("Can't get db for %s\n", mti->mti_fsname);
+                RETURN(rc);
+        }
+
         if (mti->mti_flags & LDD_F_SV_TYPE_OST)
                 imap = fsdb->fsdb_ost_index_map;
         else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
         if (mti->mti_flags & LDD_F_SV_TYPE_OST)
                 imap = fsdb->fsdb_ost_index_map;
         else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
@@ -2547,23 +2554,15 @@ int mgs_write_log_target(struct obd_device *obd,
                          struct mgs_target_info *mti)
 {
         struct fs_db *fsdb;
                          struct mgs_target_info *mti)
 {
         struct fs_db *fsdb;
+        int rc = -EINVAL;
         char *buf, *params;
         char *buf, *params;
-        int rc;
         ENTRY;
 
         ENTRY;
 
-        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
-        if (rc) {
-                CERROR("Can't get db for %s\n", mti->mti_fsname);
-                RETURN(rc);
-        }
-
-        down(&fsdb->fsdb_sem);
-
         /* set/check the new target index */
         /* set/check the new target index */
-        rc = mgs_set_index(fsdb, mti);
+        rc = mgs_set_index(obd, mti);
         if (rc < 0) {
                 CERROR("Can't get index (%d)\n", rc);
         if (rc < 0) {
                 CERROR("Can't get index (%d)\n", rc);
-                GOTO(out_up, rc);
+                RETURN(rc);
         }
 
         /* COMPAT_146 */
         }
 
         /* COMPAT_146 */
@@ -2599,6 +2598,14 @@ int mgs_write_log_target(struct obd_device *obd,
                 }
         }
 
                 }
         }
 
+        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
+        if (rc) {
+                CERROR("Can't get db for %s\n", mti->mti_fsname);
+                RETURN(rc);
+        }
+
+        down(&fsdb->fsdb_sem);
+
         if (mti->mti_flags &
             (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) {
                 /* Generate a log from scratch */
         if (mti->mti_flags &
             (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) {
                 /* Generate a log from scratch */
index e9f337b..ab08463 100644 (file)
@@ -887,7 +887,7 @@ struct obd_import *class_import_get(struct obd_import *import)
         LASSERT(atomic_read(&import->imp_refcount) < 0x5a5a5a);
         atomic_inc(&import->imp_refcount);
         CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", import,
         LASSERT(atomic_read(&import->imp_refcount) < 0x5a5a5a);
         atomic_inc(&import->imp_refcount);
         CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", import,
-               atomic_read(&import->imp_refcount), 
+               atomic_read(&import->imp_refcount),
                import->imp_obd->obd_name);
         return import;
 }
                import->imp_obd->obd_name);
         return import;
 }
@@ -902,7 +902,7 @@ void class_import_put(struct obd_import *imp)
         LASSERT(list_empty(&imp->imp_zombie_chain));
 
         CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp,
         LASSERT(list_empty(&imp->imp_zombie_chain));
 
         CDEBUG(D_INFO, "import %p refcount=%d obd=%s\n", imp,
-               atomic_read(&imp->imp_refcount) - 1, 
+               atomic_read(&imp->imp_refcount) - 1,
                imp->imp_obd->obd_name);
 
         if (atomic_dec_and_test(&imp->imp_refcount)) {
                imp->imp_obd->obd_name);
 
         if (atomic_dec_and_test(&imp->imp_refcount)) {
@@ -1514,11 +1514,11 @@ static int obd_zombie_impexp_thread(void *unused)
         while(!test_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags)) {
                 struct l_wait_info lwi = { 0 };
 
         while(!test_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags)) {
                 struct l_wait_info lwi = { 0 };
 
-                l_wait_event(obd_zombie_waitq, 
+                l_wait_event(obd_zombie_waitq,
                              !obd_zombie_impexp_check(NULL), &lwi);
                 obd_zombie_impexp_cull();
 
                              !obd_zombie_impexp_check(NULL), &lwi);
                 obd_zombie_impexp_cull();
 
-                /* 
+                /*
                  * Notify obd_zombie_barrier callers that queues
                  * may be empty.
                  */
                  * Notify obd_zombie_barrier callers that queues
                  * may be empty.
                  */
@@ -1540,7 +1540,7 @@ int obd_zombie_impexp_kill(void *arg)
 {
         int rc = 0;
 
 {
         int rc = 0;
 
-       if (atomic_inc_return(&zombie_recur) == 1) {
+        if (atomic_inc_return(&zombie_recur) == 1) {
                 obd_zombie_impexp_cull();
                 rc = 1;
         }
                 obd_zombie_impexp_cull();
                 rc = 1;
         }
@@ -1597,3 +1597,4 @@ void obd_zombie_impexp_stop(void)
         liblustre_deregister_idle_callback(obd_zombie_impexp_idle_cb);
 #endif
 }
         liblustre_deregister_idle_callback(obd_zombie_impexp_idle_cb);
 #endif
 }
+
index 61a21db..690f4f3 100644 (file)
@@ -2275,11 +2275,19 @@ void lustre_swab_lustre_capa(struct lustre_capa *c)
         __swab32s (&c->lc_expiry);
 }
 
         __swab32s (&c->lc_expiry);
 }
 
-void lustre_swab_lustre_capa_key (struct lustre_capa_key *k)
+void lustre_swab_lustre_capa_key(struct lustre_capa_key *k)
 {
         __swab64s (&k->lk_mdsid);
         __swab32s (&k->lk_keyid);
         __swab32s (&k->lk_padding);
 }
 
 {
         __swab64s (&k->lk_mdsid);
         __swab32s (&k->lk_keyid);
         __swab32s (&k->lk_padding);
 }
 
+void lustre_swab_lnlh(struct lnl_hdr *l)
+{
+        __swab16s(&l->lnl_magic);
+        /* __u8 l->lnl_transport */
+        __swab16s(&l->lnl_msgtype);
+        __swab16s(&l->lnl_msglen);
+}
+EXPORT_SYMBOL(lustre_swab_lnlh);
 
 
index 5c84523..b58ad9a 100644 (file)
@@ -52,7 +52,7 @@ noinst_PROGRAMS += small_write multiop ll_sparseness_verify
 noinst_PROGRAMS += ll_sparseness_write mrename ll_dirstripe_verify mkdirmany
 noinst_PROGRAMS += openfilleddirunlink rename_many memhog iopentest1 iopentest2
 noinst_PROGRAMS += mmap_sanity flock_test writemany reads flocks_test
 noinst_PROGRAMS += ll_sparseness_write mrename ll_dirstripe_verify mkdirmany
 noinst_PROGRAMS += openfilleddirunlink rename_many memhog iopentest1 iopentest2
 noinst_PROGRAMS += mmap_sanity flock_test writemany reads flocks_test
-noinst_PROGRAMS += write_time_limit rwv
+noinst_PROGRAMS += write_time_limit rwv copytool
 # noinst_PROGRAMS += copy_attr mkdirdeep 
 bin_PROGRAMS = mcreate munlink
 testdir = $(libdir)/lustre/tests
 # noinst_PROGRAMS += copy_attr mkdirdeep 
 bin_PROGRAMS = mcreate munlink
 testdir = $(libdir)/lustre/tests
@@ -67,9 +67,11 @@ mmap_sanity_SOURCES= mmap_sanity.c
 
 LIBLUSTREAPI := $(top_builddir)/lustre/utils/liblustreapi.a
 multiop_LDADD=$(LIBLUSTREAPI) -lrt
 
 LIBLUSTREAPI := $(top_builddir)/lustre/utils/liblustreapi.a
 multiop_LDADD=$(LIBLUSTREAPI) -lrt
+copytool_LDADD=$(LIBLUSTREAPI)
 
 ll_dirstripe_verify_SOURCES= ll_dirstripe_verify.c
 ll_dirstripe_verify_LDADD= -L$(top_builddir)/lustre/utils -llustreapi
 
 flocks_test_SOURCES=flocks_test.c
 flocks_test_LDADD=-lpthread
 
 ll_dirstripe_verify_SOURCES= ll_dirstripe_verify.c
 ll_dirstripe_verify_LDADD= -L$(top_builddir)/lustre/utils -llustreapi
 
 flocks_test_SOURCES=flocks_test.c
 flocks_test_LDADD=-lpthread
+
index f378836..1e70847 100644 (file)
@@ -6375,6 +6375,15 @@ test_162() {
 }
 run_test 162 "path lookup sanity"
 
 }
 run_test 162 "path lookup sanity"
 
+test_163() {
+        copytool &
+       sleep 1
+       # this proc file is temporary and linux-only
+       $LCTL set_param mdc.lustre-MDT0000-mdc-*.netlink=0 || error "lnl send failed"
+       kill $!
+}
+run_test 163 "LustreNetLink kernelcomms"
+
 test_169() {
        # do directio so as not to populate the page cache
        log "creating a 10 Mb file"
 test_169() {
        # do directio so as not to populate the page cache
        log "creating a 10 Mb file"
@@ -6390,7 +6399,7 @@ test_169() {
        log "removing the temporary file"
        rm -rf $DIR/$tfile || error "tmp file removal failed"
 }
        log "removing the temporary file"
        rm -rf $DIR/$tfile || error "tmp file removal failed"
 }
-run_test 169 "parallel read and truncate should not deadlock ==="
+run_test 169 "parallel read and truncate should not deadlock"
 
 test_170() {
         $LCTL clear    # bug 18514
 
 test_170() {
         $LCTL clear    # bug 18514
@@ -6589,6 +6598,7 @@ test_213() {
 }
 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
 
 }
 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
 
+
 #
 # tests that do cleanup/setup should be run at the end
 #
 #
 # tests that do cleanup/setup should be run at the end
 #
index f20cf73..0970d22 100644 (file)
@@ -69,7 +69,8 @@ llverfs_LDADD := $(EXT2FSLIB) $(E2PLIB)
 llverdev_LDADD := $(EXT2FSLIB) $(BLKIDLIB)
 
 L_IOCTL := $(top_builddir)/libcfs/libcfs/util/l_ioctl.c
 llverdev_LDADD := $(EXT2FSLIB) $(BLKIDLIB)
 
 L_IOCTL := $(top_builddir)/libcfs/libcfs/util/l_ioctl.c
-liblustreapi_a_SOURCES = liblustreapi.c $(L_IOCTL)
+L_KERNELCOMM := $(top_builddir)/libcfs/libcfs/ulinux/ulinux-kernelcomm.c
+liblustreapi_a_SOURCES = liblustreapi.c $(L_IOCTL) $(L_KERNELCOMM)
 
 libiam_a_SOURCES = libiam.c
 
 
 libiam_a_SOURCES = libiam.c
 
index 879794e..c029546 100644 (file)
@@ -2614,3 +2614,148 @@ int llapi_path2fid(const char *path, lustre_fid *fid)
         return rc;
 }
 
         return rc;
 }
 
+/****** HSM Copytool API ********/
+#define CT_PRIV_MAGIC 0xC0BE2001
+struct copytool_private {
+        int magic;
+        lustre_netlink lnl;
+        int archive_num_count;
+        int archive_nums[0];
+};
+
+#include <libcfs/libcfs.h>
+
+/** Register a copytool
+ * @param priv Opaque private control structure
+ * @param flags Open flags, currently unused (e.g. O_NONBLOCK)
+ * @param archive_nums Which archive numbers this copytool is responsible for
+ */
+int llapi_copytool_start(void **priv, int flags, int archive_num_count,
+                         int *archive_nums)
+{
+        struct copytool_private *ct;
+        int rc;
+
+        if (archive_num_count > 0 && archive_nums == NULL) {
+                llapi_err(LLAPI_MSG_ERROR | LLAPI_MSG_NO_ERRNO,
+                          "NULL archive numbers");
+                return -EINVAL;
+        }
+
+        ct = malloc(sizeof(*ct) +
+                    archive_num_count * sizeof(ct->archive_nums[0]));
+        if (ct == NULL)
+                return -ENOMEM;
+
+        ct->magic = CT_PRIV_MAGIC;
+        ct->archive_num_count = archive_num_count;
+        if (ct->archive_num_count > 0)
+                memcpy(ct->archive_nums, archive_nums, archive_num_count *
+                       sizeof(ct->archive_nums[0]));
+
+        rc = libcfs_ulnl_start(&ct->lnl, LNL_GRP_HSM);
+        if (rc < 0)
+                goto out_err;
+
+        *priv = ct;
+        return 0;
+
+out_err:
+        free(ct);
+        return rc;
+}
+
+/** Deregister a copytool */
+int llapi_copytool_fini(void **priv)
+{
+        struct copytool_private *ct = (struct copytool_private *)*priv;
+
+        if (!ct || (ct->magic != CT_PRIV_MAGIC))
+                return -EINVAL;
+
+        libcfs_ulnl_stop(&ct->lnl);
+        free(ct);
+        *priv = NULL;
+        return 0;
+}
+
+/** Wait for the next hsm_action_list
+ * @param priv Opaque private control structure
+ * @param halh Action list handle, will be allocated here
+ * @param msgsize Number of bytes in the message, will be set here
+ * @return 0 valid message received; halh and msgsize are set
+ *         <0 error code
+ */
+int llapi_copytool_recv(void *priv, struct hsm_action_list **halh, int *msgsize)
+{
+        struct copytool_private *ct = (struct copytool_private *)priv;
+        struct lnl_hdr *lnlh;
+        struct hsm_action_list *hal;
+        int rc = 0;
+
+        if (!ct || (ct->magic != CT_PRIV_MAGIC))
+                return -EINVAL;
+        if (halh == NULL || msgsize == NULL)
+                return -EINVAL;
+
+        rc = libcfs_ulnl_msg_get(&ct->lnl, HAL_MAXSIZE,
+                                 LNL_TRANSPORT_HSM, &lnlh);
+        if (rc < 0)
+                return rc;
+
+        /* Handle generic messages */
+        if (lnlh->lnl_transport == LNL_TRANSPORT_GENERIC &&
+            lnlh->lnl_msgtype == LNL_MSG_SHUTDOWN) {
+                rc = -ESHUTDOWN;
+                goto out_free;
+        }
+
+        if (lnlh->lnl_transport != LNL_TRANSPORT_HSM ||
+            lnlh->lnl_msgtype != HMT_ACTION_LIST) {
+                llapi_err(LLAPI_MSG_ERROR | LLAPI_MSG_NO_ERRNO,
+                          "Unknown HSM message type %d:%d\n",
+                          lnlh->lnl_transport, lnlh->lnl_msgtype);
+                rc = -EPROTO;
+                goto out_free;
+        }
+
+        /* Our message is an hsm_action_list */
+
+        hal = (struct hsm_action_list *)(lnlh + 1);
+
+        /* Check that we have registered for this archive # */
+        for (rc = 0; rc < ct->archive_num_count; rc++) {
+                if (hal->hal_archive_num == ct->archive_nums[rc])
+                        break;
+        }
+        if (rc >= ct->archive_num_count) {
+                CDEBUG(D_INFO, "This copytool does not service archive #%d, "
+                       "ignoring this request.\n", hal->hal_archive_num);
+                rc = 0;
+                goto out_free;
+        }
+
+        *halh = hal;
+        *msgsize = lnlh->lnl_msglen - sizeof(*lnlh);
+        return 0;
+
+out_free:
+        libcfs_ulnl_msg_free(&lnlh);
+        *halh = NULL;
+        *msgsize = 0;
+        return rc;
+}
+
+/** Release the action list when done with it. */
+int llapi_copytool_free(struct hsm_action_list **hal)
+{
+        if (*hal) {
+                struct lnl_hdr *lnlh = (struct lnl_hdr *)*hal - 1;
+                libcfs_ulnl_msg_free(&lnlh);
+        }
+        *hal = NULL;
+        return 0;
+}
+
+
+