libcfs/libcfs/Makefile
libcfs/libcfs/autoMakefile
libcfs/libcfs/linux/Makefile
+libcfs/libcfs/ulinux/Makefile
libcfs/libcfs/posix/Makefile
libcfs/libcfs/util/Makefile
])
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
* "continously".
*/
enum {
- CDD_MAGIC1 = 0x02128506,
- CDD_MAGIC2 = 0x42424242
+ CDD_MAGIC1 = 0x02128506,
+ CDD_MAGIC2 = 0x42424242
};
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);
-#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)
#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)
#ifndef __KERNEL__
#error This include is only for kernel use.
-#endif
+#endif
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
-EXTRA_DIST := libcfs.h posix-wordsize.h posix-types.h
+EXTRA_DIST := libcfs.h posix-wordsize.h posix-types.h posix-kernelcomm.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;
void *item;
};
-#define RADIX_TREE_INIT(mask) { \
+#define RADIX_TREE_INIT(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)
#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 {
- void *frame[CFS_STACK_TRACE_DEPTH];
+ void *frame[CFS_STACK_TRACE_DEPTH];
};
static inline __u32 query_stack_size()
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))
# Lustre is a trademark of Sun Microsystems, Inc.
#
-SUBDIRS := linux util posix
+SUBDIRS := linux util posix ulinux
if DARWIN
SUBDIRS += darwin
endif
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
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)
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
--- /dev/null
+Makefile
+Makefile.in
LC_PERCPU_COUNTER
LC_QUOTA64
LC_4ARGS_VFS_SYMLINK
+ LC_NETLINK
# does the kernel have VFS intent patches?
LC_VFS_INTENT_PATCHES
])
#
+# 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
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 */
} 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 +
- (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 +
- (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 +
- (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 +
- (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 +
- (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 +
- (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 +
- (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 +
- (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;
}
-#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) + \
- (EXTRA_LAST_OPC - EXTRA_FIRST_OPC))
+ OPC_RANGE(EXTRA))
enum {
PTLRPC_REQWAIT_CNTR = 0,
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();
- }
+ }
}
return rc;
}
{
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:
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
+
+
* 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.
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;
void lustre_swab_fid2path (struct getinfo_fid2path *gf);
+extern void lustre_swab_lnlh(struct lnl_hdr *);
+
#endif
/** @} lustreidl */
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.
struct obd_uuid obd_uuid;
};
+
+/********* Misc **********/
+
struct ioc_changelog_clear {
__u32 icc_mdtindex;
__u32 icc_id;
#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 */
__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) */
void l_unlock(struct lustre_lock *);
int l_has_lock(struct lustre_lock *);
-
/*
* OBD IOCTLS
*/
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;
}
}
+ printf("\n");
if (rc < 0) {
printf("getdents error %d\n", rc);
return(-1);
.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 },
{ "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 }
};
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);
const struct lu_fid *fid, ldlm_type_t type,
ldlm_policy_data_t *policy, ldlm_mode_t mode,
struct lustre_handle *lockh);
+
#endif
CERROR("failed to setup llogging subsystems\n");
}
+ /* ignore errors */
+ libcfs_klnl_start(LNL_TRANSPORT_HSM);
+
RETURN(rc);
err_close_lock:
{
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));
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;
+ 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)
struct mgs_target_info *mti)
{
struct fs_db *fsdb;
+ int rc = -EINVAL;
char *buf, *params;
- int rc;
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 */
- rc = mgs_set_index(fsdb, mti);
+ rc = mgs_set_index(obd, mti);
if (rc < 0) {
CERROR("Can't get index (%d)\n", rc);
- GOTO(out_up, rc);
+ RETURN(rc);
}
/* COMPAT_146 */
}
}
+ 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 */
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;
}
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)) {
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();
- /*
+ /*
* Notify obd_zombie_barrier callers that queues
* may be empty.
*/
{
int rc = 0;
- if (atomic_inc_return(&zombie_recur) == 1) {
+ if (atomic_inc_return(&zombie_recur) == 1) {
obd_zombie_impexp_cull();
rc = 1;
}
liblustre_deregister_idle_callback(obd_zombie_impexp_idle_cb);
#endif
}
+
__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);
}
+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);
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
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
+
}
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"
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
}
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
#
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
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;
+}
+
+
+