lustre/include/*.h, platform dependent code in lustre/include/<platform>.
2. Land portability library to obdclass, osc and obdecho.
lvfs-sources:
$(MAKE) sources -C lvfs
+obdclass-sources:
+ $(MAKE) sources -C obdclass
-sources: $(LDISKFS) lvfs-sources lustre_build_version
+sources: $(LDISKFS) lvfs-sources obdclass-sources lustre_build_version
all-recursive: lustre_build_version
#
AC_DEFUN([LC_TARGET_SUPPORTED],
[case $target_os in
- linux*)
+ linux* | darwin*)
$1
;;
*)
lustre/mds/autoMakefile
lustre/obdclass/Makefile
lustre/obdclass/autoMakefile
+lustre/obdclass/linux/Makefile
lustre/obdecho/Makefile
lustre/obdecho/autoMakefile
lustre/obdfilter/Makefile
lustre/utils/Lustre/Makefile
lustre/utils/Makefile
])
+case $lb_target_os in
+ darwin)
+ AC_CONFIG_FILES([ lustre/obdclass/darwin/Makefile ])
+ ;;
+esac
+
])
# See the file COPYING in this distribution
SUBDIRS = linux lustre
-EXTRA_DIST = ioctl.h liblustre.h
+EXTRA_DIST = ioctl.h liblustre.h lprocfs_status.h lustre_cfg.h \
+ lustre_commit_confd.h lustre_debug.h lustre_dlm.h \
+ lustre_export.h lustre_fsfilt.h lustre_ha.h \
+ lustre_handles.h lustre_idl.h lustre_import.h \
+ lustre_lib.h lustre_lite.h lustre_log.h lustre_mds.h\
+ lustre_net.h lustre_quota.h lustre_ucache.h lvfs.h \
+ obd_cache.h obd_class.h obd_echo.h obd.h obd_lov.h \
+ obd_ost.h obd_support.h
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Top level header file for LProc SNMP
+ * Author: Hariharan Thantry thantry@users.sourceforge.net
+ */
+#ifndef _DARWIN_LPROCFS_SNMP_H
+#define _DARWIN_LPROCFS_SNMP_H
+
+#ifndef _LPROCFS_SNMP_H
+#error Do not #include this file directly. #include <lprocfs_status.h> instead
+#endif
+
+#ifdef LPROCFS
+#undef LPROCFS
+#endif
+
+#include <sys/mount.h>
+#define kstatfs statfs
+
+/*
+ * XXX nikita: temporary! Stubs for naked procfs calls made by Lustre
+ * code. Should be replaced with our own procfs-like API.
+ */
+
+static inline cfs_proc_dir_entry_t *proc_symlink(const char *name,
+ cfs_proc_dir_entry_t *parent,
+ const char *dest)
+{
+ return NULL;
+}
+
+static inline cfs_proc_dir_entry_t *create_proc_entry(const char *name,
+ mode_t mode,
+ cfs_proc_dir_entry_t *p)
+{
+ return NULL;
+}
+
+#endif /* XNU_LPROCFS_SNMP_H */
--- /dev/null
+#ifndef __DARWIN_LUSTRE_COMPAT_H__
+#define __DARWIN_LUSTRE_COMPAT_H__
+
+#include <libcfs/libcfs.h>
+
+#ifdef __KERNEL__
+
+#ifndef HLIST_HEAD
+#define hlist_entry list_entry
+#define hlist_head list_head
+#define hlist_node list_head
+#define hlist_del_init list_del_init
+#define hlist_add_head list_add
+#define hlist_for_each_safe list_for_each_safe
+
+/* XXX */
+#define LOOKUP_COBD 4096
+#define CURRENT_SECONDS cfs_unix_seconds()
+
+#endif
+
+struct module;
+static inline int try_module_get(struct module *module)
+{
+ return 1;
+}
+
+static inline void module_put(struct module *module)
+{
+}
+
+#define THIS_MODULE NULL
+
+static inline void lustre_daemonize_helper(void)
+{
+ return;
+}
+
+static inline int32_t ext2_set_bit(int nr, void *a)
+{
+ int32_t old = test_bit(nr, a);
+ set_bit(nr, a);
+ return old;
+}
+
+static inline int32_t ext2_clear_bit(int nr, void *a)
+{
+ int32_t old = test_bit(nr, a);
+ clear_bit(nr, a);
+ return old;
+}
+
+static inline int ll_path_lookup(const char *path, unsigned int flags, struct nameidata *nd)
+{
+ int ret = 0;
+ NDINIT(nd, LOOKUP, FOLLOW, UIO_SYSSPACE, (char *)path, current_proc());
+ if (ret = namei(nd)){
+ CERROR("ll_path_lookup fail!\n");
+ }
+ return ret;
+}
+
+#define to_kdev_t(dev) (dev)
+#define kdev_t_to_nr(dev) (dev)
+#define val_to_kdev(dev) (dev)
+
+#define ext2_test_bit test_bit
+
+#endif /* !__KERNEL__ */
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DARWIN_LUSTRE_DEBUG_H
+#define _DARWIN_LUSTRE_DEBUG_H
+
+#ifndef _LUSTRE_DEBUG_H
+#error Do not #include this file directly. #include <lprocfs_status.h> instead
+#endif
+
+#ifdef __KERNEL__
+#define LL_CDEBUG_PAGE(mask, page, fmt, arg...) do {} while (0)
+#else
+#define LL_CDEBUG_PAGE(mask, page, fmt, arg...) do {} while (0)
+#endif
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * (visit-tags-table FILE)
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+
+#ifndef _DARWIN_LUSTRE_DLM_H__
+#define _DARWIN_LUSTRE_DLM_H__
+
+#ifndef _LUSTRE_DLM_H__
+#error Do not #include this file directly. #include <lprocfs_status.h> instead
+#endif
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001-2004 Cluster File Systems, Inc. <info@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Filesystem interface helper.
+ *
+ */
+
+#ifndef _DARWIN_LUSTRE_FSFILT_H
+#define _DARWIN_LUSTRE_FSFILT_H
+
+#ifndef _LUSTRE_FSFILT_H
+#error Do not #include this file directly. #include <lustre_fsfilt.h> instead
+#endif
+
+#endif
--- /dev/null
+#ifndef __DARWIN_LUSTRE_HANDLES_H_
+#define __DARWIN_LUSTR_HANDLES_H_
+
+#ifndef __LUSTRE_HANDLES_H_
+#error Do not #include this file directly. #include <lustre_handles.h> instead
+#endif
+
+#include <libcfs/list.h>
+#include <libcfs/libcfs.h>
+
+#endif
+
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _DARWIN_LUSTRE_IDL_H_
+#define _DARWIN_LUSTRE_IDL_H_
+
+#ifndef _LUSTRE_IDL_H_
+#error Do not #include this file directly. #include <lustre_idl.h> instead
+#endif
+
+#include <string.h>
+#include <libcfs/libcfs.h>
+#include <libcfs/list.h>
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Basic Lustre library routines.
+ *
+ */
+
+#ifndef _DARWIN_LUSTRE_LIB_H
+#define _DARWIN_LUSTRE_LIB_H
+
+#ifndef _LUSTRE_LIB_H
+#error Do not #include this file directly. #include <lustre_lib.h> instead
+#endif
+
+#include <string.h>
+#include <libcfs/libcfs.h>
+#include <libcfs/kp30.h>
+
+#ifndef LP_POISON
+#define LI_POISON ((int)0x5a5a5a5a)
+#define LL_POISON ((long)0x5a5a5a5a)
+#define LP_POISON ((void *)(long)0x5a5a5a5a)
+#endif
+
+#ifndef LPU64
+#define LPU64 "%llu"
+#define LPD64 "%lld"
+#define LPX64 "%llx"
+#endif
+
+struct obd_ioctl_data;
+#define OBD_IOC_DATA_TYPE struct obd_ioctl_data
+
+#define LUSTRE_FATAL_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | \
+ sigmask(SIGTERM) | sigmask(SIGQUIT) | \
+ sigmask(SIGALRM) | sigmask(SIGHUP))
+
+#ifdef __KERNEL__
+static inline sigset_t l_w_e_set_sigs(sigset_t sigs)
+{
+ struct proc *p = current_proc();
+ sigset_t old;
+
+ extern int block_procsigmask(struct proc *p, int bit);
+ old = cfs_current()->uu_sigmask;
+ block_procsigmask(p, ~sigs);
+
+ return old;
+}
+#endif
+
+#endif
+
+
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * lustre lite cluster file system
+ *
+ * This code is issued under the GNU General Public License.
+ * See the file COPYING in this distribution
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc. <info@clusterfs.com>
+ */
+
+
+
+#ifndef _DARWIN_LL_H
+#define _DARWIN_LL_H
+
+#ifndef _LL_H
+#error Do not #include this file directly. #include <lustre_lite.h> instead
+#endif
+
+#include <libcfs/libcfs.h>
+
+#ifdef __KERNEL__
+
+/*
+ * XXX Liang:
+ * liblustre.h has defined all of them in user space.
+ * Where should we put them in OSX?
+ */
+#define IT_OPEN 0x0001
+#define IT_CREAT 0x0002
+#define IT_READDIR 0x0004
+#define IT_GETATTR 0x0008
+#define IT_LOOKUP 0x0010
+#define IT_UNLINK 0x0020
+#define IT_GETXATTR 0x0040
+#define IT_EXEC 0x0080
+#define IT_PIN 0x0100
+#define IT_CHDIR 0x0200
+
+struct iattr {
+ unsigned int ia_valid;
+ umode_t ia_mode;
+ uid_t ia_uid;
+ gid_t ia_gid;
+ loff_t ia_size;
+ time_t ia_atime;
+ time_t ia_mtime;
+ time_t ia_ctime;
+ unsigned int ia_attr_flags;
+};
+
+/*
+ * intent data-structured. For Linux they are defined in
+ * linux/include/linux/dcache.h
+ */
+#define IT_OPEN 0x0001
+#define IT_CREAT 0x0002
+#define IT_READDIR 0x0004
+#define IT_GETATTR 0x0008
+#define IT_LOOKUP 0x0010
+#define IT_UNLINK 0x0020
+#define IT_GETXATTR 0x0040
+#define IT_EXEC 0x0080
+#define IT_PIN 0x0100
+
+#define IT_FL_LOCKED 0x0001
+#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
+
+#define INTENT_MAGIC 0x19620323 /* Happy birthday! */
+
+struct lustre_intent_data {
+ int it_disposition;
+ int it_status;
+ __u64 it_lock_handle;
+ void *it_data;
+ int it_lock_mode;
+};
+
+/*
+ * Liang: We keep the old lookup_intent struct in XNU
+ * to avoid unnecessary allocate/free.
+ */
+#define LUSTRE_IT(it) ((struct lustre_intent_data *)(&(it)->d.lustre))
+
+struct lookup_intent {
+ int it_magic;
+ void (*it_op_release)(struct lookup_intent *);
+ int it_op;
+ int it_flags;
+ int it_create_mode;
+ union {
+ struct lustre_intent_data lustre;
+ void *fs_data;
+ } d;
+};
+
+struct super_operations{
+};
+#endif
+
+#endif
--- /dev/null
+#ifndef _DARWIN_LUSTRE_LOG_H
+#define _DARWIN_LUSTRE_LOG_H
+
+#ifndef _LUSTRE_LOG_H
+#error Do not #include this file directly. #include <lustre_log.h> instead
+#endif
+
+#undef LUSTRE_LOG_SERVER
+#include <darwin/lustre_compat.h>
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001-2003 Cluster File Systems, Inc. <info@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * MDS data structures.
+ * See also lustre_idl.h for wire formats of requests.
+ *
+ */
+
+#ifndef _DARWIN_LUSTRE_MDS_H
+#define _DARWIN_LUSTRE_MDS_H
+
+#ifndef _LUSTRE_MDS_H
+#error Do not #include this file directly. #include <lustre_mds.h> instead
+#endif
+
+#include <lustre_lite.h>
+#include <libcfs/darwin/darwin-prim.h>
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DARWIN_LUSTRE_NET_H
+#define _DARWIN_LUSTRE_NET_H
+
+#ifndef _LUSTRE_NET_H
+#error Do not #include this file directly. #include <lustre_net.h> instead
+#endif
+
+#include <netat/sysglue.h>
+#include <libcfs/darwin/darwin-prim.h>
+
+#undef WITH_GROUP_INFO
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+#ifndef _DARWIN_LUSTRE_QUOTA_H
+#define _DARWIN_LUSTRE_QUOTA_H
+
+#ifndef _LUSTRE_QUOTA_H
+#error Do not #include this file directly. #include <lustre_quota.h> instead
+#endif
+
+#ifdef __KERNEL__
+#include <libcfs/libcfs.h>
+#endif
+
+
+#endif /* _LUSTRE_QUOTA_H */
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * This file is part of Lustre, http://www.lustre.org
+ *
+ * Lustre public user-space interface definitions.
+ */
+
+#ifndef _DARWIN_LUSTRE_USER_H
+#define _DARWIN_LUSTRE_USER_H
+
+#include <lustre/types.h>
+
+#ifndef __KERNEL__
+/* for llmount */
+# define _GNU_SOURCE
+# include <getopt.h>
+# include <sys/utsname.h>
+# include <sys/stat.h>
+# include <errno.h>
+# include <sys/mount.h>
+# include <sys/fcntl.h>
+# include <sys/ioccom.h>
+# include <sys/wait.h>
+# include <string.h>
+#endif
+
+#if defined(__KERNEL__)
+typedef struct stat lstat_t;
+#define HAVE_LOV_USER_MDS_DATA
+#endif
+
+#ifndef LPU64
+/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
+#if defined(__x86_64__) && defined(__KERNEL__)
+# define LPU64 "%Lu"
+# define LPD64 "%Ld"
+# define LPX64 "%#Lx"
+# define LPSZ "%lu"
+# define LPSSZ "%ld"
+#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
+# define LPU64 "%Lu"
+# define LPD64 "%Ld"
+# define LPX64 "%#Lx"
+# define LPSZ "%u"
+# define LPSSZ "%d"
+#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
+# define LPU64 "%lu"
+# define LPD64 "%ld"
+# define LPX64 "%#lx"
+# define LPSZ "%lu"
+# define LPSSZ "%ld"
+#endif
+#endif /* !LPU64 */
+
+#endif /* _LUSTRE_USER_H */
--- /dev/null
+#ifndef __DARWIN_LVFS_H__
+#define __DARWIN_LVFS_H__
+
+#ifndef __LVFS_H__
+#error Do not #include this file directly. #include <lvfs.h> instead
+#endif
+
+#ifdef LLOG_LVFS
+#undef LLOG_LVFS
+#endif
+
+struct lvfs_ucred {
+ __u32 luc_fsuid;
+ __u32 luc_fsgid;
+ __u32 luc_cap;
+ __u32 luc_uid;
+ __u32 luc_umask;
+};
+
+struct lvfs_run_ctxt {
+ int pid;
+};
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ *
+ * This code is issued under the GNU General Public License.
+ * See the file COPYING in this distribution
+ */
+
+#ifndef __DARWIN_OBD_H
+#define __DARWIN_OBD_H
+
+#ifndef __OBD_H
+#error Do not #include this file directly. #include <obd.h> instead
+#endif
+
+#include <libcfs/libcfs.h>
+
+typedef struct semaphore client_obd_lock_t;
+
+static inline void client_obd_list_lock_init(client_obd_lock_t *lock)
+{
+ sema_init(lock, 1);
+}
+
+static inline void client_obd_list_lock_done(client_obd_lock_t *lock)
+{}
+
+static inline void client_obd_list_lock(client_obd_lock_t *lock)
+{
+ mutex_down(lock);
+}
+
+static inline void client_obd_list_unlock(client_obd_lock_t *lock)
+{
+ mutex_up(lock);
+}
+
+#endif /* __DARWIN_OBD_H */
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001-2003 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __DARWIN_CLASS_OBD_H
+#define __DARWIN_CLASS_OBD_H
+
+#ifndef __CLASS_OBD_H
+#error Do not #include this file directly. #include <obd_class.h> instead
+#endif
+
+#define to_kdev_t(dev) dev
+
+#endif /* __XNU_OBD_CLASS_H */
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _DARWIN_OBD_SUPPORT
+#define _DARWIN_OBD_SUPPORT
+
+#ifndef _OBD_SUPPORT
+#error Do not #include this file directly. #include <obd_support.h> instead
+#endif
+
+#include <darwin/lustre_compat.h>
+
+#define CRCPOLY_LE 0xedb88320
+/**
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
+ * other uses, or the previous crc32 value if computing incrementally.
+ * @p - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ */
+static inline __u32 crc32_le(__u32 crc, unsigned char const *p, size_t len)
+{
+ int i;
+ while (len--) {
+ crc ^= *p++;
+ for (i = 0; i < 8; i++)
+ crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+ }
+ return crc;
+}
+
+#define OBD_SLEEP_ON(wq) sleep_on(wq)
+
+/* for obd_class.h */
+# ifndef ERR_PTR
+# define ERR_PTR(a) ((void *)(a))
+# endif
+
+#endif
#define kmap(page) (page)->addr
#define kunmap(a) do {} while (0)
-static inline struct page *alloc_pages(int mask, unsigned long order)
+static inline cfs_page_t *alloc_pages(int mask, unsigned long order)
{
- struct page *pg = malloc(sizeof(*pg));
+ cfs_page_t *pg = malloc(sizeof(*pg));
if (!pg)
return NULL;
#define alloc_page(mask) alloc_pages((mask), 0)
-static inline void __free_pages(struct page *pg, int what)
+static inline void __free_pages(cfs_page_t *pg, int what)
{
#if 0 //#ifdef MAP_ANONYMOUS
munmap(pg->addr, PAGE_SIZE);
#define __free_page(page) __free_pages((page), 0)
#define free_page(page) __free_page(page)
-static inline struct page* __grab_cache_page(unsigned long index)
+static inline cfs_page_t* __grab_cache_page(unsigned long index)
{
- struct page *pg = alloc_pages(0, 0);
+ cfs_page_t *pg = alloc_pages(0, 0);
if (pg)
pg->index = index;
sema_init(sem, 1);
}
+#define init_mutex(s) init_MUTEX(s)
typedef struct {
struct list_head sleepers;
__u32 cap_effective;
};
+typedef struct task_struct cfs_task_t;
+#define cfs_current() current
+#define cfs_curproc_pid() (current->pid)
+#define cfs_curproc_comm() (current->comm)
+
extern struct task_struct *current;
int in_group_p(gid_t gid);
static inline int capable(int cap)
/* completion */
struct completion {
unsigned int done;
- wait_queue_head_t wait;
+ cfs_waitq_t wait;
};
#define COMPLETION_INITIALIZER(work) \
void *host;
};
-struct file_lock {
+typedef struct file_lock {
struct file_lock *fl_next; /* singly linked list for this inode */
struct list_head fl_link; /* doubly linked list of all locks */
struct list_head fl_block; /* circular list of blocked processes */
void *fl_owner;
unsigned int fl_pid;
- wait_queue_head_t fl_wait;
+ cfs_waitq_t fl_wait;
struct file *fl_file;
unsigned char fl_flags;
unsigned char fl_type;
union {
struct nfs_lock_info nfs_fl;
} fl_u;
-};
+} cfs_flock_t;
+
+#define cfs_flock_type(fl) ((fl)->fl_type)
+#define cfs_flock_set_type(fl, type) do { (fl)->fl_type = (type); } while(0)
+#define cfs_flock_pid(fl) ((fl)->fl_pid)
+#define cfs_flock_set_pid(fl, pid) do { (fl)->fl_pid = (pid); } while(0)
+#define cfs_flock_start(fl) ((fl)->fl_start)
+#define cfs_flock_set_start(fl, start) do { (fl)->fl_start = (start); } while(0)
+#define cfs_flock_end(fl) ((fl)->fl_end)
+#define cfs_flock_set_end(fl, end) do { (fl)->fl_end = (end); } while(0)
#ifndef OFFSET_MAX
#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
#define ENOTSUPP ENOTSUP
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_import.h>
-#include <linux/lustre_export.h>
-#include <linux/lustre_net.h>
+#include <obd_support.h>
+#include <lustre_idl.h>
+#include <lustre_lib.h>
+#include <lustre_import.h>
+#include <lustre_export.h>
+#include <lustre_net.h>
#endif
linux_HEADERS = lustre_idl.h
endif
-EXTRA_DIST = lprocfs_status.h lustre_debug.h lustre_ha.h lustre_lib.h \
- obd_cache.h obd_lov.h lustre_dlm.h lustre_handles.h \
- lustre_net.h obd_class.h obd_ost.h obd_support.h lustre_commit_confd.h \
- lustre_export.h lustre_log.h obd_echo.h \
- lustre_compat25.h lustre_fsfilt.h lustre_import.h lustre_mds.h obd.h \
- lvfs.h lvfs_linux.h lustre_cfg.h lustre_lite.h lustre_idl.h \
- lustre_quota.h lustre_ucache.h
+EXTRA_DIST = lprocfs_status.h lustre_debug.h lustre_lib.h \
+ lustre_dlm.h lustre_handles.h lustre_net.h obd_class.h obd_support.h \
+ lustre_log.h lustre_compat25.h lustre_fsfilt.h lustre_mds.h obd.h \
+ lvfs.h lvfs_linux.h lustre_lite.h lustre_idl.h lustre_quota.h lustre_user.h
* Top level header file for LProc SNMP
* Author: Hariharan Thantry thantry@users.sourceforge.net
*/
-#ifndef _LPROCFS_SNMP_H
-#define _LPROCFS_SNMP_H
+#ifndef _LINUX_LPROCFS_SNMP_H
+#define _LINUX_LPROCFS_SNMP_H
+#ifndef _LPROCFS_SNMP_H
+#error Do not #include this file directly. #include <lprocfs_status.h> instead
+#endif
#ifdef __KERNEL__
#include <linux/config.h>
#include <linux/autoconf.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/version.h>
#include <linux/smp.h>
#include <libcfs/kp30.h>
# define kstatfs statfs
#endif
-
-#undef LPROCFS
-#if (defined(__KERNEL__) && defined(CONFIG_PROC_FS))
-# define LPROCFS
-#endif
-
-struct lprocfs_vars {
- const char *name;
- read_proc_t *read_fptr;
- write_proc_t *write_fptr;
- void *data;
-};
-
-struct lprocfs_static_vars {
- struct lprocfs_vars *module_vars;
- struct lprocfs_vars *obd_vars;
-};
-
-/* An lprocfs counter can be configured using the enum bit masks below.
- *
- * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
- * protects this counter from concurrent updates. If not specified,
- * lprocfs an internal per-counter lock variable. External locks are
- * not used to protect counter increments, but are used to protect
- * counter readout and resets.
- *
- * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
- * (i.e. counter can be incremented by more than "1"). When specified,
- * the counter maintains min, max and sum in addition to a simple
- * invocation count. This allows averages to be be computed.
- * If not specified, the counter is an increment-by-1 counter.
- * min, max, sum, etc. are not maintained.
- *
- * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
- * squares (for multi-valued counter samples only). This allows
- * external computation of standard deviation, but involves a 64-bit
- * multiply per counter increment.
- */
-
-enum {
- LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
- LPROCFS_CNTR_AVGMINMAX = 0x0002,
- LPROCFS_CNTR_STDDEV = 0x0004,
-
- /* counter data type */
- LPROCFS_TYPE_REGS = 0x0100,
- LPROCFS_TYPE_BYTES = 0x0200,
- LPROCFS_TYPE_PAGES = 0x0400,
- LPROCFS_TYPE_CYCLE = 0x0800,
-};
-
-struct lprocfs_atomic {
- atomic_t la_entry;
- atomic_t la_exit;
-};
-
-struct lprocfs_counter {
- struct lprocfs_atomic lc_cntl; /* may need to move to per set */
- unsigned int lc_config;
- __u64 lc_count;
- __u64 lc_sum;
- __u64 lc_min;
- __u64 lc_max;
- __u64 lc_sumsquare;
- const char *lc_name; /* must be static */
- const char *lc_units; /* must be static */
-};
-
-struct lprocfs_percpu {
- struct lprocfs_counter lp_cntr[0];
-};
-
-
-struct lprocfs_stats {
- unsigned int ls_num; /* # of counters */
- unsigned int ls_percpu_size;
- struct lprocfs_percpu *ls_percpu[0];
-};
-
-
-/* class_obd.c */
-extern struct proc_dir_entry *proc_lustre_root;
-
-struct obd_device;
-struct file;
-struct obd_histogram;
-
-#ifdef LPROCFS
-
-/* Two optimized LPROCFS counter increment functions are provided:
- * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
- * lprocfs_counter_add(cntr) - use for multi-valued counters
- * Counter data layout allows config flag, counter lock and the
- * count itself to reside within a single cache line.
- */
-
-static inline void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
- long amount)
-{
- struct lprocfs_counter *percpu_cntr;
-
- LASSERT(stats != NULL);
- percpu_cntr = &(stats->ls_percpu[smp_processor_id()]->lp_cntr[idx]);
- atomic_inc(&percpu_cntr->lc_cntl.la_entry);
- percpu_cntr->lc_count++;
-
- if (percpu_cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) {
- percpu_cntr->lc_sum += amount;
- if (percpu_cntr->lc_config & LPROCFS_CNTR_STDDEV)
- percpu_cntr->lc_sumsquare += (__u64)amount * amount;
- if (amount < percpu_cntr->lc_min)
- percpu_cntr->lc_min = amount;
- if (amount > percpu_cntr->lc_max)
- percpu_cntr->lc_max = amount;
- }
- atomic_inc(&percpu_cntr->lc_cntl.la_exit);
-}
-
-static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, int idx)
-{
- struct lprocfs_counter *percpu_cntr;
-
- LASSERT(stats != NULL);
- percpu_cntr = &(stats->ls_percpu[smp_processor_id()]->lp_cntr[idx]);
- atomic_inc(&percpu_cntr->lc_cntl.la_entry);
- percpu_cntr->lc_count++;
- atomic_inc(&percpu_cntr->lc_cntl.la_exit);
-}
-
-extern struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num);
-extern void lprocfs_free_stats(struct lprocfs_stats *stats);
-extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
- unsigned int num_private_stats);
-extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
- unsigned conf, const char *name,
- const char *units);
-extern void lprocfs_free_obd_stats(struct obd_device *obddev);
-extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
- struct lprocfs_stats *stats);
-
-#define LPROCFS_INIT_VARS(name, vclass, vinstance) \
-void lprocfs_##name##_init_vars(struct lprocfs_static_vars *x) \
-{ \
- x->module_vars = vclass; \
- x->obd_vars = vinstance; \
-} \
-
-#define lprocfs_init_vars(NAME, VAR) \
-do { \
- extern void lprocfs_##NAME##_init_vars(struct lprocfs_static_vars *); \
- lprocfs_##NAME##_init_vars(VAR); \
-} while (0)
-/* lprocfs_status.c */
-extern int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
- void *data);
-
-extern struct proc_dir_entry *lprocfs_register(const char *name,
- struct proc_dir_entry *parent,
- struct lprocfs_vars *list,
- void *data);
-
-extern void lprocfs_remove(struct proc_dir_entry *root);
-
-extern struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *root,
- const char *name);
-
-extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
-extern int lprocfs_obd_cleanup(struct obd_device *obd);
-
-/* Generic callbacks */
-
-extern int lprocfs_rd_u64(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_atomic(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_uuid(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_name(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_fstype(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_wr_ping(struct file *file, const char *buffer,
- unsigned long count, void *data);
-
-/* Statfs helpers */
-extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_filestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-
-extern int lprocfs_write_helper(const char *buffer, unsigned long count,
- int *val);
-extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
- __u64 *val);
-int lprocfs_obd_seq_create(struct obd_device *dev, char *name, mode_t mode,
- struct file_operations *seq_fops, void *data);
-void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
-void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
-void lprocfs_oh_clear(struct obd_histogram *oh);
-unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
-
-/* lprocfs_status.c: counter read/write functions */
-extern int lprocfs_counter_read(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-extern int lprocfs_counter_write(struct file *file, const char *buffer,
- unsigned long count, void *data);
-
-/* lprocfs_status.c: recovery status */
-int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-#else
-/* LPROCFS is not defined */
-static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
- int index, long amount) { return; }
-static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
- int index) { return; }
-static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
- int index, unsigned conf,
- const char *name, const char *units)
-{ return; }
-
-static inline struct lprocfs_stats* lprocfs_alloc_stats(unsigned int num)
-{ return NULL; }
-static inline void lprocfs_free_stats(struct lprocfs_stats *stats)
-{ return; }
-
-static inline int lprocfs_register_stats(struct proc_dir_entry *root,
- const char *name,
- struct lprocfs_stats *stats)
-{ return 0; }
-static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
- unsigned int num_private_stats)
-{ return 0; }
-static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
-{ return; }
-
-static inline struct proc_dir_entry *
-lprocfs_register(const char *name, struct proc_dir_entry *parent,
- struct lprocfs_vars *list, void *data) { return NULL; }
-#define LPROCFS_INIT_VARS(name, vclass, vinstance)
-#define lprocfs_init_vars(...) do {} while (0)
-static inline int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
- void *data) { return 0; }
-static inline void lprocfs_remove(struct proc_dir_entry *root) {};
-static inline struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
- const char *name) {return 0;}
-static inline int lprocfs_obd_setup(struct obd_device *dev,
- struct lprocfs_vars *list) { return 0; }
-static inline int lprocfs_obd_cleanup(struct obd_device *dev) { return 0; }
-static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline int lprocfs_rd_name(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{ return 0; }
-static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{ return 0; }
-static inline int lprocfs_rd_num_exports(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{ return 0; }
-static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{ return 0; }
-static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{ return 0; }
-static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{ return 0; }
-
-
-/* Statfs helpers */
-static inline
-int lprocfs_rd_blksize(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_rd_filestotal(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_rd_filesfree(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_rd_filegroups(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value) {}
-static inline
-void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value) {}
-static inline
-void lprocfs_oh_clear(struct obd_histogram *oh) {}
-static inline
-unsigned long lprocfs_oh_sum(struct obd_histogram *oh) { return 0; }
-static inline
-int lprocfs_counter_read(char *page, char **start, off_t off,
- int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_counter_write(struct file *file, const char *buffer,
- unsigned long count, void *data) { return 0; }
-#endif /* LPROCFS */
-
#endif /* LPROCFS_SNMP_H */
*
*/
-#ifndef _COMPAT25_H
-#define _COMPAT25_H
+#ifndef _LINUX_COMPAT25_H
+#define _LINUX_COMPAT25_H
#ifdef __KERNEL__
*
*/
-#ifndef _LUSTRE_DEBUG_H
-#define _LUSTRE_DEBUG_H
-
-#include <linux/lustre_net.h>
-
-#define ASSERT_MAX_SIZE_MB 60000ULL
-#define ASSERT_PAGE_INDEX(index, OP) \
-do { if (index > ASSERT_MAX_SIZE_MB << (20 - PAGE_SHIFT)) { \
- CERROR("bad page index %lu > %Lu\n", index, \
- ASSERT_MAX_SIZE_MB << (20 - PAGE_SHIFT)); \
- libcfs_debug = ~0UL; \
- OP; \
-}} while(0)
+#ifndef _LINUX_LUSTRE_DEBUG_H
+#define _LINUX_LUSTRE_DEBUG_H
-#define ASSERT_FILE_OFFSET(offset, OP) \
-do { if (offset > ASSERT_MAX_SIZE_MB << 20) { \
- CERROR("bad file offset %Lu > %Lu\n", offset, \
- ASSERT_MAX_SIZE_MB << 20); \
- libcfs_debug = ~0UL; \
- OP; \
-}} while(0)
+#ifndef _LUSTRE_DEBUG_H
+#error Do not #include this file directly. #include <lprocfs_status.h> instead
+#endif
#ifdef __KERNEL__
#define LL_CDEBUG_PAGE(mask, page, fmt, arg...) \
fmt, page, page->index, page->private, ## arg)
#endif
-/* lib/debug.c */
-int dump_lniobuf(struct niobuf_local *lnb);
-int dump_rniobuf(struct niobuf_remote *rnb);
-int dump_ioo(struct obd_ioobj *nb);
-int dump_req(struct ptlrpc_request *req);
-int dump_obdo(struct obdo *oa);
-void dump_lsm(int level, struct lov_stripe_md *lsm);
-int block_debug_setup(void *addr, int len, __u64 off, __u64 id);
-int block_debug_check(char *who, void *addr, int len, __u64 off, __u64 id);
#endif
* vim:expandtab:shiftwidth=8:tabstop=8:
*/
+#ifndef _LINUX_LUSTRE_DLM_H__
+#define _LINUX_LUSTRE_DLM_H__
+
#ifndef _LUSTRE_DLM_H__
-#define _LUSTRE_DLM_H__
+#error Do not #include this file directly. #include <lprocfs_status.h> instead
+#endif
#ifdef __KERNEL__
# include <linux/proc_fs.h>
#endif
-#include <linux/lustre_lib.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_import.h>
-#include <linux/lustre_handles.h>
-#include <linux/lustre_export.h> /* for obd_export, for LDLM_DEBUG */
-
-struct obd_ops;
-struct obd_device;
-
-#define OBD_LDLM_DEVICENAME "ldlm"
-
-#define LDLM_DEFAULT_LRU_SIZE 100
-
-typedef enum {
- ELDLM_OK = 0,
-
- ELDLM_LOCK_CHANGED = 300,
- ELDLM_LOCK_ABORTED = 301,
- ELDLM_LOCK_REPLACED = 302,
- ELDLM_NO_LOCK_DATA = 303,
-
- ELDLM_NAMESPACE_EXISTS = 400,
- ELDLM_BAD_NAMESPACE = 401
-} ldlm_error_t;
-
-#define LDLM_NAMESPACE_SERVER 0
-#define LDLM_NAMESPACE_CLIENT 1
-
-#define LDLM_FL_LOCK_CHANGED 0x000001 /* extent, mode, or resource changed */
-
-/* If the server returns one of these flags, then the lock was put on that list.
- * If the client sends one of these flags (during recovery ONLY!), it wants the
- * lock added to the specified list, no questions asked. -p */
-#define LDLM_FL_BLOCK_GRANTED 0x000002
-#define LDLM_FL_BLOCK_CONV 0x000004
-#define LDLM_FL_BLOCK_WAIT 0x000008
-
-#define LDLM_FL_CBPENDING 0x000010 /* this lock is being destroyed */
-#define LDLM_FL_AST_SENT 0x000020 /* blocking or cancel packet was sent */
-#define LDLM_FL_WAIT_NOREPROC 0x000040 /* not a real flag, not saved in lock */
-#define LDLM_FL_CANCEL 0x000080 /* cancellation callback already run */
-
-/* Lock is being replayed. This could probably be implied by the fact that one
- * of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */
-#define LDLM_FL_REPLAY 0x000100
-
-#define LDLM_FL_INTENT_ONLY 0x000200 /* don't grant lock, just do intent */
-#define LDLM_FL_LOCAL_ONLY 0x000400 /* see ldlm_cli_cancel_unused */
-
-/* don't run the cancel callback under ldlm_cli_cancel_unused */
-#define LDLM_FL_FAILED 0x000800
-
-#define LDLM_FL_HAS_INTENT 0x001000 /* lock request has intent */
-#define LDLM_FL_CANCELING 0x002000 /* lock cancel has already been sent */
-#define LDLM_FL_LOCAL 0x004000 /* local lock (ie, no srv/cli split) */
-#define LDLM_FL_WARN 0x008000 /* see ldlm_cli_cancel_unused */
-#define LDLM_FL_DISCARD_DATA 0x010000 /* discard (no writeback) on cancel */
-
-#define LDLM_FL_NO_TIMEOUT 0x020000 /* Blocked by group lock - wait
- * indefinitely */
-
-/* file & record locking */
-#define LDLM_FL_BLOCK_NOWAIT 0x040000 // server told not to wait if blocked
-#define LDLM_FL_TEST_LOCK 0x080000 // return blocking lock
-
-/* XXX FIXME: This is being added to b_size as a low-risk fix to the fact that
- * the LVB filling happens _after_ the lock has been granted, so another thread
- * can match before the LVB has been updated. As a dirty hack, we set
- * LDLM_FL_CAN_MATCH only after we've done the LVB poop.
- *
- * The proper fix is to do the granting inside of the completion AST, which can
- * be replaced with a LVB-aware wrapping function for OSC locks. That change is
- * pretty high-risk, though, and would need a lot more testing. */
-#define LDLM_FL_CAN_MATCH 0x100000
-
-/* A lock contributes to the kms calculation until it has finished the part
- * of it's cancelation that performs write back on its dirty pages. It
- * can remain on the granted list during this whole time. Threads racing
- * to update the kms after performing their writeback need to know to
- * exclude each others locks from the calculation as they walk the granted
- * list. */
-#define LDLM_FL_KMS_IGNORE 0x200000
-
-/* Don't drop lock covering mmapped file in LRU */
-#define LDLM_FL_NO_LRU 0x400000
-
-/* Immediatelly cancel such locks when they block some other locks. Send
- cancel notification to original lock holder, but expect no reply. */
-#define LDLM_FL_CANCEL_ON_BLOCK 0x800000
-
-/* Flags flags inherited from parent lock when doing intents. */
-#define LDLM_INHERIT_FLAGS (LDLM_FL_CANCEL_ON_BLOCK)
-
-/* These are flags that are mapped into the flags and ASTs of blocking locks */
-#define LDLM_AST_DISCARD_DATA 0x80000000 /* Add FL_DISCARD to blocking ASTs */
-/* Flags sent in AST lock_flags to be mapped into the receiving lock. */
-#define LDLM_AST_FLAGS (LDLM_FL_DISCARD_DATA)
-
-/* The blocking callback is overloaded to perform two functions. These flags
- * indicate which operation should be performed. */
-#define LDLM_CB_BLOCKING 1
-#define LDLM_CB_CANCELING 2
-
-/* compatibility matrix */
-#define LCK_COMPAT_EX LCK_NL
-#define LCK_COMPAT_PW (LCK_COMPAT_EX | LCK_CR)
-#define LCK_COMPAT_PR (LCK_COMPAT_PW | LCK_PR)
-#define LCK_COMPAT_CW (LCK_COMPAT_PW | LCK_CW)
-#define LCK_COMPAT_CR (LCK_COMPAT_CW | LCK_PR | LCK_PW)
-#define LCK_COMPAT_NL (LCK_COMPAT_CR | LCK_EX)
-#define LCK_COMPAT_GROUP (LCK_GROUP | LCK_NL)
-
-static ldlm_mode_t lck_compat_array[] = {
- [LCK_EX] LCK_COMPAT_EX,
- [LCK_PW] LCK_COMPAT_PW,
- [LCK_PR] LCK_COMPAT_PR,
- [LCK_CW] LCK_COMPAT_CW,
- [LCK_CR] LCK_COMPAT_CR,
- [LCK_NL] LCK_COMPAT_NL,
- [LCK_GROUP] LCK_COMPAT_GROUP
-};
-
-static inline void lockmode_verify(ldlm_mode_t mode)
-{
- LASSERT(mode > LCK_MINMODE && mode < LCK_MAXMODE);
-}
-
-static inline int lockmode_compat(ldlm_mode_t exist, ldlm_mode_t new)
-{
- return (lck_compat_array[exist] & new);
-}
-
-/*
- *
- * cluster name spaces
- *
- */
-
-#define DLM_OST_NAMESPACE 1
-#define DLM_MDS_NAMESPACE 2
-
-/* XXX
- - do we just separate this by security domains and use a prefix for
- multiple namespaces in the same domain?
- -
-*/
-
-struct ldlm_lock;
-struct ldlm_resource;
-struct ldlm_namespace;
-
-typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **,
- void *req_cookie, ldlm_mode_t mode, int flags,
- void *data);
-
-struct ldlm_valblock_ops {
- int (*lvbo_init)(struct ldlm_resource *res);
- int (*lvbo_update)(struct ldlm_resource *res, struct lustre_msg *m,
- int buf_idx, int increase);
-};
-
-struct ldlm_namespace {
- char *ns_name;
- __u32 ns_client; /* is this a client-side lock tree? */
- struct list_head *ns_hash; /* hash table for ns */
- wait_queue_head_t ns_refcount_waitq; /* for cleanup */
- atomic_t ns_refcount; /* count of resources in the hash */
- struct list_head ns_root_list; /* all root resources in ns */
- struct lustre_lock ns_lock; /* protects hash, refcount, list */
- struct list_head ns_list_chain; /* position in global NS list */
-
- struct list_head ns_unused_list; /* all root resources in ns */
- int ns_nr_unused;
- unsigned int ns_max_unused;
- unsigned long ns_next_dump; /* next debug dump, jiffies */
-
- spinlock_t ns_counter_lock;
- __u64 ns_locks;
- ldlm_res_policy ns_policy;
- struct ldlm_valblock_ops *ns_lvbo;
- void *ns_lvbp;
-};
-
-/*
- *
- * Resource hash table
- *
- */
-
-#define RES_HASH_BITS 10
-#define RES_HASH_SIZE (1UL << RES_HASH_BITS)
-#define RES_HASH_MASK (RES_HASH_SIZE - 1)
-
-struct ldlm_lock;
-
-typedef int (*ldlm_blocking_callback)(struct ldlm_lock *lock,
- struct ldlm_lock_desc *new, void *data,
- int flag);
-typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags,
- void *data);
-typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);
-
-struct ldlm_lock {
- struct portals_handle l_handle; // must be first in the structure
- atomic_t l_refc;
- struct ldlm_resource *l_resource;
- struct ldlm_lock *l_parent;
- struct list_head l_children;
- struct list_head l_childof;
- struct list_head l_lru;
- struct list_head l_res_link; // position in one of three res lists
- struct list_head l_export_chain; // per-export chain of locks
-
- ldlm_mode_t l_req_mode;
- ldlm_mode_t l_granted_mode;
-
- ldlm_completion_callback l_completion_ast;
- ldlm_blocking_callback l_blocking_ast;
- ldlm_glimpse_callback l_glimpse_ast;
-
- struct obd_export *l_export;
- struct obd_export *l_conn_export;
- __u32 l_flags;
- struct lustre_handle l_remote_handle;
- ldlm_policy_data_t l_policy_data;
-
- __u32 l_readers;
- __u32 l_writers;
- __u8 l_destroyed;
-
- /* If the lock is granted, a process sleeps on this waitq to learn when
- * it's no longer in use. If the lock is not granted, a process sleeps
- * on this waitq to learn when it becomes granted. */
- wait_queue_head_t l_waitq;
- struct timeval l_enqueued_time;
-
- unsigned long l_last_used; /* jiffies */
- struct ldlm_extent l_req_extent;
-
- /* Client-side-only members */
- __u32 l_lvb_len; /* temporary storage for */
- void *l_lvb_data; /* an LVB received during */
- void *l_lvb_swabber; /* an enqueue */
- void *l_ast_data;
-
- /* Server-side-only members */
- struct list_head l_pending_chain; /* callbacks pending */
- unsigned long l_callback_timeout; /* jiffies */
-
- __u32 l_pid; /* pid which created this lock */
-};
-
-struct ldlm_resource {
- struct ldlm_namespace *lr_namespace;
- struct list_head lr_hash;
- struct ldlm_resource *lr_parent; /* 0 for a root resource */
- struct list_head lr_children; /* list head for child resources */
- struct list_head lr_childof; /* part of ns_root_list if root res,
- * part of lr_children if child */
-
- struct list_head lr_granted;
- struct list_head lr_converting;
- struct list_head lr_waiting;
- ldlm_mode_t lr_most_restr;
- ldlm_type_t lr_type; /* LDLM_{PLAIN,EXTENT,FLOCK} */
- struct ldlm_resource *lr_root;
- struct ldlm_res_id lr_name;
- atomic_t lr_refcount;
-
- /* Server-side-only lock value block elements */
- struct semaphore lr_lvb_sem;
- __u32 lr_lvb_len;
- void *lr_lvb_data;
-
- /* lr_tmp holds a list head temporarily, during the building of a work
- * queue. see ldlm_add_ast_work_item and ldlm_run_ast_work */
- void *lr_tmp;
-};
-
-struct ldlm_ast_work {
- struct ldlm_lock *w_lock;
- int w_blocking;
- struct ldlm_lock_desc w_desc;
- struct list_head w_list;
- int w_flags;
- void *w_data;
- int w_datalen;
-};
-
-extern struct obd_ops ldlm_obd_ops;
-
-extern char *ldlm_lockname[];
-extern char *ldlm_typename[];
-extern char *ldlm_it2str(int it);
-
-#define __LDLM_DEBUG(level, lock, format, a...) \
-do { \
- if (lock->l_resource == NULL) { \
- CDEBUG(level, "### " format \
- " ns: \?\? lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "\
- "res: \?\? rrc=\?\? type: \?\?\? flags: %x remote: " \
- LPX64" expref: %d pid: %u\n" , ## a, lock, \
- lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
- lock->l_readers, lock->l_writers, \
- ldlm_lockname[lock->l_granted_mode], \
- ldlm_lockname[lock->l_req_mode], \
- lock->l_flags, lock->l_remote_handle.cookie, \
- lock->l_export ? \
- atomic_read(&lock->l_export->exp_refcount) : -99, \
- lock->l_pid); \
- break; \
- } \
- if (lock->l_resource->lr_type == LDLM_EXTENT) { \
- CDEBUG(level, "### " format \
- " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
- "res: "LPU64"/"LPU64" rrc: %d type: %s ["LPU64"->"LPU64\
- "] (req "LPU64"->"LPU64") flags: %x remote: "LPX64 \
- " expref: %d pid: %u\n" , ## a, \
- lock->l_resource->lr_namespace->ns_name, lock, \
- lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
- lock->l_readers, lock->l_writers, \
- ldlm_lockname[lock->l_granted_mode], \
- ldlm_lockname[lock->l_req_mode], \
- lock->l_resource->lr_name.name[0], \
- lock->l_resource->lr_name.name[1], \
- atomic_read(&lock->l_resource->lr_refcount), \
- ldlm_typename[lock->l_resource->lr_type], \
- lock->l_policy_data.l_extent.start, \
- lock->l_policy_data.l_extent.end, \
- lock->l_req_extent.start, lock->l_req_extent.end, \
- lock->l_flags, lock->l_remote_handle.cookie, \
- lock->l_export ? \
- atomic_read(&lock->l_export->exp_refcount) : -99, \
- lock->l_pid); \
- break; \
- } \
- if (lock->l_resource->lr_type == LDLM_FLOCK) { \
- CDEBUG(level, "### " format \
- " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
- "res: "LPU64"/"LPU64" rrc: %d type: %s pid: %d " \
- "["LPU64"->"LPU64"] flags: %x remote: "LPX64 \
- " expref: %d pid: %u\n" , ## a, \
- lock->l_resource->lr_namespace->ns_name, lock, \
- lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
- lock->l_readers, lock->l_writers, \
- ldlm_lockname[lock->l_granted_mode], \
- ldlm_lockname[lock->l_req_mode], \
- lock->l_resource->lr_name.name[0], \
- lock->l_resource->lr_name.name[1], \
- atomic_read(&lock->l_resource->lr_refcount), \
- ldlm_typename[lock->l_resource->lr_type], \
- lock->l_policy_data.l_flock.pid, \
- lock->l_policy_data.l_flock.start, \
- lock->l_policy_data.l_flock.end, \
- lock->l_flags, lock->l_remote_handle.cookie, \
- lock->l_export ? \
- atomic_read(&lock->l_export->exp_refcount) : -99, \
- lock->l_pid); \
- break; \
- } \
- if (lock->l_resource->lr_type == LDLM_IBITS) { \
- CDEBUG(level, "### " format \
- " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
- "res: "LPU64"/"LPU64" bits "LPX64" rrc: %d type: %s " \
- "flags: %x remote: "LPX64" expref: %d " \
- "pid %u\n" , ## a, \
- lock->l_resource->lr_namespace->ns_name, \
- lock, lock->l_handle.h_cookie, \
- atomic_read (&lock->l_refc), \
- lock->l_readers, lock->l_writers, \
- ldlm_lockname[lock->l_granted_mode], \
- ldlm_lockname[lock->l_req_mode], \
- lock->l_resource->lr_name.name[0], \
- lock->l_resource->lr_name.name[1], \
- lock->l_policy_data.l_inodebits.bits, \
- atomic_read(&lock->l_resource->lr_refcount), \
- ldlm_typename[lock->l_resource->lr_type], \
- lock->l_flags, lock->l_remote_handle.cookie, \
- lock->l_export ? \
- atomic_read(&lock->l_export->exp_refcount) : -99, \
- lock->l_pid); \
- break; \
- } \
- { \
- CDEBUG(level, "### " format \
- " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
- "res: "LPU64"/"LPU64" rrc: %d type: %s flags: %x " \
- "remote: "LPX64" expref: %d pid: %u\n" , ## a, \
- lock->l_resource->lr_namespace->ns_name, \
- lock, lock->l_handle.h_cookie, \
- atomic_read (&lock->l_refc), \
- lock->l_readers, lock->l_writers, \
- ldlm_lockname[lock->l_granted_mode], \
- ldlm_lockname[lock->l_req_mode], \
- lock->l_resource->lr_name.name[0], \
- lock->l_resource->lr_name.name[1], \
- atomic_read(&lock->l_resource->lr_refcount), \
- ldlm_typename[lock->l_resource->lr_type], \
- lock->l_flags, lock->l_remote_handle.cookie, \
- lock->l_export ? \
- atomic_read(&lock->l_export->exp_refcount) : -99, \
- lock->l_pid); \
- } \
-} while (0)
-
-#define LDLM_DEBUG(lock, format, a...) __LDLM_DEBUG(D_DLMTRACE, lock, \
- format, ## a)
-#define LDLM_ERROR(lock, format, a...) __LDLM_DEBUG(D_ERROR, lock, format, ## a)
-
-#define LDLM_DEBUG_NOLOCK(format, a...) \
- CDEBUG(D_DLMTRACE, "### " format "\n" , ## a)
-
-typedef int (*ldlm_processing_policy)(struct ldlm_lock *lock, int *flags,
- int first_enq, ldlm_error_t *err);
-
-/*
- * Iterators.
- */
-
-#define LDLM_ITER_CONTINUE 1 /* keep iterating */
-#define LDLM_ITER_STOP 2 /* stop iterating */
-
-typedef int (*ldlm_iterator_t)(struct ldlm_lock *, void *);
-typedef int (*ldlm_res_iterator_t)(struct ldlm_resource *, void *);
-
-int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
- void *closure);
-int ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter,
- void *closure);
-int ldlm_namespace_foreach_res(struct ldlm_namespace *ns,
- ldlm_res_iterator_t iter, void *closure);
-
-int ldlm_replay_locks(struct obd_import *imp);
-void ldlm_change_cbdata(struct ldlm_namespace *, struct ldlm_res_id *,
- ldlm_iterator_t iter, void *data);
-
-/* ldlm_flock.c */
-int ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data);
-
-/* ldlm_extent.c */
-__u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms);
-
-
-/* ldlm_lockd.c */
-int ldlm_server_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
- void *data, int flag);
-int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data);
-int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data);
-int ldlm_handle_enqueue(struct ptlrpc_request *req, ldlm_completion_callback,
- ldlm_blocking_callback, ldlm_glimpse_callback);
-int ldlm_handle_convert(struct ptlrpc_request *req);
-int ldlm_handle_cancel(struct ptlrpc_request *req);
-int ldlm_del_waiting_lock(struct ldlm_lock *lock);
-int ldlm_get_ref(void);
-void ldlm_put_ref(int force);
-
-/* ldlm_lock.c */
-ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res);
-void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg);
-void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh);
-struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *, int flags);
-void ldlm_cancel_callback(struct ldlm_lock *);
-int ldlm_lock_set_data(struct lustre_handle *, void *data);
-void ldlm_lock_remove_from_lru(struct ldlm_lock *);
-struct ldlm_lock *ldlm_handle2lock_ns(struct ldlm_namespace *,
- struct lustre_handle *);
-
-static inline struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *h)
-{
- return __ldlm_handle2lock(h, 0);
-}
-
-#define LDLM_LOCK_PUT(lock) \
-do { \
- /*LDLM_DEBUG((lock), "put");*/ \
- ldlm_lock_put(lock); \
-} while (0)
-
-#define LDLM_LOCK_GET(lock) \
-({ \
- ldlm_lock_get(lock); \
- /*LDLM_DEBUG((lock), "get");*/ \
- lock; \
-})
-
-struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
-void ldlm_lock_put(struct ldlm_lock *lock);
-void ldlm_lock_destroy(struct ldlm_lock *lock);
-void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc);
-void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode);
-void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode);
-void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode);
-void ldlm_lock_allow_match(struct ldlm_lock *lock);
-int ldlm_lock_match(struct ldlm_namespace *ns, int flags, struct ldlm_res_id *,
- __u32 type, ldlm_policy_data_t *, ldlm_mode_t mode,
- struct lustre_handle *);
-struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
- int *flags);
-void ldlm_lock_cancel(struct ldlm_lock *lock);
-void ldlm_cancel_locks_for_export(struct obd_export *export);
-void ldlm_reprocess_all(struct ldlm_resource *res);
-void ldlm_reprocess_all_ns(struct ldlm_namespace *ns);
-void ldlm_lock_dump(int level, struct ldlm_lock *lock, int pos);
-void ldlm_lock_dump_handle(int level, struct lustre_handle *);
-
-/* resource.c */
-struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 local);
-int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int flags);
-int ldlm_namespace_free(struct ldlm_namespace *ns, int force);
-int ldlm_proc_setup(void);
-#ifdef LPROCFS
-void ldlm_proc_cleanup(void);
-#else
-static inline void ldlm_proc_cleanup(void) {}
-#endif
-
-/* resource.c - internal */
-struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
- struct ldlm_resource *parent,
- struct ldlm_res_id, __u32 type,
- int create);
-struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res);
-int ldlm_resource_putref(struct ldlm_resource *res);
-void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head,
- struct ldlm_lock *lock);
-void ldlm_resource_unlink_lock(struct ldlm_lock *lock);
-void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc);
-void ldlm_dump_all_namespaces(int level);
-void ldlm_namespace_dump(int level, struct ldlm_namespace *);
-void ldlm_resource_dump(int level, struct ldlm_resource *);
-int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
- struct ldlm_res_id);
-
-/* ldlm_request.c */
-int ldlm_expired_completion_wait(void *data);
-int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
- void *data, int flag);
-int ldlm_glimpse_ast(struct ldlm_lock *lock, void *reqp);
-int ldlm_completion_ast(struct ldlm_lock *lock, int flags, void *data);
-int ldlm_cli_enqueue(struct obd_export *exp,
- struct ptlrpc_request *req,
- struct ldlm_namespace *ns,
- struct ldlm_res_id,
- __u32 type,
- ldlm_policy_data_t *,
- ldlm_mode_t mode,
- int *flags,
- ldlm_blocking_callback blocking,
- ldlm_completion_callback completion,
- ldlm_glimpse_callback glimpse,
- void *data,
- void *lvb,
- __u32 lvb_len,
- void *lvb_swabber,
- struct lustre_handle *lockh);
-int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new,
- void *data, __u32 data_len);
-int ldlm_cli_convert(struct lustre_handle *, int new_mode, int *flags);
-int ldlm_cli_cancel(struct lustre_handle *lockh);
-int ldlm_cli_cancel_unused(struct ldlm_namespace *, struct ldlm_res_id *,
- int flags, void *opaque);
-int ldlm_cli_join_lru(struct ldlm_namespace *, struct ldlm_res_id *,
- int join);
-
-/* mds/handler.c */
-/* This has to be here because recursive inclusion sucks. */
-int intent_disposition(struct ldlm_reply *rep, int flag);
-void intent_set_disposition(struct ldlm_reply *rep, int flag);
-
-
-/* ioctls for trying requests */
-#define IOC_LDLM_TYPE 'f'
-#define IOC_LDLM_MIN_NR 40
-
-#define IOC_LDLM_TEST _IOWR('f', 40, long)
-#define IOC_LDLM_DUMP _IOWR('f', 41, long)
-#define IOC_LDLM_REGRESS_START _IOWR('f', 42, long)
-#define IOC_LDLM_REGRESS_STOP _IOWR('f', 43, long)
-#define IOC_LDLM_MAX_NR 43
-
#endif
*
*/
+#ifndef _LINUX_LUSTRE_FSFILT_H
+#define _LINUX_LUSTRE_FSFILT_H
+
#ifndef _LUSTRE_FSFILT_H
-#define _LUSTRE_FSFILT_H
+#error Do not #include this file directly. #include <lustre_fsfilt.h> instead
+#endif
#ifdef __KERNEL__
-#include <linux/obd.h>
-#include <linux/obd_class.h>
+#include <obd.h>
+#include <obd_class.h>
typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd,
void *data, int error);
-#ifndef __LINUX_HANDLES_H_
-#define __LINUX_HANDLES_H_
+#ifndef __LINUX_LUSTRE_HANDLES_H_
+#define __LINUX_LUSTRE_HANDLES_H_
+
+#ifndef __LUSTRE_HANDLES_H_
+#error Do not #include this file directly. #include <lustre_handles.h> instead
+#endif
#ifdef __KERNEL__
#include <asm/types.h>
#include <linux/list.h>
#endif
-typedef void (*portals_handle_addref_cb)(void *object);
-
-/* These handles are most easily used by having them appear at the very top of
- * whatever object that you want to make handles for. ie:
- *
- * struct ldlm_lock {
- * struct portals_handle handle;
- * ...
- * };
- *
- * Now you're able to assign the results of cookie2handle directly to an
- * ldlm_lock. If it's not at the top, you'll want to hack up a macro that
- * uses some offsetof() magic. */
-
-struct portals_handle {
- struct list_head h_link;
- __u64 h_cookie;
- portals_handle_addref_cb h_addref;
-};
-
-/* handles.c */
-
-/* Add a handle to the hash table */
-void class_handle_hash(struct portals_handle *, portals_handle_addref_cb);
-void class_handle_unhash(struct portals_handle *);
-void *class_handle2object(__u64 cookie);
-int class_handle_init(void);
-void class_handle_cleanup(void);
-
#endif
* verified that the message buffer is large enough.
*/
+#ifndef _LINUX_LUSTRE_IDL_H_
+#define _LINUX_LUSTRE_IDL_H_
+
#ifndef _LUSTRE_IDL_H_
-#define _LUSTRE_IDL_H_
+#error Do not #include this file directly. #include <lustre_idl.h> instead
+#endif
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
#endif
#endif
-/* Defn's shared with user-space. */
-#include <lustre/lustre_user.h>
-
-/*
- * this file contains all data structures used in Lustre interfaces:
- * - obdo and obd_request records
- * - mds_request records
- * - ldlm data
- * - ioctl's
- */
-
-/*
- * GENERAL STUFF
- */
-/* FOO_REQUEST_PORTAL is for incoming requests on the FOO
- * FOO_REPLY_PORTAL is for incoming replies on the FOO
- * FOO_BULK_PORTAL is for incoming bulk on the FOO
- */
-
-#define CONNMGR_REQUEST_PORTAL 1
-#define CONNMGR_REPLY_PORTAL 2
-//#define OSC_REQUEST_PORTAL 3
-#define OSC_REPLY_PORTAL 4
-//#define OSC_BULK_PORTAL 5
-#define OST_REQUEST_PORTAL 6
-#define OST_CREATE_PORTAL 7
-#define OST_BULK_PORTAL 8
-//#define MDC_REQUEST_PORTAL 9
-#define MDC_REPLY_PORTAL 10
-//#define MDC_BULK_PORTAL 11
-#define MDS_REQUEST_PORTAL 12
-//#define MDS_REPLY_PORTAL 13
-#define MDS_BULK_PORTAL 14
-#define LDLM_CB_REQUEST_PORTAL 15
-#define LDLM_CB_REPLY_PORTAL 16
-#define LDLM_CANCEL_REQUEST_PORTAL 17
-#define LDLM_CANCEL_REPLY_PORTAL 18
-#define PTLBD_REQUEST_PORTAL 19
-#define PTLBD_REPLY_PORTAL 20
-#define PTLBD_BULK_PORTAL 21
-#define MDS_SETATTR_PORTAL 22
-#define MDS_READPAGE_PORTAL 23
-#define MGMT_REQUEST_PORTAL 24
-#define MGMT_REPLY_PORTAL 25
-#define MGMT_CLI_REQUEST_PORTAL 26
-#define MGMT_CLI_REPLY_PORTAL 27
-
-#define SVC_KILLED 1
-#define SVC_EVENT 2
-#define SVC_SIGNAL 4
-#define SVC_RUNNING 8
-#define SVC_STOPPING 16
-#define SVC_STOPPED 32
-
-/* packet types */
-#define PTL_RPC_MSG_REQUEST 4711
-#define PTL_RPC_MSG_ERR 4712
-#define PTL_RPC_MSG_REPLY 4713
-
-#define PTLRPC_MSG_MAGIC 0x0BD00BD0
-
-
-#define PTLRPC_MSG_VERSION 0x00000003
-#define LUSTRE_VERSION_MASK 0xffff0000
-#define LUSTRE_OBD_VERSION 0x00010000
-#define LUSTRE_MDS_VERSION 0x00020000
-#define LUSTRE_OST_VERSION 0x00030000
-#define LUSTRE_DLM_VERSION 0x00040000
-#define LUSTRE_LOG_VERSION 0x00050000
-#define LUSTRE_PBD_VERSION 0x00060000
-
-struct lustre_handle {
- __u64 cookie;
-};
-#define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabeULL
-
-/* we depend on this structure to be 8-byte aligned */
-/* this type is only endian-adjusted in lustre_unpack_msg() */
-struct lustre_msg {
- struct lustre_handle handle;
- __u32 magic;
- __u32 type;
- __u32 version;
- __u32 opc;
- __u64 last_xid;
- __u64 last_committed;
- __u64 transno;
- __u32 status;
- __u32 flags;
- __u32 conn_cnt;
- __u32 bufcount;
- __u32 buflens[0];
-};
-
-/* Flags that are operation-specific go in the top 16 bits. */
-#define MSG_OP_FLAG_MASK 0xffff0000
-#define MSG_OP_FLAG_SHIFT 16
-
-/* Flags that apply to all requests are in the bottom 16 bits */
-#define MSG_GEN_FLAG_MASK 0x0000ffff
-#define MSG_LAST_REPLAY 1
-#define MSG_RESENT 2
-#define MSG_REPLAY 4
-
-static inline int lustre_msg_get_flags(struct lustre_msg *msg)
-{
- return (msg->flags & MSG_GEN_FLAG_MASK);
-}
-
-static inline void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags |= MSG_GEN_FLAG_MASK & flags;
-}
-
-static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags &= ~MSG_GEN_FLAG_MASK;
- lustre_msg_add_flags(msg, flags);
-}
-
-static inline void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags &= ~(MSG_GEN_FLAG_MASK & flags);
-}
-
-static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
-{
- return (msg->flags >> MSG_OP_FLAG_SHIFT);
-}
-
-static inline void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
-}
-
-static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
-{
- msg->flags &= ~MSG_OP_FLAG_MASK;
- lustre_msg_add_op_flags(msg, flags);
-}
-
-/*
- * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
- */
-
-#define MSG_CONNECT_RECOVERING 0x1
-#define MSG_CONNECT_RECONNECT 0x2
-#define MSG_CONNECT_REPLAYABLE 0x4
-//#define MSG_CONNECT_PEER 0x8
-#define MSG_CONNECT_LIBCLIENT 0x10
-#define MSG_CONNECT_INITIAL 0x20
-#define MSG_CONNECT_ASYNC 0x40
-
-/* Connect flags */
-#define OBD_CONNECT_RDONLY 0x0001ULL
-#define OBD_CONNECT_SRVLOCK 0x0010ULL /* server takes locks for client */
-#define OBD_CONNECT_ACL 0x0080ULL
-#define OBD_CONNECT_USER_XATTR 0x0100ULL
-#define OBD_CONNECT_CROW 0x0200ULL /* OST is CROW able */
-
-#define MDS_CONNECT_SUPPORTED (OBD_CONNECT_RDONLY | \
- OBD_CONNECT_ACL | \
- OBD_CONNECT_USER_XATTR)
-#define OST_CONNECT_SUPPORTED (OBD_CONNECT_SRVLOCK | OBD_CONNECT_CROW)
-#define ECHO_CONNECT_SUPPORTED (0)
-
-/* This structure is used for both request and reply.
- *
- * If we eventually have separate connect data for different types, which we
- * almost certainly will, then perhaps we stick a union in here. */
-struct obd_connect_data {
- __u64 ocd_connect_flags; /* connection flags, server should return
- * subset of what is asked for. */
-
- __u64 padding[8];
-};
-
-extern void lustre_swab_connect(struct obd_connect_data *ocd);
-
-/*
- * OST requests: OBDO & OBD request records
- */
-
-/* opcodes */
-typedef enum {
- OST_REPLY = 0, /* reply ? */
- OST_GETATTR = 1,
- OST_SETATTR = 2,
- OST_READ = 3,
- OST_WRITE = 4,
- OST_CREATE = 5,
- OST_DESTROY = 6,
- OST_GET_INFO = 7,
- OST_CONNECT = 8,
- OST_DISCONNECT = 9,
- OST_PUNCH = 10,
- OST_OPEN = 11,
- OST_CLOSE = 12,
- OST_STATFS = 13,
- OST_SAN_READ = 14,
- OST_SAN_WRITE = 15,
- OST_SYNC = 16,
- OST_SET_INFO = 17,
- OST_QUOTACHECK = 18,
- OST_QUOTACTL = 19,
- OST_LAST_OPC
-} ost_cmd_t;
-#define OST_FIRST_OPC OST_REPLY
-
-typedef uint64_t obd_id;
-typedef uint64_t obd_gr;
-typedef uint64_t obd_time;
-typedef uint64_t obd_size;
-typedef uint64_t obd_off;
-typedef uint64_t obd_blocks;
-typedef uint32_t obd_blksize;
-typedef uint32_t obd_mode;
-typedef uint32_t obd_uid;
-typedef uint32_t obd_gid;
-typedef uint32_t obd_flag;
-typedef uint64_t obd_valid;
-typedef uint32_t obd_count;
-
-#define OBD_FL_INLINEDATA (0x00000001)
-#define OBD_FL_OBDMDEXISTS (0x00000002)
-#define OBD_FL_DELORPHAN (0x00000004) /* if set in o_flags delete orphans */
-#define OBD_FL_NORPC (0x00000008) /* set in o_flags do in OSC not OST */
-#define OBD_FL_IDONLY (0x00000010) /* set in o_flags only adjust obj id*/
-#define OBD_FL_RECREATE_OBJS (0x00000020) /* recreate missing obj */
-#define OBD_FL_DEBUG_CHECK (0x00000040) /* echo client/server debug check */
-#define OBD_FL_NO_USRQUOTA (0x00000100) /* the object's owner is over quota */
-#define OBD_FL_NO_GRPQUOTA (0x00000200) /* the object's group is over quota */
-#define OBD_FL_CREATE_CROW (0x00000400) /* object should be created with crow */
-
-/* this should be not smaller than sizeof(struct lustre_handle) + sizeof(struct
- * llog_cookie) + sizeof(ll_fid). Nevertheless struct ll_fid is not longer
- * stored in o_inline, we keep this just for case. */
-#define OBD_INLINESZ 80
-
-/* Note: 64-bit types are 64-bit aligned in structure */
-struct obdo {
- obd_valid o_valid; /* hot fields in this obdo */
- obd_id o_id;
- obd_gr o_gr;
- obd_id o_fid;
- obd_size o_size; /* o_size-o_blocks == ost_lvb */
- obd_time o_mtime;
- obd_time o_atime;
- obd_time o_ctime;
- obd_blocks o_blocks; /* brw: cli sent cached bytes */
- obd_size o_grant;
-
- /* 32-bit fields start here: keep an even number of them via padding */
- obd_blksize o_blksize; /* optimal IO blocksize */
- obd_mode o_mode; /* brw: cli sent cache remain */
- obd_uid o_uid;
- obd_gid o_gid;
- obd_flag o_flags;
- obd_count o_nlink; /* brw: checksum */
- obd_count o_generation;
- obd_count o_misc; /* brw: o_dropped */
- __u32 o_easize; /* epoch in ost writes */
- __u32 o_mds;
- __u32 o_stripe_idx; /* holds stripe idx */
- __u32 o_padding_1;
- char o_inline[OBD_INLINESZ]; /* fid in ost writes */
-};
-
-#define o_dirty o_blocks
-#define o_undirty o_mode
-#define o_dropped o_misc
-#define o_cksum o_nlink
-
-#define OBDO_URGENT_CREATE(oa) \
- (!((oa)->o_valid & OBD_MD_FLFLAGS) || \
- !((oa)->o_flags & OBD_FL_CREATE_CROW) || \
- ((oa)->o_flags & OBD_FL_RECREATE_OBJS))
-
-extern void lustre_swab_obdo (struct obdo *o);
-
-#define LOV_MAGIC_V1 0x0BD10BD0
-#define LOV_MAGIC LOV_MAGIC_V1
-
-#define LOV_PATTERN_RAID0 0x001 /* stripes are used round-robin */
-#define LOV_PATTERN_RAID1 0x002 /* stripes are mirrors of each other */
-#define LOV_PATTERN_FIRST 0x100 /* first stripe is not in round-robin */
-#define LOV_PATTERN_CMOBD 0x200
-
-#define lov_ost_data lov_ost_data_v1
-struct lov_ost_data_v1 { /* per-stripe data structure (little-endian)*/
- __u64 l_object_id; /* OST object ID */
- __u64 l_object_gr; /* OST object group (creating MDS number) */
- __u32 l_ost_gen; /* generation of this l_ost_idx */
- __u32 l_ost_idx; /* OST index in LOV (lov_tgt_desc->tgts) */
-};
-
-#define lov_mds_md lov_mds_md_v1
-struct lov_mds_md_v1 { /* LOV EA mds/wire data (little-endian) */
- __u32 lmm_magic; /* magic number = LOV_MAGIC_V1 */
- __u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
- __u64 lmm_object_id; /* LOV object ID */
- __u64 lmm_object_gr; /* LOV object group */
- __u32 lmm_stripe_size; /* size of stripe in bytes */
- __u32 lmm_stripe_count; /* num stripes in use for this object */
- struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
-};
-
-#define OBD_MD_FLID (0x00000001ULL) /* object ID */
-#define OBD_MD_FLATIME (0x00000002ULL) /* access time */
-#define OBD_MD_FLMTIME (0x00000004ULL) /* data modification time */
-#define OBD_MD_FLCTIME (0x00000008ULL) /* change time */
-#define OBD_MD_FLSIZE (0x00000010ULL) /* size */
-#define OBD_MD_FLBLOCKS (0x00000020ULL) /* allocated blocks count */
-#define OBD_MD_FLBLKSZ (0x00000040ULL) /* block size */
-#define OBD_MD_FLMODE (0x00000080ULL) /* access bits (mode & ~S_IFMT) */
-#define OBD_MD_FLTYPE (0x00000100ULL) /* object type (mode & S_IFMT) */
-#define OBD_MD_FLUID (0x00000200ULL) /* user ID */
-#define OBD_MD_FLGID (0x00000400ULL) /* group ID */
-#define OBD_MD_FLFLAGS (0x00000800ULL) /* flags word */
-#define OBD_MD_FLNLINK (0x00002000ULL) /* link count */
-#define OBD_MD_FLGENER (0x00004000ULL) /* generation number */
-#define OBD_MD_FLINLINE (0x00008000ULL) /* inline data */
-#define OBD_MD_FLRDEV (0x00010000ULL) /* device number */
-#define OBD_MD_FLEASIZE (0x00020000ULL) /* extended attribute data */
-#define OBD_MD_LINKNAME (0x00040000ULL) /* symbolic link target */
-#define OBD_MD_FLHANDLE (0x00080000ULL) /* file handle */
-#define OBD_MD_FLCKSUM (0x00100000ULL) /* bulk data checksum */
-#define OBD_MD_FLQOS (0x00200000ULL) /* quality of service stats */
-#define OBD_MD_FLOSCOPQ (0x00400000ULL) /* osc opaque data */
-#define OBD_MD_FLCOOKIE (0x00800000ULL) /* log cancellation cookie */
-#define OBD_MD_FLGROUP (0x01000000ULL) /* group */
-#define OBD_MD_FLFID (0x02000000ULL) /* ->ost write inline fid */
-#define OBD_MD_FLEPOCH (0x04000000ULL) /* ->ost write easize is epoch */
-#define OBD_MD_FLGRANT (0x08000000ULL) /* ost preallocation space grant */
-#define OBD_MD_FLDIREA (0x10000000ULL) /* dir's extended attribute data */
-#define OBD_MD_FLUSRQUOTA (0x20000000ULL) /* over quota flags sent from ost */
-#define OBD_MD_FLGRPQUOTA (0x40000000ULL) /* over quota flags sent from ost */
-
-#define OBD_MD_MDS (0x0000000100000000ULL) /* where an inode lives on */
-#define OBD_MD_REINT (0x0000000200000000ULL) /* reintegrate oa */
-
-#define OBD_MD_FLXATTR (0x0000001000000000ULL) /* xattr */
-#define OBD_MD_FLXATTRLS (0x0000002000000000ULL) /* xattr list */
-#define OBD_MD_FLXATTRRM (0x0000004000000000ULL) /* xattr remove */
-#define OBD_MD_FLACL (0x0000008000000000ULL) /* ACL */
-
-#define OBD_MD_FLGETATTR (OBD_MD_FLID | OBD_MD_FLATIME | OBD_MD_FLMTIME | \
- OBD_MD_FLCTIME | OBD_MD_FLSIZE | OBD_MD_FLBLKSZ | \
- OBD_MD_FLMODE | OBD_MD_FLTYPE | OBD_MD_FLUID | \
- OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \
- OBD_MD_FLGENER | OBD_MD_FLRDEV | OBD_MD_FLGROUP)
-
-static inline struct lustre_handle *obdo_handle(struct obdo *oa)
-{
- return (struct lustre_handle *)oa->o_inline;
-}
-
-static inline struct llog_cookie *obdo_logcookie(struct obdo *oa)
-{
- return (struct llog_cookie *)(oa->o_inline +
- sizeof(struct lustre_handle));
-}
-/* don't forget obdo_fid which is way down at the bottom so it can
- * come after the definition of llog_cookie */
-
-struct obd_statfs {
- __u64 os_type;
- __u64 os_blocks;
- __u64 os_bfree;
- __u64 os_bavail;
- __u64 os_files;
- __u64 os_ffree;
- __u8 os_fsid[40];
- __u32 os_bsize;
- __u32 os_namelen;
- __u64 os_maxbytes;
- __u32 os_state;
- __u32 os_spare1;
- __u32 os_spare2;
- __u32 os_spare3;
- __u32 os_spare4;
- __u32 os_spare5;
- __u32 os_spare6;
- __u32 os_spare7;
- __u32 os_spare8;
- __u32 os_spare9;
-};
-
-extern void lustre_swab_obd_statfs (struct obd_statfs *os);
-
-/* ost_body.data values for OST_BRW */
-
-#define OBD_BRW_READ 0x01
-#define OBD_BRW_WRITE 0x02
-#define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE)
-#define OBD_BRW_SYNC 0x08
-#define OBD_BRW_CHECK 0x10
-#define OBD_BRW_FROM_GRANT 0x20 /* the osc manages this under llite */
-#define OBD_BRW_GRANTED 0x40 /* the ost manages this */
-#define OBD_BRW_DROP 0x80 /* drop the page after IO */
-#define OBD_BRW_NOQUOTA 0x100
-#define OBD_BRW_SRVLOCK 0x200 /* Client holds no lock over this page */
-
-#define OBD_OBJECT_EOF 0xffffffffffffffffULL
-
-#define OST_MIN_PRECREATE 32
-#define OST_MAX_PRECREATE 20000
-
-struct obd_ioobj {
- obd_id ioo_id;
- obd_gr ioo_gr;
- __u32 ioo_type;
- __u32 ioo_bufcnt;
-};
-
-extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
-
-/* multiple of 8 bytes => can array */
-struct niobuf_remote {
- __u64 offset;
- __u32 len;
- __u32 flags;
-};
-
-extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
-
-/* request structure for OST's */
-
-struct ost_body {
- struct obdo oa;
-};
-
-extern void lustre_swab_ost_body (struct ost_body *b);
-extern void lustre_swab_ost_last_id(obd_id *id);
-
-/* lock value block communicated between the filter and llite */
-
-struct ost_lvb {
- __u64 lvb_size;
- __u64 lvb_mtime;
- __u64 lvb_atime;
- __u64 lvb_ctime;
- __u64 lvb_blocks;
-};
-
-extern void lustre_swab_ost_lvb(struct ost_lvb *);
-
-/*
- * MDS REQ RECORDS
- */
-
-/* opcodes */
-typedef enum {
- MDS_GETATTR = 33,
- MDS_GETATTR_NAME = 34,
- MDS_CLOSE = 35,
- MDS_REINT = 36,
- MDS_READPAGE = 37,
- MDS_CONNECT = 38,
- MDS_DISCONNECT = 39,
- MDS_GETSTATUS = 40,
- MDS_STATFS = 41,
- MDS_PIN = 42,
- MDS_UNPIN = 43,
- MDS_SYNC = 44,
- MDS_DONE_WRITING = 45,
- MDS_SET_INFO = 46,
- MDS_QUOTACHECK = 47,
- MDS_QUOTACTL = 48,
- MDS_GETXATTR = 49,
- MDS_SETXATTR = 50,
- MDS_LAST_OPC
-} mds_cmd_t;
-
-#define MDS_FIRST_OPC MDS_GETATTR
-
-/*
- * Do not exceed 63
- */
-
-typedef enum {
- REINT_SETATTR = 1,
- REINT_CREATE = 2,
- REINT_LINK = 3,
- REINT_UNLINK = 4,
- REINT_RENAME = 5,
- REINT_OPEN = 6,
-// REINT_CLOSE = 7,
-// REINT_WRITE = 8,
- REINT_MAX
-} mds_reint_t;
-
-/* the disposition of the intent outlines what was executed */
-#define DISP_IT_EXECD 0x01
-#define DISP_LOOKUP_EXECD 0x02
-#define DISP_LOOKUP_NEG 0x04
-#define DISP_LOOKUP_POS 0x08
-#define DISP_OPEN_CREATE 0x10
-#define DISP_OPEN_OPEN 0x20
-#define DISP_ENQ_COMPLETE 0x40
-
-/* INODE LOCK PARTS */
-#define MDS_INODELOCK_LOOKUP 0x000001 /* dentry, mode, owner, group */
-#define MDS_INODELOCK_UPDATE 0x000002 /* size, links, timestamps */
-#define MDS_INODELOCK_OPEN 0x000004 /* For opened files */
-
-/* Do not forget to increase MDS_INODELOCK_MAXSHIFT when adding new bits */
-#define MDS_INODELOCK_MAXSHIFT 2
-/* This FULL lock is useful to take on unlink sort of operations */
-#define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1)
-
-struct ll_fid {
- __u64 id; /* holds object id */
- __u32 generation; /* holds object generation */
-
- __u32 f_type; /* holds object type or stripe idx when passing it to
- * OST for saving into EA. */
-};
-
-extern void lustre_swab_ll_fid (struct ll_fid *fid);
-
-#define MDS_STATUS_CONN 1
-#define MDS_STATUS_LOV 2
-
-struct mds_status_req {
- __u32 flags;
- __u32 repbuf;
-};
-
-extern void lustre_swab_mds_status_req (struct mds_status_req *r);
-
-#define MDS_BFLAG_UNCOMMITTED_WRITES 0x1
-
-struct mds_body {
- struct ll_fid fid1;
- struct ll_fid fid2;
- struct lustre_handle handle;
- __u64 valid;
- __u64 size; /* Offset, in the case of MDS_READPAGE */
- __u64 mtime;
- __u64 atime;
- __u64 ctime;
- __u64 blocks; /* XID, in the case of MDS_READPAGE */
- __u64 io_epoch;
- __u64 ino;
- __u32 fsuid;
- __u32 fsgid;
- __u32 capability;
- __u32 mode;
- __u32 uid;
- __u32 gid;
- __u32 flags; /* from vfs for pin/unpin, MDS_BFLAG for close */
- __u32 rdev;
- __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */
- __u32 generation;
- __u32 suppgid;
- __u32 eadatasize;
- __u32 aclsize;
- __u32 padding_2; /* also fix lustre_swab_mds_body */
- __u32 padding_3; /* also fix lustre_swab_mds_body */
- __u32 padding_4; /* also fix lustre_swab_mds_body */
-};
-
-extern void lustre_swab_mds_body (struct mds_body *b);
-
-#define Q_QUOTACHECK 0x800100
-#define Q_INITQUOTA 0x800101 /* init slave limits */
-#define Q_GETOINFO 0x800102 /* get obd quota info */
-#define Q_GETOQUOTA 0x800103 /* get obd quotas */
-
-#define Q_TYPESET(oqc, type) \
- ((oqc)->qc_type == type || (oqc)->qc_type == UGQUOTA)
-
-#define Q_GETOCMD(oqc) \
- ((oqc)->qc_cmd == Q_GETOINFO || (oqc)->qc_cmd == Q_GETOQUOTA)
-
-struct obd_quotactl {
- __u32 qc_cmd;
- __u32 qc_type;
- __u32 qc_id;
- __u32 qc_stat;
- struct obd_dqinfo qc_dqinfo;
- struct obd_dqblk qc_dqblk;
-};
-
-extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
-
-struct mds_rec_setattr {
- __u32 sa_opcode;
- __u32 sa_fsuid;
- __u32 sa_fsgid;
- __u32 sa_cap;
- __u32 sa_suppgid;
- __u32 sa_mode;
- struct ll_fid sa_fid;
- __u64 sa_valid;
- __u64 sa_size;
- __u64 sa_mtime;
- __u64 sa_atime;
- __u64 sa_ctime;
- __u32 sa_uid;
- __u32 sa_gid;
- __u32 sa_attr_flags;
- __u32 sa_padding; /* also fix lustre_swab_mds_rec_setattr */
-};
-
-/* Remove this once we declare it in include/linux/fs.h (v21 kernel patch?) */
-#ifndef ATTR_CTIME_SET
-#define ATTR_CTIME_SET 0x2000
-#endif
-
-extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
-
-#ifndef FMODE_READ
-#define FMODE_READ 00000001
-#define FMODE_WRITE 00000002
-#endif
-#ifndef FMODE_EXEC
-#define FMODE_EXEC 00000004
-#endif
-#define MDS_OPEN_CREAT 00000100
-#define MDS_OPEN_EXCL 00000200
-#define MDS_OPEN_TRUNC 00001000
-#define MDS_OPEN_APPEND 00002000
-#define MDS_OPEN_SYNC 00010000
-#define MDS_OPEN_DIRECTORY 00200000
-
-#define MDS_OPEN_DELAY_CREATE 0100000000 /* delay initial object create */
-#define MDS_OPEN_OWNEROVERRIDE 0200000000 /* NFSD rw-reopen ro file for owner */
-#define MDS_OPEN_HAS_EA 010000000000 /* specify object create pattern */
-#define MDS_OPEN_HAS_OBJS 020000000000 /* Just set the EA the obj exist */
-
-struct mds_rec_create {
- __u32 cr_opcode;
- __u32 cr_fsuid;
- __u32 cr_fsgid;
- __u32 cr_cap;
- __u32 cr_flags; /* for use with open */
- __u32 cr_mode;
- struct ll_fid cr_fid;
- struct ll_fid cr_replayfid;
- __u64 cr_time;
- __u64 cr_rdev;
- __u32 cr_suppgid;
- __u32 cr_padding_1; /* also fix lustre_swab_mds_rec_create */
- __u32 cr_padding_2; /* also fix lustre_swab_mds_rec_create */
- __u32 cr_padding_3; /* also fix lustre_swab_mds_rec_create */
- __u32 cr_padding_4; /* also fix lustre_swab_mds_rec_create */
- __u32 cr_padding_5; /* also fix lustre_swab_mds_rec_create */
-};
-
-extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr);
-
-struct mds_rec_link {
- __u32 lk_opcode;
- __u32 lk_fsuid;
- __u32 lk_fsgid;
- __u32 lk_cap;
- __u32 lk_suppgid1;
- __u32 lk_suppgid2;
- struct ll_fid lk_fid1;
- struct ll_fid lk_fid2;
- __u64 lk_time;
- __u32 lk_padding_1; /* also fix lustre_swab_mds_rec_link */
- __u32 lk_padding_2; /* also fix lustre_swab_mds_rec_link */
- __u32 lk_padding_3; /* also fix lustre_swab_mds_rec_link */
- __u32 lk_padding_4; /* also fix lustre_swab_mds_rec_link */
-};
-
-extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk);
-
-struct mds_rec_unlink {
- __u32 ul_opcode;
- __u32 ul_fsuid;
- __u32 ul_fsgid;
- __u32 ul_cap;
- __u32 ul_suppgid;
- __u32 ul_mode;
- struct ll_fid ul_fid1;
- struct ll_fid ul_fid2;
- __u64 ul_time;
- __u32 ul_padding_1; /* also fix lustre_swab_mds_rec_unlink */
- __u32 ul_padding_2; /* also fix lustre_swab_mds_rec_unlink */
- __u32 ul_padding_3; /* also fix lustre_swab_mds_rec_unlink */
- __u32 ul_padding_4; /* also fix lustre_swab_mds_rec_unlink */
-};
-
-extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul);
-
-struct mds_rec_rename {
- __u32 rn_opcode;
- __u32 rn_fsuid;
- __u32 rn_fsgid;
- __u32 rn_cap;
- __u32 rn_suppgid1;
- __u32 rn_suppgid2;
- struct ll_fid rn_fid1;
- struct ll_fid rn_fid2;
- __u64 rn_time;
- __u32 rn_padding_1; /* also fix lustre_swab_mds_rec_rename */
- __u32 rn_padding_2; /* also fix lustre_swab_mds_rec_rename */
- __u32 rn_padding_3; /* also fix lustre_swab_mds_rec_rename */
- __u32 rn_padding_4; /* also fix lustre_swab_mds_rec_rename */
-};
-
-extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
-
-/*
- * LOV data structures
- */
-
-#define LOV_MIN_STRIPE_SIZE 65536 /* maximum PAGE_SIZE (ia64), power of 2 */
-#define LOV_MAX_STRIPE_COUNT 160 /* until bug 4424 is fixed */
-
-#define LOV_MAX_UUID_BUFFER_SIZE 8192
-/* The size of the buffer the lov/mdc reserves for the
- * array of UUIDs returned by the MDS. With the current
- * protocol, this will limit the max number of OSTs per LOV */
-
-#define LOV_DESC_MAGIC 0xB0CCDE5C
-
-struct lov_desc {
- __u32 ld_tgt_count; /* how many OBD's */
- __u32 ld_active_tgt_count; /* how many active */
- __u32 ld_default_stripe_count; /* how many objects are used */
- __u32 ld_pattern; /* PATTERN_RAID0, PATTERN_RAID1 */
- __u64 ld_default_stripe_size; /* in bytes */
- __u64 ld_default_stripe_offset; /* in bytes */
- __u32 ld_qos_threshold; /* in MB */
- __u32 ld_qos_maxage; /* in second */
- __u32 ld_padding_1; /* also fix lustre_swab_lov_desc */
- __u32 ld_padding_2; /* also fix lustre_swab_lov_desc */
- struct obd_uuid ld_uuid;
-};
-
-#define ld_magic ld_active_tgt_count /* for swabbing from llogs */
-
-extern void lustre_swab_lov_desc (struct lov_desc *ld);
-
-/*
- * LDLM requests:
- */
-/* opcodes -- MUST be distinct from OST/MDS opcodes */
-typedef enum {
- LDLM_ENQUEUE = 101,
- LDLM_CONVERT = 102,
- LDLM_CANCEL = 103,
- LDLM_BL_CALLBACK = 104,
- LDLM_CP_CALLBACK = 105,
- LDLM_GL_CALLBACK = 106,
- LDLM_LAST_OPC
-} ldlm_cmd_t;
-#define LDLM_FIRST_OPC LDLM_ENQUEUE
-
-#define RES_NAME_SIZE 4
-struct ldlm_res_id {
- __u64 name[RES_NAME_SIZE];
-};
-
-extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
-
-/* lock types */
-typedef enum {
- LCK_MINMODE = 0,
- LCK_EX = 1,
- LCK_PW = 2,
- LCK_PR = 4,
- LCK_CW = 8,
- LCK_CR = 16,
- LCK_NL = 32,
- LCK_GROUP = 64,
- LCK_MAXMODE
-} ldlm_mode_t;
-
-typedef enum {
- LDLM_PLAIN = 10,
- LDLM_EXTENT = 11,
- LDLM_FLOCK = 12,
- LDLM_IBITS = 13,
- LDLM_MAX_TYPE
-} ldlm_type_t;
-
-#define LDLM_MIN_TYPE LDLM_PLAIN
-
-struct ldlm_extent {
- __u64 start;
- __u64 end;
- __u64 gid;
-};
-
-struct ldlm_inodebits {
- __u64 bits;
-};
-
-struct ldlm_flock {
- __u64 start;
- __u64 end;
- __u64 blocking_export; /* not actually used over the wire */
- __u32 blocking_pid; /* not actually used over the wire */
- __u32 pid;
-};
-
-/* it's important that the fields of the ldlm_extent structure match
- * the first fields of the ldlm_flock structure because there is only
- * one ldlm_swab routine to process the ldlm_policy_data_t union. if
- * this ever changes we will need to swab the union differently based
- * on the resource type. */
-
-typedef union {
- struct ldlm_extent l_extent;
- struct ldlm_flock l_flock;
- struct ldlm_inodebits l_inodebits;
-} ldlm_policy_data_t;
-
-extern void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d);
-
-struct ldlm_intent {
- __u64 opc;
-};
-
-extern void lustre_swab_ldlm_intent (struct ldlm_intent *i);
-
-struct ldlm_resource_desc {
- ldlm_type_t lr_type;
- __u32 lr_padding;
- struct ldlm_res_id lr_name;
-};
-
-extern void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r);
-
-struct ldlm_lock_desc {
- struct ldlm_resource_desc l_resource;
- ldlm_mode_t l_req_mode;
- ldlm_mode_t l_granted_mode;
- ldlm_policy_data_t l_policy_data;
-};
-
-extern void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l);
-
-struct ldlm_request {
- __u32 lock_flags;
- __u32 lock_padding;
- struct ldlm_lock_desc lock_desc;
- struct lustre_handle lock_handle1;
- struct lustre_handle lock_handle2;
-};
-
-extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
-
-struct ldlm_reply {
- __u32 lock_flags;
- __u32 lock_padding;
- struct ldlm_lock_desc lock_desc;
- struct lustre_handle lock_handle;
- __u64 lock_policy_res1;
- __u64 lock_policy_res2;
-};
-
-extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
-
-/*
- * ptlbd, portal block device requests
- */
-typedef enum {
- PTLBD_QUERY = 200,
- PTLBD_READ = 201,
- PTLBD_WRITE = 202,
- PTLBD_FLUSH = 203,
- PTLBD_CONNECT = 204,
- PTLBD_DISCONNECT = 205,
- PTLBD_LAST_OPC
-} ptlbd_cmd_t;
-#define PTLBD_FIRST_OPC PTLBD_QUERY
-
-struct ptlbd_op {
- __u16 op_cmd;
- __u16 op_lun;
- __u16 op_niob_cnt;
- __u16 op__padding;
- __u32 op_block_cnt;
-};
-
-extern void lustre_swab_ptlbd_op (struct ptlbd_op *op);
-
-struct ptlbd_niob {
- __u64 n_xid;
- __u64 n_block_nr;
- __u32 n_offset;
- __u32 n_length;
-};
-
-extern void lustre_swab_ptlbd_niob (struct ptlbd_niob *n);
-
-struct ptlbd_rsp {
- __u16 r_status;
- __u16 r_error_cnt;
-};
-
-extern void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r);
-
-/*
- * Opcodes for management/monitoring node.
- */
-typedef enum {
- MGMT_CONNECT = 250,
- MGMT_DISCONNECT,
- MGMT_EXCEPTION, /* node died, etc. */
- MGMT_LAST_OPC
-} mgmt_cmd_t;
-#define MGMT_FIRST_OPC MGMT_CONNECT
-
-/*
- * Opcodes for multiple servers.
- */
-
-typedef enum {
- OBD_PING = 400,
- OBD_LOG_CANCEL,
- OBD_QC_CALLBACK,
- OBD_LAST_OPC
-} obd_cmd_t;
-#define OBD_FIRST_OPC OBD_PING
-
-/* catalog of log objects */
-
-/* Identifier for a single log object */
-struct llog_logid {
- __u64 lgl_oid;
- __u64 lgl_ogr;
- __u32 lgl_ogen;
-} __attribute__((packed));
-
-/* Records written to the CATALOGS list */
-#define CATLIST "CATALOGS"
-struct llog_catid {
- struct llog_logid lci_logid;
- __u32 lci_padding[3];
-} __attribute__((packed));
-
-/* Log data record types - there is no specific reason that these need to
- * be related to the RPC opcodes, but no reason not to (may be handy later?)
- */
-#define LLOG_OP_MAGIC 0x10600000
-#define LLOG_OP_MASK 0xfff00000
-
-typedef enum {
- LLOG_PAD_MAGIC = LLOG_OP_MAGIC | 0,
- OST_SZ_REC = LLOG_OP_MAGIC | (OST_SAN_WRITE << 8),
- OST_RAID1_REC = LLOG_OP_MAGIC | ((OST_SAN_WRITE + 1) << 8),
- MDS_UNLINK_REC = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_UNLINK,
- MDS_SETATTR_REC = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_SETATTR,
- OBD_CFG_REC = LLOG_OP_MAGIC | 0x20000,
- PTL_CFG_REC = LLOG_OP_MAGIC | 0x30000, /* obsolete */
- LLOG_GEN_REC = LLOG_OP_MAGIC | 0x40000,
- LLOG_HDR_MAGIC = LLOG_OP_MAGIC | 0x45539,
- LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b,
-} llog_op_type;
-
-/*
- * for now, continue to support old pad records which have 0 for their
- * type but still need to be swabbed for their length
- */
-#define LLOG_REC_HDR_NEEDS_SWABBING(r) \
- (((r)->lrh_type & __swab32(LLOG_OP_MASK)) == \
- __swab32(LLOG_OP_MAGIC) || \
- (((r)->lrh_type == 0) && ((r)->lrh_len > LLOG_CHUNK_SIZE)))
-
-/* Log record header - stored in little endian order.
- * Each record must start with this struct, end with a llog_rec_tail,
- * and be a multiple of 256 bits in size.
- */
-struct llog_rec_hdr {
- __u32 lrh_len;
- __u32 lrh_index;
- __u32 lrh_type;
- __u32 padding;
-};
-
-struct llog_rec_tail {
- __u32 lrt_len;
- __u32 lrt_index;
-};
-
-struct llog_logid_rec {
- struct llog_rec_hdr lid_hdr;
- struct llog_logid lid_id;
- __u32 padding[5];
- struct llog_rec_tail lid_tail;
-} __attribute__((packed));
-
-struct llog_create_rec {
- struct llog_rec_hdr lcr_hdr;
- struct ll_fid lcr_fid;
- obd_id lcr_oid;
- obd_count lcr_ogen;
- __u32 padding;
- struct llog_rec_tail lcr_tail;
-} __attribute__((packed));
-
-struct llog_orphan_rec {
- struct llog_rec_hdr lor_hdr;
- obd_id lor_oid;
- obd_count lor_ogen;
- __u32 padding;
- struct llog_rec_tail lor_tail;
-} __attribute__((packed));
-
-struct llog_unlink_rec {
- struct llog_rec_hdr lur_hdr;
- obd_id lur_oid;
- obd_count lur_ogen;
- __u32 padding;
- struct llog_rec_tail lur_tail;
-} __attribute__((packed));
-
-struct llog_setattr_rec {
- struct llog_rec_hdr lsr_hdr;
- obd_id lsr_oid;
- obd_count lsr_ogen;
- __u32 lsr_uid;
- __u32 lsr_gid;
- __u32 padding;
- struct llog_rec_tail lsr_tail;
-} __attribute__((packed));
-
-struct llog_size_change_rec {
- struct llog_rec_hdr lsc_hdr;
- struct ll_fid lsc_fid;
- __u32 lsc_io_epoch;
- __u32 padding;
- struct llog_rec_tail lsc_tail;
-} __attribute__((packed));
-
-struct llog_gen {
- __u64 mnt_cnt;
- __u64 conn_cnt;
-} __attribute__((packed));
-
-struct llog_gen_rec {
- struct llog_rec_hdr lgr_hdr;
- struct llog_gen lgr_gen;
- struct llog_rec_tail lgr_tail;
-};
-/* On-disk header structure of each log object, stored in little endian order */
-#define LLOG_CHUNK_SIZE 8192
-#define LLOG_HEADER_SIZE (96)
-#define LLOG_BITMAP_BYTES (LLOG_CHUNK_SIZE - LLOG_HEADER_SIZE)
-
-#define LLOG_MIN_REC_SIZE (24) /* round(llog_rec_hdr + llog_rec_tail) */
-
-/* flags for the logs */
-#define LLOG_F_ZAP_WHEN_EMPTY 0x1
-#define LLOG_F_IS_CAT 0x2
-#define LLOG_F_IS_PLAIN 0x4
-
-struct llog_log_hdr {
- struct llog_rec_hdr llh_hdr;
- __u64 llh_timestamp;
- __u32 llh_count;
- __u32 llh_bitmap_offset;
- __u32 llh_size;
- __u32 llh_flags;
- __u32 llh_cat_idx;
- /* for a catalog the first plain slot is next to it */
- struct obd_uuid llh_tgtuuid;
- __u32 llh_reserved[LLOG_HEADER_SIZE/sizeof(__u32) - 23];
- __u32 llh_bitmap[LLOG_BITMAP_BYTES/sizeof(__u32)];
- struct llog_rec_tail llh_tail;
-} __attribute__((packed));
-
-#define LLOG_BITMAP_SIZE(llh) ((llh->llh_hdr.lrh_len - \
- llh->llh_bitmap_offset - \
- sizeof(llh->llh_tail)) * 8)
-
-/* log cookies are used to reference a specific log file and a record therein */
-struct llog_cookie {
- struct llog_logid lgc_lgl;
- __u32 lgc_subsys;
- __u32 lgc_index;
- __u32 lgc_padding;
-} __attribute__((packed));
-
-/* llog protocol */
-enum llogd_rpc_ops {
- LLOG_ORIGIN_HANDLE_CREATE = 501,
- LLOG_ORIGIN_HANDLE_NEXT_BLOCK = 502,
- LLOG_ORIGIN_HANDLE_READ_HEADER = 503,
- LLOG_ORIGIN_HANDLE_WRITE_REC = 504,
- LLOG_ORIGIN_HANDLE_CLOSE = 505,
- LLOG_ORIGIN_CONNECT = 506,
- LLOG_CATINFO = 507, /* for lfs catinfo */
-};
-
-struct llogd_body {
- struct llog_logid lgd_logid;
- __u32 lgd_ctxt_idx;
- __u32 lgd_llh_flags;
- __u32 lgd_index;
- __u32 lgd_saved_index;
- __u32 lgd_len;
- __u64 lgd_cur_offset;
-} __attribute__((packed));
-
-struct llogd_conn_body {
- struct llog_gen lgdc_gen;
- struct llog_logid lgdc_logid;
- __u32 lgdc_ctxt_idx;
-} __attribute__((packed));
-
-extern void lustre_swab_lov_user_md(struct lov_user_md *lum);
-extern void lustre_swab_lov_user_md_objects(struct lov_user_md *lum);
-
-/* llog_swab.c */
-extern void lustre_swab_llogd_body (struct llogd_body *d);
-extern void lustre_swab_llog_hdr (struct llog_log_hdr *h);
-extern void lustre_swab_llogd_conn_body (struct llogd_conn_body *d);
-extern void lustre_swab_llog_rec(struct llog_rec_hdr *rec,
- struct llog_rec_tail *tail);
-
-struct lustre_cfg;
-extern void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
-
-/* qutoa */
-struct qunit_data {
- __u32 qd_id; /* ID appiles to (uid, gid) */
- __u32 qd_type; /* Quota type (USRQUOTA, GRPQUOTA) */
- __u32 qd_count; /* acquire/release count (bytes for block quota) */
- __u32 qd_isblk; /* Block quota or file quota */
-};
-extern void lustre_swab_qdata(struct qunit_data *d);
-
-typedef enum {
- QUOTA_DQACQ = 601,
- QUOTA_DQREL = 602,
-} quota_cmd_t;
-
#endif
*
*/
+#ifndef _LINUX_LUSTRE_LIB_H
+#define _LINUX_LUSTRE_LIB_H
+
#ifndef _LUSTRE_LIB_H
-#define _LUSTRE_LIB_H
+#error Do not #include this file directly. #include <lustre_lib.h> instead
+#endif
#ifndef __KERNEL__
# include <string.h>
# include <linux/signal.h>
# include <linux/types.h>
#endif
-#include <libcfs/kp30.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_cfg.h>
+#include <linux/lustre_compat25.h>
#ifndef LP_POISON
#if BITS_PER_LONG > 32
#endif
#endif
-/* target.c */
-struct ptlrpc_request;
-struct recovd_data;
-struct recovd_obd;
-struct obd_export;
-#include <linux/lustre_ha.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_compat25.h>
-#include <linux/lvfs.h>
-
-int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler);
-int target_handle_disconnect(struct ptlrpc_request *req);
-void target_destroy_export(struct obd_export *exp);
-int target_handle_reconnect(struct lustre_handle *conn, struct obd_export *exp,
- struct obd_uuid *cluuid);
-int target_handle_ping(struct ptlrpc_request *req);
-void target_committed_to_req(struct ptlrpc_request *req);
-
-#ifdef HAVE_QUOTA_SUPPORT
-/* quotacheck callback, dqacq/dqrel callback handler */
-int target_handle_qc_callback(struct ptlrpc_request *req);
-int target_handle_dqacq_callback(struct ptlrpc_request *req);
-#else
-#define target_handle_dqacq_callback(req) ldlm_callback_reply(req, -ENOTSUPP)
-#define target_handle_qc_callback(req) (0)
-#endif
-
-void target_cancel_recovery_timer(struct obd_device *obd);
-
-#define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
-void target_start_recovery_timer(struct obd_device *obd, svc_handler_t handler);
-void target_abort_recovery(void *data);
-void target_cleanup_recovery(struct obd_device *obd);
-int target_queue_recovery_request(struct ptlrpc_request *req,
- struct obd_device *obd);
-int target_queue_final_reply(struct ptlrpc_request *req, int rc);
-void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id);
-
-/* client.c */
-
-int client_sanobd_setup(struct obd_device *obddev, obd_count len, void *buf);
-struct client_obd *client_conn2cli(struct lustre_handle *conn);
-
-struct mdc_open_data;
-struct obd_client_handle {
- struct lustre_handle och_fh;
- struct llog_cookie och_cookie;
- struct mdc_open_data *och_mod;
- __u32 och_magic;
-};
-#define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed
-
-/* statfs_pack.c */
-void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
-void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
-
-/* l_lock.c */
-struct lustre_lock {
- int l_depth;
- struct task_struct *l_owner;
- struct semaphore l_sem;
- spinlock_t l_spin;
-};
-
-void l_lock_init(struct lustre_lock *);
-void l_lock(struct lustre_lock *);
-void l_unlock(struct lustre_lock *);
-int l_has_lock(struct lustre_lock *);
-
-
-/*
- * OBD IOCTLS
- */
-#define OBD_IOCTL_VERSION 0x00010004
-
-struct obd_ioctl_data {
- uint32_t ioc_len;
- uint32_t ioc_version;
-
- uint64_t ioc_cookie;
- uint32_t ioc_conn1;
- uint32_t ioc_conn2;
-
- struct obdo ioc_obdo1;
- struct obdo ioc_obdo2;
-
- obd_size ioc_count;
- obd_off ioc_offset;
- uint32_t ioc_dev;
- uint32_t ioc_command;
-
- uint64_t ioc_nid;
- uint32_t ioc_nal;
- uint32_t ioc_type;
-
- /* buffers the kernel will treat as user pointers */
- uint32_t ioc_plen1;
- char *ioc_pbuf1;
- uint32_t ioc_plen2;
- char *ioc_pbuf2;
-
- /* inline buffers for various arguments */
- uint32_t ioc_inllen1;
- char *ioc_inlbuf1;
- uint32_t ioc_inllen2;
- char *ioc_inlbuf2;
- uint32_t ioc_inllen3;
- char *ioc_inlbuf3;
- uint32_t ioc_inllen4;
- char *ioc_inlbuf4;
-
- char ioc_bulk[0];
-};
-
-struct obd_ioctl_hdr {
- uint32_t ioc_len;
- uint32_t ioc_version;
-};
-
-static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
-{
- int len = size_round(sizeof(struct obd_ioctl_data));
- len += size_round(data->ioc_inllen1);
- len += size_round(data->ioc_inllen2);
- len += size_round(data->ioc_inllen3);
- len += size_round(data->ioc_inllen4);
- return len;
-}
-
-
-static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
-{
- if (data->ioc_len > (1<<30)) {
- CERROR("OBD ioctl: ioc_len larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen1 > (1<<30)) {
- CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen2 > (1<<30)) {
- CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen3 > (1<<30)) {
- CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen4 > (1<<30)) {
- CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
- CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
- CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_inlbuf3 && !data->ioc_inllen3) {
- CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_inlbuf4 && !data->ioc_inllen4) {
- CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_pbuf1 && !data->ioc_plen1) {
- CERROR("OBD ioctl: pbuf1 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_pbuf2 && !data->ioc_plen2) {
- CERROR("OBD ioctl: pbuf2 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_plen1 && !data->ioc_pbuf1) {
- CERROR("OBD ioctl: plen1 set but NULL pointer\n");
- return 1;
- }
- if (data->ioc_plen2 && !data->ioc_pbuf2) {
- CERROR("OBD ioctl: plen2 set but NULL pointer\n");
- return 1;
- }
- if (obd_ioctl_packlen(data) > data->ioc_len) {
- CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n",
- obd_ioctl_packlen(data), data->ioc_len);
- return 1;
- }
- return 0;
-}
-
-#ifndef __KERNEL__
-static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
- int max)
-{
- char *ptr;
- struct obd_ioctl_data *overlay;
- data->ioc_len = obd_ioctl_packlen(data);
- data->ioc_version = OBD_IOCTL_VERSION;
-
- if (*pbuf && data->ioc_len > max)
- return 1;
- if (*pbuf == NULL) {
- *pbuf = malloc(data->ioc_len);
- }
- if (!*pbuf)
- return 1;
- overlay = (struct obd_ioctl_data *)*pbuf;
- memcpy(*pbuf, data, sizeof(*data));
-
- ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1)
- LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
- if (data->ioc_inlbuf2)
- LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
- if (data->ioc_inlbuf3)
- LOGL(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
- if (data->ioc_inlbuf4)
- LOGL(data->ioc_inlbuf4, data->ioc_inllen4, ptr);
- if (obd_ioctl_is_invalid(overlay))
- return 1;
-
- return 0;
-}
-
-static inline int obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf,
- int max)
-{
- char *ptr;
- struct obd_ioctl_data *overlay;
-
- if (!pbuf)
- return 1;
- overlay = (struct obd_ioctl_data *)pbuf;
-
- /* Preserve the caller's buffer pointers */
- overlay->ioc_inlbuf1 = data->ioc_inlbuf1;
- overlay->ioc_inlbuf2 = data->ioc_inlbuf2;
- overlay->ioc_inlbuf3 = data->ioc_inlbuf3;
- overlay->ioc_inlbuf4 = data->ioc_inlbuf4;
-
- memcpy(data, pbuf, sizeof(*data));
-
- ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1)
- LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
- if (data->ioc_inlbuf2)
- LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
- if (data->ioc_inlbuf3)
- LOGU(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
- if (data->ioc_inlbuf4)
- LOGU(data->ioc_inlbuf4, data->ioc_inllen4, ptr);
-
- return 0;
-}
-#endif
-
-#include <linux/obd_support.h>
-
-/* buffer MUST be at least the size of obd_ioctl_hdr */
-static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
-{
- struct obd_ioctl_hdr hdr;
- struct obd_ioctl_data *data;
- int err;
- int offset = 0;
- ENTRY;
-
- err = copy_from_user(&hdr, (void *)arg, sizeof(hdr));
- if (err)
- RETURN(err);
-
- if (hdr.ioc_version != OBD_IOCTL_VERSION) {
- CERROR("Version mismatch kernel vs application\n");
- RETURN(-EINVAL);
- }
-
- if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) {
- CERROR("User buffer len %d exceeds %d max buffer\n",
- hdr.ioc_len, OBD_MAX_IOCTL_BUFFER);
- RETURN(-EINVAL);
- }
-
- if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) {
- CERROR("user buffer too small for ioctl (%d)\n", hdr.ioc_len);
- RETURN(-EINVAL);
- }
-
- /* XXX allocate this more intelligently, using kmalloc when
- * appropriate */
- OBD_VMALLOC(*buf, hdr.ioc_len);
- if (*buf == NULL) {
- CERROR("Cannot allocate control buffer of len %d\n",
- hdr.ioc_len);
- RETURN(-EINVAL);
- }
- *len = hdr.ioc_len;
- data = (struct obd_ioctl_data *)*buf;
-
- err = copy_from_user(*buf, (void *)arg, hdr.ioc_len);
- if (err) {
- OBD_VFREE(*buf, hdr.ioc_len);
- RETURN(err);
- }
-
- if (obd_ioctl_is_invalid(data)) {
- CERROR("ioctl not correctly formatted\n");
- OBD_VFREE(*buf, hdr.ioc_len);
- RETURN(-EINVAL);
- }
-
- if (data->ioc_inllen1) {
- data->ioc_inlbuf1 = &data->ioc_bulk[0];
- offset += size_round(data->ioc_inllen1);
- }
-
- if (data->ioc_inllen2) {
- data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset;
- offset += size_round(data->ioc_inllen2);
- }
-
- if (data->ioc_inllen3) {
- data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset;
- offset += size_round(data->ioc_inllen3);
- }
-
- if (data->ioc_inllen4) {
- data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset;
- }
-
- RETURN(0);
-}
-
-static inline void obd_ioctl_freedata(char *buf, int len)
-{
- ENTRY;
-
- OBD_VFREE(buf, len);
- EXIT;
- return;
-}
-
-#define OBD_IOC_CREATE _IOR ('f', 101, long)
-#define OBD_IOC_DESTROY _IOW ('f', 104, long)
-#define OBD_IOC_PREALLOCATE _IOWR('f', 105, long)
-
-#define OBD_IOC_SETATTR _IOW ('f', 107, long)
-#define OBD_IOC_GETATTR _IOR ('f', 108, long)
-#define OBD_IOC_READ _IOWR('f', 109, long)
-#define OBD_IOC_WRITE _IOWR('f', 110, long)
-
-
-#define OBD_IOC_STATFS _IOWR('f', 113, long)
-#define OBD_IOC_SYNC _IOW ('f', 114, long)
-#define OBD_IOC_READ2 _IOWR('f', 115, long)
-#define OBD_IOC_FORMAT _IOWR('f', 116, long)
-#define OBD_IOC_PARTITION _IOWR('f', 117, long)
-#define OBD_IOC_COPY _IOWR('f', 120, long)
-#define OBD_IOC_MIGR _IOWR('f', 121, long)
-#define OBD_IOC_PUNCH _IOWR('f', 122, long)
-
-#define OBD_IOC_MODULE_DEBUG _IOWR('f', 124, long)
-#define OBD_IOC_BRW_READ _IOWR('f', 125, long)
-#define OBD_IOC_BRW_WRITE _IOWR('f', 126, long)
-#define OBD_IOC_NAME2DEV _IOWR('f', 127, long)
-#define OBD_IOC_UUID2DEV _IOWR('f', 130, long)
-#define OBD_IOC_GETNAME _IOR ('f', 131, long)
-
-#define OBD_IOC_LOV_GET_CONFIG _IOWR('f', 132, long)
-#define OBD_IOC_CLIENT_RECOVER _IOW ('f', 133, long)
-
-#define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 139 )
-#define OBD_IOC_NO_TRANSNO _IOW ('f', 140, long)
-#define OBD_IOC_SET_READONLY _IOW ('f', 141, long)
-#define OBD_IOC_ABORT_RECOVERY _IOR ('f', 142, long)
-
-#define OBD_GET_VERSION _IOWR ('f', 144, long)
-
-#define OBD_IOC_CLOSE_UUID _IOWR ('f', 147, long)
-
-#define OBD_IOC_LOV_SETSTRIPE _IOW ('f', 154, long)
-#define OBD_IOC_LOV_GETSTRIPE _IOW ('f', 155, long)
-#define OBD_IOC_LOV_SETEA _IOW ('f', 156, long)
-
-#define OBD_IOC_QUOTACHECK _IOW ('f', 160, int)
-#define OBD_IOC_POLL_QUOTACHECK _IOR ('f', 161, struct if_quotacheck *)
-#define OBD_IOC_QUOTACTL _IOWR('f', 162, struct if_quotactl *)
-
-#define OBD_IOC_MOUNTOPT _IOWR('f', 170, long)
-
-#define OBD_IOC_RECORD _IOWR('f', 180, long)
-#define OBD_IOC_ENDRECORD _IOWR('f', 181, long)
-#define OBD_IOC_PARSE _IOWR('f', 182, long)
-#define OBD_IOC_DORECORD _IOWR('f', 183, long)
-#define OBD_IOC_PROCESS_CFG _IOWR('f', 184, long)
-#define OBD_IOC_DUMP_LOG _IOWR('f', 185, long)
-#define OBD_IOC_CLEAR_LOG _IOWR('f', 186, long)
-
-#define OBD_IOC_CATLOGLIST _IOWR('f', 190, long)
-#define OBD_IOC_LLOG_INFO _IOWR('f', 191, long)
-#define OBD_IOC_LLOG_PRINT _IOWR('f', 192, long)
-#define OBD_IOC_LLOG_CANCEL _IOWR('f', 193, long)
-#define OBD_IOC_LLOG_REMOVE _IOWR('f', 194, long)
-#define OBD_IOC_LLOG_CHECK _IOWR('f', 195, long)
-#define OBD_IOC_LLOG_CATINFO _IOWR('f', 196, long)
-
-#define ECHO_IOC_GET_STRIPE _IOWR('f', 200, long)
-#define ECHO_IOC_SET_STRIPE _IOWR('f', 201, long)
-#define ECHO_IOC_ENQUEUE _IOWR('f', 202, long)
-#define ECHO_IOC_CANCEL _IOWR('f', 203, long)
-
-/* XXX _IOWR('f', 250, long) has been defined in
- * lnet/include/libcfs/kp30.h for debug, don't use it
- */
-
-/* Until such time as we get_info the per-stripe maximum from the OST,
- * we define this to be 2T - 4k, which is the ext3 maxbytes. */
-#define LUSTRE_STRIPE_MAXBYTES 0x1fffffff000ULL
-
-#define POISON_BULK 0
-
-static inline int ll_insecure_random_int(void)
-{
- struct timeval t;
- do_gettimeofday(&t);
- return (int)(t.tv_usec);
-}
-
-/*
- * l_wait_event is a flexible sleeping function, permitting simple caller
- * configuration of interrupt and timeout sensitivity along with actions to
- * be performed in the event of either exception.
- *
- * Common usage looks like this:
- *
- * struct l_wait_info lwi = LWI_TIMEOUT_INTR(timeout, timeout_handler,
- * intr_handler, callback_data);
- * rc = l_wait_event(waitq, condition, &lwi);
- *
- * (LWI_TIMEOUT and LWI_INTR macros are available for timeout- and
- * interrupt-only variants, respectively.)
- *
- * If a timeout is specified, the timeout_handler will be invoked in the event
- * that the timeout expires before the process is awakened. (Note that any
- * waking of the process will restart the timeout, even if the condition is
- * not satisfied and the process immediately returns to sleep. This might be
- * considered a bug.) If the timeout_handler returns non-zero, l_wait_event
- * will return -ETIMEDOUT and the caller will continue. If the handler returns
- * zero instead, the process will go back to sleep until it is awakened by the
- * waitq or some similar mechanism, or an interrupt occurs (if the caller has
- * asked for interrupts to be detected). The timeout will only fire once, so
- * callers should take care that a timeout_handler which returns zero will take
- * future steps to awaken the process. N.B. that these steps must include
- * making the provided condition become true.
- *
- * If the interrupt flag (lwi_signals) is non-zero, then the process will be
- * interruptible, and will be awakened by any "killable" signal (SIGTERM,
- * SIGKILL or SIGINT). If a timeout is also specified, then the process will
- * only become interruptible _after_ the timeout has expired, though it can be
- * awakened by a signal that was delivered before the timeout and is still
- * pending when the timeout expires. If a timeout is not specified, the process
- * will be interruptible at all times during l_wait_event.
- */
-
-struct l_wait_info {
- long lwi_timeout;
- int (*lwi_on_timeout)(void *);
- long lwi_signals;
- void (*lwi_on_signal)(void *);
- void *lwi_cb_data;
-};
-
-#define LWI_TIMEOUT(time, cb, data) \
-((struct l_wait_info) { \
- lwi_timeout: time, \
- lwi_on_timeout: cb, \
- lwi_cb_data: data \
-})
-
-#define LWI_INTR(cb, data) \
-((struct l_wait_info) { \
- lwi_signals: 1, \
- lwi_on_signal: cb, \
- lwi_cb_data: data \
-})
-
-#define LWI_TIMEOUT_INTR(time, time_cb, sig_cb, data) \
-((struct l_wait_info) { \
- lwi_timeout: time, \
- lwi_on_timeout: time_cb, \
- lwi_signals: 1, \
- lwi_on_signal: sig_cb, \
- lwi_cb_data: data \
-})
+#define OBD_IOC_DATA_TYPE long
#define LUSTRE_FATAL_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | \
sigmask(SIGTERM) | sigmask(SIGQUIT) | \
return old;
}
-
-#define __l_wait_event(wq, condition, info, ret, excl) \
-do { \
- wait_queue_t __wait; \
- int __timed_out = 0; \
- unsigned long irqflags; \
- sigset_t blocked; \
- signed long timeout_remaining; \
- \
- init_waitqueue_entry(&__wait, current); \
- if (excl) \
- add_wait_queue_exclusive(&wq, &__wait); \
- else \
- add_wait_queue(&wq, &__wait); \
- \
- /* Block all signals (just the non-fatal ones if no timeout). */ \
- if (info->lwi_signals && !info->lwi_timeout) \
- blocked = l_w_e_set_sigs(LUSTRE_FATAL_SIGS); \
- else \
- blocked = l_w_e_set_sigs(0); \
- \
- timeout_remaining = info->lwi_timeout; \
- \
- for (;;) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- if (condition) \
- break; \
- if (info->lwi_timeout && !__timed_out) { \
- timeout_remaining = schedule_timeout(timeout_remaining); \
- if (timeout_remaining == 0) { \
- __timed_out = 1; \
- if (!info->lwi_on_timeout || \
- info->lwi_on_timeout(info->lwi_cb_data)) { \
- ret = -ETIMEDOUT; \
- break; \
- } \
- /* We'll take signals after a timeout. */ \
- if (info->lwi_signals) \
- (void)l_w_e_set_sigs(LUSTRE_FATAL_SIGS); \
- } \
- } else { \
- schedule(); \
- } \
- if (condition) \
- break; \
- if (signal_pending(current)) { \
- if (!info->lwi_timeout || __timed_out) { \
- break; \
- } else { \
- /* We have to do this here because some signals */ \
- /* are not blockable - ie from strace(1). */ \
- /* In these cases we want to schedule_timeout() */ \
- /* again, because we don't want that to return */ \
- /* -EINTR when the RPC actually succeeded. */ \
- /* the RECALC_SIGPENDING below will deliver the */ \
- /* signal properly. */ \
- SIGNAL_MASK_LOCK(current, irqflags); \
- CLEAR_SIGPENDING; \
- SIGNAL_MASK_UNLOCK(current, irqflags); \
- } \
- } \
- } \
- \
- SIGNAL_MASK_LOCK(current, irqflags); \
- current->blocked = blocked; \
- RECALC_SIGPENDING; \
- SIGNAL_MASK_UNLOCK(current, irqflags); \
- \
- if ((!info->lwi_timeout || __timed_out) && signal_pending(current)) { \
- if (info->lwi_on_signal) \
- info->lwi_on_signal(info->lwi_cb_data); \
- ret = -EINTR; \
- } \
- \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&wq, &__wait); \
-} while(0)
-
-#else /* !__KERNEL__ */
-#define __l_wait_event(wq, condition, info, ret, excl) \
-do { \
- long timeout = info->lwi_timeout, elapse, last = 0; \
- int __timed_out = 0; \
- \
- if (info->lwi_timeout == 0) \
- timeout = 1000000000; \
- else \
- last = time(NULL); \
- \
- for (;;) { \
- if (condition) \
- break; \
- if (liblustre_wait_event(timeout)) { \
- if (timeout == 0 || info->lwi_timeout == 0) \
- continue; \
- elapse = time(NULL) - last; \
- if (elapse) { \
- last += elapse; \
- timeout -= elapse; \
- if (timeout < 0) \
- timeout = 0; \
- } \
- continue; \
- } \
- if (info->lwi_timeout && !__timed_out) { \
- __timed_out = 1; \
- if (info->lwi_on_timeout == NULL || \
- info->lwi_on_timeout(info->lwi_cb_data)) { \
- ret = -ETIMEDOUT; \
- break; \
- } \
- } \
- } \
-} while (0)
-
-#endif /* __KERNEL__ */
-
-#define l_wait_event(wq, condition, info) \
-({ \
- int __ret = 0; \
- struct l_wait_info *__info = (info); \
- if (!(condition)) \
- __l_wait_event(wq, condition, __info, __ret, 0); \
- __ret; \
-})
-
-#define l_wait_event_exclusive(wq, condition, info) \
-({ \
- int __ret = 0; \
- struct l_wait_info *__info = (info); \
- if (!(condition)) \
- __l_wait_event(wq, condition, __info, __ret, 1); \
- __ret; \
-})
-
-#define LMD_MAGIC_R1 0xbdacbdac
-#define LMD_MAGIC 0xbdacbd02
-
-#define lmd_bad_magic(LMDP) \
-({ \
- struct lustre_mount_data *_lmd__ = (LMDP); \
- int _ret__ = 0; \
- if (!_lmd__) { \
- LCONSOLE_ERROR("Missing mount data: " \
- "check that /sbin/mount.lustre is installed.\n");\
- _ret__ = 1; \
- } else if (_lmd__->lmd_magic == LMD_MAGIC_R1) { \
- LCONSOLE_ERROR("You're using an old version of " \
- "/sbin/mount.lustre. Please install version " \
- "1.%d\n", LMD_MAGIC & 0xFF); \
- _ret__ = 1; \
- } else if (_lmd__->lmd_magic != LMD_MAGIC) { \
- LCONSOLE_ERROR("Invalid mount data (%#x != %#x): " \
- "check that /sbin/mount.lustre is installed\n", \
- _lmd__->lmd_magic, LMD_MAGIC); \
- _ret__ = 1; \
- } \
- _ret__; \
-})
-
-#ifdef __KERNEL__
-#define LIBLUSTRE_CLIENT (0)
-#else
-#define LIBLUSTRE_CLIENT (1)
#endif
#endif /* _LUSTRE_LIB_H */
* vim:expandtab:shiftwidth=8:tabstop=8:
+#ifndef _LINUX_LL_H
+#define _LINUX_LL_H
+
#ifndef _LL_H
-#define _LL_H
+#error Do not #include this file directly. #include <lustre_lite.h> instead
+#endif
#ifdef __KERNEL__
#include <linux/ext3_fs.h>
#include <linux/proc_fs.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_ha.h>
+#include <obd_class.h>
+#include <lustre_net.h>
+#include <lustre_mds.h>
+#include <lustre_ha.h>
#include <linux/rbtree.h>
#include <linux/lustre_compat25.h>
#include <linux/pagemap.h>
-/* careful, this is easy to screw up */
-#define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << PAGE_CACHE_SHIFT)
-
/* lprocfs.c */
enum {
LPROC_LL_DIRTY_HITS = 0,
};
#else
-#include <linux/lustre_idl.h>
+#include <lustre_idl.h>
#endif /* __KERNEL__ */
-#define LLAP_FROM_COOKIE(c) \
- (LASSERT(((struct ll_async_page *)(c))->llap_magic == LLAP_MAGIC), \
- (struct ll_async_page *)(c))
-
-#define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
-
-#include <lustre/lustre_user.h>
-
#endif
-
-struct lustre_rw_params {
- int lrp_lock_mode;
- ldlm_policy_data_t lrp_policy;
- obd_flag lrp_brw_flags;
- int lrp_ast_flags;
-};
-
-/*
- * XXX nikita: this function lives in the header because it is used by both
- * llite kernel module and liblustre library, and there is no (?) better place
- * to put it in.
- */
-static inline void lustre_build_lock_params(int cmd, unsigned long open_flags,
- __u64 connect_flags,
- loff_t pos, ssize_t len,
- struct lustre_rw_params *params)
-{
- params->lrp_lock_mode = (cmd == OBD_BRW_READ) ? LCK_PR : LCK_PW;
- params->lrp_brw_flags = 0;
-
- params->lrp_policy.l_extent.start = pos;
- params->lrp_policy.l_extent.end = pos + len - 1;
- /*
- * for now O_APPEND always takes local locks.
- */
- if (cmd == OBD_BRW_WRITE && (open_flags & O_APPEND)) {
- params->lrp_policy.l_extent.start = 0;
- params->lrp_policy.l_extent.end = OBD_OBJECT_EOF;
- } else if (LIBLUSTRE_CLIENT && (connect_flags & OBD_CONNECT_SRVLOCK)) {
- /*
- * liblustre: OST-side locking for all non-O_APPEND
- * reads/writes.
- */
- params->lrp_lock_mode = LCK_NL;
- params->lrp_brw_flags = OBD_BRW_SRVLOCK;
- } else {
- /*
- * nothing special for the kernel. In the future llite may use
- * OST-side locks for small writes into highly contended
- * files.
- */
- }
- params->lrp_ast_flags = (open_flags & O_NONBLOCK) ?
- LDLM_FL_BLOCK_NOWAIT : 0;
-}
* - MDS replication logs
*/
-#ifndef _LUSTRE_LOG_H
-#define _LUSTRE_LOG_H
-
-#include <linux/obd.h>
-#include <linux/lustre_idl.h>
-
-#define LOG_NAME_LIMIT(logname, name) \
- snprintf(logname, sizeof(logname), "LOGS/%s", name)
-#define LLOG_EEMPTY 4711
-
-struct plain_handle_data {
- struct list_head phd_entry;
- struct llog_handle *phd_cat_handle;
- struct llog_cookie phd_cookie; /* cookie of this log in its cat */
- int phd_last_idx;
-};
-
-struct cat_handle_data {
- struct list_head chd_head;
- struct llog_handle *chd_current_log; /* currently open log */
-};
-
-/* In-memory descriptor for a log object or log catalog */
-struct llog_handle {
- struct rw_semaphore lgh_lock;
- struct llog_logid lgh_id; /* id of this log */
- struct llog_log_hdr *lgh_hdr;
- struct file *lgh_file;
- int lgh_last_idx;
- struct llog_ctxt *lgh_ctxt;
- union {
- struct plain_handle_data phd;
- struct cat_handle_data chd;
- } u;
-};
-
-/* llog.c - general API */
-typedef int (*llog_cb_t)(struct llog_handle *, struct llog_rec_hdr *, void *);
-typedef int (*llog_fill_rec_cb_t)(struct llog_rec_hdr *rec, void *data);
-extern struct llog_handle *llog_alloc_handle(void);
-int llog_init_handle(struct llog_handle *handle, int flags,
- struct obd_uuid *uuid);
-extern void llog_free_handle(struct llog_handle *handle);
-int llog_process(struct llog_handle *loghandle, llog_cb_t cb,
- void *data, void *catdata);
-extern int llog_cancel_rec(struct llog_handle *loghandle, int index);
-extern int llog_close(struct llog_handle *cathandle);
-
-/* llog_cat.c - catalog api */
-struct llog_process_data {
- void *lpd_data;
- llog_cb_t lpd_cb;
-};
-
-struct llog_process_cat_data {
- int first_idx;
- int last_idx;
- /* to process catalog across zero record */
-};
-
-int llog_cat_put(struct llog_handle *cathandle);
-int llog_cat_add_rec(struct llog_handle *cathandle, struct llog_rec_hdr *rec,
- struct llog_cookie *reccookie, void *buf);
-int llog_cat_cancel_records(struct llog_handle *cathandle, int count,
- struct llog_cookie *cookies);
-int llog_cat_process(struct llog_handle *cat_llh, llog_cb_t cb, void *data);
-int llog_cat_set_first_idx(struct llog_handle *cathandle, int index);
-
-/* llog_obd.c */
-int llog_setup(struct obd_device *obd, int index, struct obd_device *disk_obd,
- int count, struct llog_logid *logid,struct llog_operations *op);
-int llog_cleanup(struct llog_ctxt *);
-int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp);
-int llog_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
- struct lov_stripe_md *lsm, struct llog_cookie *logcookies,
- int numcookies);
-int llog_cancel(struct llog_ctxt *, struct lov_stripe_md *lsm,
- int count, struct llog_cookie *cookies, int flags);
-
-int llog_obd_origin_setup(struct obd_device *obd, int index,
- struct obd_device *disk_obd, int count,
- struct llog_logid *logid);
-int llog_obd_origin_cleanup(struct llog_ctxt *ctxt);
-int llog_obd_origin_add(struct llog_ctxt *ctxt,
- struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies);
-
-int llog_cat_initialize(struct obd_device *obd, int count);
-int obd_llog_init(struct obd_device *obd, struct obd_device *disk_obd,
- int count, struct llog_catid *logid);
-
-int obd_llog_finish(struct obd_device *obd, int count);
-
-/* llog_ioctl.c */
-int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data);
-int llog_catalog_list(struct obd_device *obd, int count,
- struct obd_ioctl_data *data);
-
-/* llog_net.c */
-int llog_initiator_connect(struct llog_ctxt *ctxt);
-int llog_receptor_accept(struct llog_ctxt *ctxt, struct obd_import *imp);
-int llog_origin_connect(struct llog_ctxt *ctxt, int count,
- struct llog_logid *logid, struct llog_gen *gen,
- struct obd_uuid *uuid);
-int llog_handle_connect(struct ptlrpc_request *req);
-
-/* recov_thread.c */
-int llog_obd_repl_cancel(struct llog_ctxt *ctxt,
- struct lov_stripe_md *lsm, int count,
- struct llog_cookie *cookies, int flags);
-int llog_obd_repl_sync(struct llog_ctxt *ctxt, struct obd_export *exp);
-int llog_repl_connect(struct llog_ctxt *ctxt, int count,
- struct llog_logid *logid, struct llog_gen *gen,
- struct obd_uuid *uuid);
-
-struct llog_operations {
- int (*lop_write_rec)(struct llog_handle *loghandle,
- struct llog_rec_hdr *rec,
- struct llog_cookie *logcookies, int numcookies,
- void *, int idx);
- int (*lop_destroy)(struct llog_handle *handle);
- int (*lop_next_block)(struct llog_handle *h, int *curr_idx,
- int next_idx, __u64 *offset, void *buf, int len);
- int (*lop_create)(struct llog_ctxt *ctxt, struct llog_handle **,
- struct llog_logid *logid, char *name);
- int (*lop_close)(struct llog_handle *handle);
- int (*lop_read_header)(struct llog_handle *handle);
-
- int (*lop_setup)(struct obd_device *obd, int ctxt_idx,
- struct obd_device *disk_obd, int count,
- struct llog_logid *logid);
- int (*lop_sync)(struct llog_ctxt *ctxt, struct obd_export *exp);
- int (*lop_cleanup)(struct llog_ctxt *ctxt);
- int (*lop_add)(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
- struct lov_stripe_md *lsm,
- struct llog_cookie *logcookies, int numcookies);
- int (*lop_cancel)(struct llog_ctxt *ctxt, struct lov_stripe_md *lsm,
- int count, struct llog_cookie *cookies, int flags);
- int (*lop_connect)(struct llog_ctxt *ctxt, int count,
- struct llog_logid *logid, struct llog_gen *gen,
- struct obd_uuid *uuid);
- /* XXX add 2 more: commit callbacks and llog recovery functions */
-};
-
-/* llog_lvfs.c */
-extern struct llog_operations llog_lvfs_ops;
-int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
- char *name, int count, struct llog_catid *idarray);
-
-struct llog_ctxt {
- int loc_idx; /* my index the obd array of ctxt's */
- struct llog_gen loc_gen;
- struct obd_device *loc_obd; /* points back to the containing obd*/
- struct obd_export *loc_exp;
- struct obd_import *loc_imp; /* to use in RPC's: can be backward
- pointing import */
- struct llog_operations *loc_logops;
- struct llog_handle *loc_handle;
- struct llog_canceld_ctxt *loc_llcd;
- struct semaphore loc_sem; /* protects loc_llcd and loc_imp */
- void *llog_proc_cb;
-};
-
-static inline void llog_gen_init(struct llog_ctxt *ctxt)
-{
- struct obd_device *obd = ctxt->loc_exp->exp_obd;
-
- if (!strcmp(obd->obd_type->typ_name, "mds"))
- ctxt->loc_gen.mnt_cnt = obd->u.mds.mds_mount_count;
- else if (!strstr(obd->obd_type->typ_name, "filter"))
- ctxt->loc_gen.mnt_cnt = obd->u.filter.fo_mount_count;
- else
- ctxt->loc_gen.mnt_cnt = 0;
-}
-
-static inline int llog_gen_lt(struct llog_gen a, struct llog_gen b)
-{
- if (a.mnt_cnt < b.mnt_cnt)
- return 1;
- if (a.mnt_cnt > b.mnt_cnt)
- return 0;
- return(a.conn_cnt < b.conn_cnt ? 1 : 0);
-}
-
-#define LLOG_GEN_INC(gen) ((gen).conn_cnt) ++
-#define LLOG_PROC_BREAK 0x0001
-
-static inline int llog_obd2ops(struct llog_ctxt *ctxt,
- struct llog_operations **lop)
-{
- if (ctxt == NULL)
- return -ENOTCONN;
-
- *lop = ctxt->loc_logops;
- if (*lop == NULL)
- return -EOPNOTSUPP;
+#ifndef _LINUX_LUSTRE_LOG_H
+#define _LINUX_LUSTRE_LOG_H
- return 0;
-}
-
-static inline int llog_handle2ops(struct llog_handle *loghandle,
- struct llog_operations **lop)
-{
- if (loghandle == NULL)
- return -EINVAL;
-
- return llog_obd2ops(loghandle->lgh_ctxt, lop);
-}
-
-static inline int llog_data_len(int len)
-{
- return size_round(len);
-}
-
-static inline struct llog_ctxt *llog_get_context(struct obd_device *obd,
- int index)
-{
- if (index < 0 || index >= LLOG_MAX_CTXTS)
- return NULL;
-
- return obd->obd_llog_ctxt[index];
-}
-
-static inline int llog_write_rec(struct llog_handle *handle,
- struct llog_rec_hdr *rec,
- struct llog_cookie *logcookies,
- int numcookies, void *buf, int idx)
-{
- struct llog_operations *lop;
- int rc, buflen;
- ENTRY;
-
- rc = llog_handle2ops(handle, &lop);
- if (rc)
- RETURN(rc);
- if (lop->lop_write_rec == NULL)
- RETURN(-EOPNOTSUPP);
-
- if (buf)
- buflen = rec->lrh_len + sizeof(struct llog_rec_hdr)
- + sizeof(struct llog_rec_tail);
- else
- buflen = rec->lrh_len;
- LASSERT(size_round(buflen) == buflen);
-
- rc = lop->lop_write_rec(handle, rec, logcookies, numcookies, buf, idx);
- RETURN(rc);
-}
-
-static inline int llog_read_header(struct llog_handle *handle)
-{
- struct llog_operations *lop;
- int rc;
- ENTRY;
-
- rc = llog_handle2ops(handle, &lop);
- if (rc)
- RETURN(rc);
- if (lop->lop_read_header == NULL)
- RETURN(-EOPNOTSUPP);
-
- rc = lop->lop_read_header(handle);
- RETURN(rc);
-}
-
-static inline int llog_destroy(struct llog_handle *handle)
-{
- struct llog_operations *lop;
- int rc;
- ENTRY;
-
- rc = llog_handle2ops(handle, &lop);
- if (rc)
- RETURN(rc);
- if (lop->lop_destroy == NULL)
- RETURN(-EOPNOTSUPP);
-
- rc = lop->lop_destroy(handle);
- RETURN(rc);
-}
-
-#if 0
-static inline int llog_cancel(struct obd_export *exp,
- struct lov_stripe_md *lsm, int count,
- struct llog_cookie *cookies, int flags)
-{
- struct llog_operations *lop;
- int rc;
- ENTRY;
-
- rc = llog_handle2ops(loghandle, &lop);
- if (rc)
- RETURN(rc);
- if (lop->lop_cancel == NULL)
- RETURN(-EOPNOTSUPP);
-
- rc = lop->lop_cancel(exp, lsm, count, cookies, flags);
- RETURN(rc);
-}
+#ifndef _LUSTRE_LOG_H
+#error Do not #include this file directly. #include <lustre_log.h> instead
#endif
-static inline int llog_next_block(struct llog_handle *loghandle, int *cur_idx,
- int next_idx, __u64 *cur_offset, void *buf,
- int len)
-{
- struct llog_operations *lop;
- int rc;
- ENTRY;
-
- rc = llog_handle2ops(loghandle, &lop);
- if (rc)
- RETURN(rc);
- if (lop->lop_next_block == NULL)
- RETURN(-EOPNOTSUPP);
-
- rc = lop->lop_next_block(loghandle, cur_idx, next_idx, cur_offset, buf,
- len);
- RETURN(rc);
-}
-
-static inline int llog_create(struct llog_ctxt *ctxt, struct llog_handle **res,
- struct llog_logid *logid, char *name)
-{
- struct llog_operations *lop;
- int rc;
- ENTRY;
-
- rc = llog_obd2ops(ctxt, &lop);
- if (rc)
- RETURN(rc);
- if (lop->lop_create == NULL)
- RETURN(-EOPNOTSUPP);
-
- rc = lop->lop_create(ctxt, res, logid, name);
- RETURN(rc);
-}
-
-static inline int llog_connect(struct llog_ctxt *ctxt, int count,
- struct llog_logid *logid, struct llog_gen *gen,
- struct obd_uuid *uuid)
-{
- struct llog_operations *lop;
- int rc;
- ENTRY;
-
- rc = llog_obd2ops(ctxt, &lop);
- if (rc)
- RETURN(rc);
- if (lop->lop_connect == NULL)
- RETURN(-EOPNOTSUPP);
-
- rc = lop->lop_connect(ctxt, count, logid, gen, uuid);
- RETURN(rc);
-}
+#define LUSTRE_LOG_SERVER
#endif
* See also lustre_idl.h for wire formats of requests.
*/
+#ifndef _LINUX_LUSTRE_MDS_H
+#define _LINUX_LUSTRE_MDS_H
+
#ifndef _LUSTRE_MDS_H
-#define _LUSTRE_MDS_H
+#error Do not #include this file directly. #include <lustre_mds.h> instead
+#endif
#ifdef __KERNEL__
# include <linux/fs.h>
# include <linux/dcache.h>
# include <linux/xattr_acl.h>
#endif
-#include <linux/lustre_handles.h>
-#include <libcfs/kp30.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_log.h>
-#include <linux/lustre_export.h>
struct ldlm_lock_desc;
struct mds_obd;
struct obd_device;
struct ll_file_data;
-#define LUSTRE_MDS_NAME "mds"
-#define LUSTRE_MDT_NAME "mdt"
-#define LUSTRE_MDC_NAME "mdc"
-
-struct lustre_md {
- struct mds_body *body;
- struct lov_stripe_md *lsm;
- struct posix_acl *posix_acl;
-};
-
-struct mdc_op_data {
- struct ll_fid fid1;
- struct ll_fid fid2;
- __u64 mod_time;
- const char *name;
- int namelen;
- __u32 create_mode;
- __u32 suppgids[2];
-};
-
-struct mds_update_record {
- __u32 ur_opcode;
- struct ll_fid *ur_fid1;
- struct ll_fid *ur_fid2;
- int ur_namelen;
- char *ur_name;
- int ur_tgtlen;
- char *ur_tgt;
- int ur_eadatalen;
- void *ur_eadata;
- int ur_cookielen;
- struct llog_cookie *ur_logcookies;
- struct iattr ur_iattr;
- struct lvfs_ucred ur_uc;
- __u64 ur_rdev;
- __u64 ur_time;
- __u32 ur_mode;
- __u32 ur_flags;
- struct lvfs_grp_hash_entry *ur_grp_entry;
-};
-
-#define MDS_LR_SERVER_SIZE 512
-
-#define MDS_LR_CLIENT_START 8192
-#define MDS_LR_CLIENT_SIZE 128
-#if MDS_LR_CLIENT_START < MDS_LR_SERVER_SIZE
-#error "Can't have MDS_LR_CLIENT_START < MDS_LR_SERVER_SIZE"
-#endif
-
-#define MDS_CLIENT_SLOTS 17
-
-#define MDS_ROCOMPAT_LOVOBJID 0x00000001
-#define MDS_ROCOMPAT_SUPP (MDS_ROCOMPAT_LOVOBJID)
-
-#define MDS_INCOMPAT_SUPP (0)
-
-/* Data stored per server at the head of the last_rcvd file. In le32 order.
- * Try to keep this the same as fsd_server_data so we might one day merge. */
-struct mds_server_data {
- __u8 msd_uuid[40]; /* server UUID */
- __u64 msd_last_transno; /* last completed transaction ID */
- __u64 msd_mount_count; /* MDS incarnation number */
- __u64 msd_unused;
- __u32 msd_feature_compat; /* compatible feature flags */
- __u32 msd_feature_rocompat;/* read-only compatible feature flags */
- __u32 msd_feature_incompat;/* incompatible feature flags */
- __u32 msd_server_size; /* size of server data area */
- __u32 msd_client_start; /* start of per-client data area */
- __u16 msd_client_size; /* size of per-client data area */
- __u16 msd_subdir_count; /* number of subdirectories for objects */
- __u64 msd_catalog_oid; /* recovery catalog object id */
- __u32 msd_catalog_ogen; /* recovery catalog inode generation */
- __u8 msd_peeruuid[40]; /* UUID of LOV/OSC associated with MDS */
- __u8 msd_padding[MDS_LR_SERVER_SIZE - 140];
-};
-
-/* Data stored per client in the last_rcvd file. In le32 order. */
-struct mds_client_data {
- __u8 mcd_uuid[40]; /* client UUID */
- __u64 mcd_last_transno; /* last completed transaction ID */
- __u64 mcd_last_xid; /* xid for the last transaction */
- __u32 mcd_last_result; /* result from last RPC */
- __u32 mcd_last_data; /* per-op data (disposition for open &c.) */
- __u8 mcd_padding[MDS_LR_CLIENT_SIZE - 64];
-};
-
-/* file data for open files on MDS */
-struct mds_file_data {
- struct portals_handle mfd_handle; /* must be first */
- atomic_t mfd_refcount;
- struct list_head mfd_list; /* protected by med_open_lock */
- __u64 mfd_xid;
- int mfd_mode;
- struct dentry *mfd_dentry;
-};
-
-/* ACL */
-#define LUSTRE_POSIX_ACL_MAX_ENTRIES (32)
-#define LUSTRE_POSIX_ACL_MAX_SIZE \
- (xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES))
-
-/* mds/mds_reint.c */
-int mds_reint_rec(struct mds_update_record *r, int offset,
- struct ptlrpc_request *req, struct lustre_handle *);
-
/* mds/handler.c */
#ifdef __KERNEL__
struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
int mds_fs_cleanup(struct obd_device *obddev);
#endif
-/* mds/mds_lov.c */
-
-/* mdc/mdc_locks.c */
-int it_disposition(struct lookup_intent *it, int flag);
-void it_set_disposition(struct lookup_intent *it, int flag);
-int it_open_error(int phase, struct lookup_intent *it);
-void mdc_set_lock_data(__u64 *lockh, void *data);
-int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid,
- ldlm_iterator_t it, void *data);
-int mdc_intent_lock(struct obd_export *exp,
- struct mdc_op_data *,
- void *lmm, int lmmsize,
- struct lookup_intent *, int,
- struct ptlrpc_request **reqp,
- ldlm_blocking_callback cb_blocking, int extra_lock_flags);
-int mdc_enqueue(struct obd_export *exp,
- int lock_type,
- struct lookup_intent *it,
- int lock_mode,
- struct mdc_op_data *data,
- struct lustre_handle *lockh,
- void *lmm,
- int lmmlen,
- ldlm_completion_callback cb_completion,
- ldlm_blocking_callback cb_blocking,
- void *cb_data, int extra_lock_flags);
-
-/* mdc/mdc_request.c */
-int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp);
-int mdc_req2lustre_md(struct ptlrpc_request *req, int offset,
- struct obd_export *exp, struct lustre_md *md);
-void mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md);
-int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid);
-int mdc_getattr(struct obd_export *exp, struct ll_fid *fid,
- obd_valid valid, unsigned int ea_size,
- struct ptlrpc_request **request);
-int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
- char *filename, int namelen, unsigned long valid,
- unsigned int ea_size, struct ptlrpc_request **request);
-int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data,
- struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len,
- struct ptlrpc_request **request);
-int mdc_setxattr(struct obd_export *exp, struct ll_fid *fid,
- obd_valid valid, const char *xattr_name,
- const char *input, int input_size,
- int output_size, int flags,
- struct ptlrpc_request **request);
-int mdc_getxattr(struct obd_export *exp, struct ll_fid *fid,
- obd_valid valid, const char *xattr_name,
- const char *input, int input_size,
- int output_size, struct ptlrpc_request **request);
-int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags,
- struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh,
- struct ptlrpc_request **);
-struct obd_client_handle;
-void mdc_set_open_replay_data(struct obd_client_handle *och,
- struct ptlrpc_request *open_req);
-void mdc_clear_open_replay_data(struct obd_client_handle *och);
-int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *,
- struct ptlrpc_request **);
-int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset,
- struct page *, struct ptlrpc_request **);
-int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
- const void *data, int datalen, int mode, __u32 uid, __u32 gid,
- __u32 cap_effective, __u64 rdev,struct ptlrpc_request **request);
-int mdc_unlink(struct obd_export *exp, struct mdc_op_data *data,
- struct ptlrpc_request **request);
-int mdc_link(struct obd_export *exp, struct mdc_op_data *data,
- struct ptlrpc_request **);
-int mdc_rename(struct obd_export *exp, struct mdc_op_data *data,
- const char *old, int oldlen, const char *new, int newlen,
- struct ptlrpc_request **request);
-int mdc_sync(struct obd_export *exp, struct ll_fid *fid,
- struct ptlrpc_request **);
-int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl);
-
-/* Store the generation of a newly-created inode in |req| for replay. */
-void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
- int repoff);
-int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data);
-int mdc_done_writing(struct obd_export *exp, struct obdo *);
-
-static inline void mdc_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen,
- int type)
-{
- fid->id = ino;
- fid->generation = gen;
- fid->f_type = type;
-}
-
-/* ioctls for trying requests */
-#define IOC_REQUEST_TYPE 'f'
-#define IOC_REQUEST_MIN_NR 30
-
-#define IOC_REQUEST_GETATTR _IOWR('f', 30, long)
-#define IOC_REQUEST_READPAGE _IOWR('f', 31, long)
-#define IOC_REQUEST_SETATTR _IOWR('f', 32, long)
-#define IOC_REQUEST_CREATE _IOWR('f', 33, long)
-#define IOC_REQUEST_OPEN _IOWR('f', 34, long)
-#define IOC_REQUEST_CLOSE _IOWR('f', 35, long)
-#define IOC_REQUEST_MAX_NR 35
-
#endif
*
*/
+#ifndef _LINUX_LUSTRE_NET_H
+#define _LINUX_LUSTRE_NET_H
+
#ifndef _LUSTRE_NET_H
-#define _LUSTRE_NET_H
+#error Do not #include this file directly. #include <lustre_net.h> instead
+#endif
#ifdef __KERNEL__
#include <linux/version.h>
#endif
#endif
-#include <libcfs/kp30.h>
-// #include <linux/obd.h>
-#include <lnet/lnet.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_import.h>
-#include <linux/lprocfs_status.h>
-
-/* MD flags we _always_ use */
-#define PTLRPC_MD_OPTIONS 0
-
-/* Define maxima for bulk I/O
- * CAVEAT EMPTOR, with multinet (i.e. routers forwarding between networks)
- * these limits are system wide and not interface-local. */
-#define PTLRPC_MAX_BRW_SIZE LNET_MTU
-#define PTLRPC_MAX_BRW_PAGES (PTLRPC_MAX_BRW_SIZE/PAGE_SIZE)
-
-/* When PAGE_SIZE is a constant, we can check our arithmetic here with cpp! */
-#ifdef __KERNEL__
-# if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
-# error "PTLRPC_MAX_BRW_PAGES isn't a power of two"
-# endif
-# if (PTLRPC_MAX_BRW_SIZE != (PTLRPC_MAX_BRW_PAGES * PAGE_SIZE))
-# error "PTLRPC_MAX_BRW_SIZE isn't PTLRPC_MAX_BRW_PAGES * PAGE_SIZE"
-# endif
-# if (PTLRPC_MAX_BRW_SIZE > LNET_MTU)
-# error "PTLRPC_MAX_BRW_SIZE too big"
-# endif
-# if (PTLRPC_MAX_BRW_PAGES > LNET_MAX_IOV)
-# error "PTLRPC_MAX_BRW_PAGES too big"
-# endif
-#endif /* __KERNEL__ */
-
-/* Size over which to OBD_VMALLOC() rather than OBD_ALLOC() service request
- * buffers */
-#define SVC_BUF_VMALLOC_THRESHOLD (2 * PAGE_SIZE)
-
-/* The following constants determine how memory is used to buffer incoming
- * service requests.
- *
- * ?_NBUFS # buffers to allocate when growing the pool
- * ?_BUFSIZE # bytes in a single request buffer
- * ?_MAXREQSIZE # maximum request service will receive
- *
- * When fewer than ?_NBUFS/2 buffers are posted for receive, another chunk
- * of ?_NBUFS is added to the pool.
- *
- * Messages larger than ?_MAXREQSIZE are dropped. Request buffers are
- * considered full when less than ?_MAXREQSIZE is left in them.
- */
-
-#define LDLM_NUM_THREADS min((int)(smp_num_cpus * smp_num_cpus * 8), 64)
-#define LDLM_NBUFS 64
-#define LDLM_BUFSIZE (8 * 1024)
-#define LDLM_MAXREQSIZE (5 * 1024)
-#define LDLM_MAXREPSIZE (1024)
-
-#define MDT_MAX_THREADS 32UL
-#define MDT_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
- MDT_MAX_THREADS), 2UL)
-#define MDS_NBUFS (64 * smp_num_cpus)
-#define MDS_BUFSIZE (8 * 1024)
-/* Assume file name length = FNAME_MAX = 256 (true for ext3).
- * path name length = PATH_MAX = 4096
- * LOV MD size max = EA_MAX = 4000
- * symlink: FNAME_MAX + PATH_MAX <- largest
- * link: FNAME_MAX + PATH_MAX (mds_rec_link < mds_rec_create)
- * rename: FNAME_MAX + FNAME_MAX
- * open: FNAME_MAX + EA_MAX
- *
- * MDS_MAXREQSIZE ~= 4736 bytes =
- * lustre_msg + ldlm_request + mds_body + mds_rec_create + FNAME_MAX + PATH_MAX
- *
- * Realistic size is about 512 bytes (20 character name + 128 char symlink),
- * except in the open case where there are a large number of OSTs in a LOV.
- */
-#define MDS_MAXREQSIZE (5 * 1024)
-#define MDS_MAXREPSIZE (9 * 1024)
-
-#define OST_MAX_THREADS 36UL
-#define OST_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
- OST_MAX_THREADS), 2UL)
-#define OST_NBUFS (64 * smp_num_cpus)
-#define OST_BUFSIZE (8 * 1024)
-/* OST_MAXREQSIZE ~= 4768 bytes =
- * lustre_msg + obdo + 16 * obd_ioobj + 256 * niobuf_remote
- *
- * - single object with 16 pages is 512 bytes
- * - OST_MAXREQSIZE must be at least 1 page of cookies plus some spillover
- */
-#define OST_MAXREQSIZE (5 * 1024)
-#define OST_MAXREPSIZE (9 * 1024)
-
-#define PTLBD_NUM_THREADS 4
-#define PTLBD_NBUFS 64
-#define PTLBD_BUFSIZE (32 * 1024)
-#define PTLBD_MAXREQSIZE 1024
-
-struct ptlrpc_connection {
- struct list_head c_link;
- lnet_nid_t c_self;
- lnet_process_id_t c_peer;
- struct obd_uuid c_remote_uuid;
- atomic_t c_refcount;
-};
-
-struct ptlrpc_client {
- __u32 cli_request_portal;
- __u32 cli_reply_portal;
- char *cli_name;
-};
-
-/* state flags of requests */
-/* XXX only ones left are those used by the bulk descs as well! */
-#define PTL_RPC_FL_INTR (1 << 0) /* reply wait was interrupted by user */
-#define PTL_RPC_FL_TIMEOUT (1 << 7) /* request timed out waiting for reply */
-
-#define REQ_MAX_ACK_LOCKS 8
-
-#define SWAB_PARANOIA 1
-#if SWAB_PARANOIA
-/* unpacking: assert idx not unpacked already */
-#define LASSERT_REQSWAB(rq, idx) \
-do { \
- LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8); \
- LASSERT (((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
- (rq)->rq_req_swab_mask |= (1 << (idx)); \
-} while (0)
-
-#define LASSERT_REPSWAB(rq, idx) \
-do { \
- LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8); \
- LASSERT (((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
- (rq)->rq_rep_swab_mask |= (1 << (idx)); \
-} while (0)
-
-/* just looking: assert idx already unpacked */
-#define LASSERT_REQSWABBED(rq, idx) \
-LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8 && \
- ((rq)->rq_req_swab_mask & (1 << (idx))) != 0)
-
-#define LASSERT_REPSWABBED(rq, idx) \
-LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8 && \
- ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0)
-#else
-#define LASSERT_REQSWAB(rq, idx)
-#define LASSERT_REPSWAB(rq, idx)
-#define LASSERT_REQSWABBED(rq, idx)
-#define LASSERT_REPSWABBED(rq, idx)
-#endif
-
-union ptlrpc_async_args {
- /* Scratchpad for passing args to completion interpreter. Users
- * cast to the struct of their choosing, and LASSERT that this is
- * big enough. For _tons_ of context, OBD_ALLOC a struct and store
- * a pointer to it here. The pointer_arg ensures this struct is at
- * least big enough for that. */
- void *pointer_arg[9];
- __u64 space[4];
-};
-
-struct ptlrpc_request_set;
-typedef int (*set_interpreter_func)(struct ptlrpc_request_set *, void *, int);
-
-struct ptlrpc_request_set {
- int set_remaining; /* # uncompleted requests */
- wait_queue_head_t set_waitq;
- wait_queue_head_t *set_wakeup_ptr;
- struct list_head set_requests;
- set_interpreter_func set_interpret; /* completion callback */
- void *set_arg; /* completion context */
- /* locked so that any old caller can communicate requests to
- * the set holder who can then fold them into the lock-free set */
- spinlock_t set_new_req_lock;
- struct list_head set_new_requests;
-};
-
-struct ptlrpc_bulk_desc;
-
-/*
- * ptlrpc callback & work item stuff
- */
-struct ptlrpc_cb_id {
- void (*cbid_fn)(lnet_event_t *ev); /* specific callback fn */
- void *cbid_arg; /* additional arg */
-};
-
-#define RS_MAX_LOCKS 4
-#define RS_DEBUG 1
-
-struct ptlrpc_reply_state {
- struct ptlrpc_cb_id rs_cb_id;
- struct list_head rs_list;
- struct list_head rs_exp_list;
- struct list_head rs_obd_list;
-#if RS_DEBUG
- struct list_head rs_debug_list;
-#endif
- /* updates to following flag serialised by srv_request_lock */
- unsigned int rs_difficult:1; /* ACK/commit stuff */
- unsigned int rs_scheduled:1; /* being handled? */
- unsigned int rs_scheduled_ever:1;/* any schedule attempts? */
- unsigned int rs_handled:1; /* been handled yet? */
- unsigned int rs_on_net:1; /* reply_out_callback pending? */
- unsigned int rs_prealloc:1; /* rs from prealloc list */
-
- int rs_size;
- __u64 rs_transno;
- __u64 rs_xid;
- struct obd_export *rs_export;
- struct ptlrpc_service *rs_service;
- lnet_handle_md_t rs_md_h;
- atomic_t rs_refcount;
-
- /* locks awaiting client reply ACK */
- int rs_nlocks;
- struct lustre_handle rs_locks[RS_MAX_LOCKS];
- ldlm_mode_t rs_modes[RS_MAX_LOCKS];
- /* last member: variable sized reply message */
- struct lustre_msg rs_msg;
-};
-
-struct ptlrpc_thread;
-
-enum rq_phase {
- RQ_PHASE_NEW = 0xebc0de00,
- RQ_PHASE_RPC = 0xebc0de01,
- RQ_PHASE_BULK = 0xebc0de02,
- RQ_PHASE_INTERPRET = 0xebc0de03,
- RQ_PHASE_COMPLETE = 0xebc0de04,
-};
-
-struct ptlrpc_request_pool {
- spinlock_t prp_lock;
- struct list_head prp_req_list; /* list of ptlrpc_request structs */
- int prp_rq_size;
- void (*prp_populate)(struct ptlrpc_request_pool *, int);
-};
-
-struct ptlrpc_request {
- int rq_type; /* one of PTL_RPC_MSG_* */
- struct list_head rq_list;
- struct list_head rq_history_list; /* server-side history */
- __u64 rq_history_seq; /* history sequence # */
- int rq_status;
- spinlock_t rq_lock;
- /* client-side flags */
- unsigned int rq_intr:1, rq_replied:1, rq_err:1,
- rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
- rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
- rq_no_delay:1, rq_net_err:1;
- enum rq_phase rq_phase; /* one of RQ_PHASE_* */
- atomic_t rq_refcount; /* client-side refcount for SENT race */
-
- struct ptlrpc_thread *rq_svc_thread; /* initial thread servicing req */
-
- int rq_request_portal; /* XXX FIXME bug 249 */
- int rq_reply_portal; /* XXX FIXME bug 249 */
-
- int rq_nob_received; /* client-side # reply bytes actually received */
-
- int rq_reqlen;
- struct lustre_msg *rq_reqmsg;
-
- int rq_timeout; /* seconds */
- int rq_replen;
- struct lustre_msg *rq_repmsg;
- __u64 rq_transno;
- __u64 rq_xid;
- struct list_head rq_replay_list;
-
-#if SWAB_PARANOIA
- __u32 rq_req_swab_mask;
- __u32 rq_rep_swab_mask;
-#endif
-
- int rq_import_generation;
- enum lustre_imp_state rq_send_state;
-
- /* client+server request */
- lnet_handle_md_t rq_req_md_h;
- struct ptlrpc_cb_id rq_req_cbid;
-
- /* server-side... */
- struct timeval rq_arrival_time; /* request arrival time */
- struct ptlrpc_reply_state *rq_reply_state; /* separated reply state */
- struct ptlrpc_request_buffer_desc *rq_rqbd; /* incoming request buffer*/
-#if CRAY_XT3
-# error "Need to get the uid from the event?"
- __u32 rq_uid; /* peer uid, used in MDS only */
-#endif
-
- /* client-only incoming reply */
- lnet_handle_md_t rq_reply_md_h;
- wait_queue_head_t rq_reply_waitq;
- struct ptlrpc_cb_id rq_reply_cbid;
-
- lnet_nid_t rq_self;
- lnet_process_id_t rq_peer;
- struct obd_export *rq_export;
- struct obd_import *rq_import;
-
- void (*rq_replay_cb)(struct ptlrpc_request *);
- void (*rq_commit_cb)(struct ptlrpc_request *);
- void *rq_cb_data;
-
- struct ptlrpc_bulk_desc *rq_bulk; /* client side bulk */
- time_t rq_sent; /* when request sent, seconds */
-
- /* Multi-rpc bits */
- struct list_head rq_set_chain;
- struct ptlrpc_request_set *rq_set;
- void *rq_interpret_reply; /* Async completion handler */
- union ptlrpc_async_args rq_async_args; /* Async completion context */
- void *rq_ptlrpcd_data;
- struct ptlrpc_request_pool *rq_pool; /* Pool if request from
- preallocated list */
-};
-
-static inline const char *
-ptlrpc_rqphase2str(struct ptlrpc_request *req)
-{
- switch (req->rq_phase) {
- case RQ_PHASE_NEW:
- return "New";
- case RQ_PHASE_RPC:
- return "Rpc";
- case RQ_PHASE_BULK:
- return "Bulk";
- case RQ_PHASE_INTERPRET:
- return "Interpret";
- case RQ_PHASE_COMPLETE:
- return "Complete";
- default:
- return "?Phase?";
- }
-}
-
-/* Spare the preprocessor, spoil the bugs. */
-#define FLAG(field, str) (field ? str : "")
-
-#define DEBUG_REQ_FLAGS(req) \
- ptlrpc_rqphase2str(req), \
- FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"), \
- FLAG(req->rq_err, "E"), \
- FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \
- FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"), \
- FLAG(req->rq_no_resend, "N"), \
- FLAG(req->rq_waiting, "W")
-
-#define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s"
-
-#define __DEBUG_REQ(CDEB_TYPE, level, req, fmt, args...) \
-CDEB_TYPE(level, "@@@ " fmt \
- " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d lens %d/%d ref %d fl " \
- REQ_FLAGS_FMT"/%x/%x rc %d/%d\n" , ## args, req, req->rq_xid, \
- req->rq_transno, \
- req->rq_reqmsg ? req->rq_reqmsg->opc : -1, \
- req->rq_import ? (char *)req->rq_import->imp_target_uuid.uuid : "<?>", \
- req->rq_import ? \
- (char *)req->rq_import->imp_connection->c_remote_uuid.uuid : "<?>", \
- (req->rq_import && req->rq_import->imp_client) ? \
- req->rq_import->imp_client->cli_request_portal : -1, \
- req->rq_reqlen, req->rq_replen, \
- atomic_read(&req->rq_refcount), \
- DEBUG_REQ_FLAGS(req), \
- req->rq_reqmsg ? req->rq_reqmsg->flags : 0, \
- req->rq_repmsg ? req->rq_repmsg->flags : 0, \
- req->rq_status, req->rq_repmsg ? req->rq_repmsg->status : 0)
-
-/* for most callers (level is a constant) this is resolved at compile time */
-#define DEBUG_REQ(level, req, fmt, args...) \
-do { \
- if ((level) & (D_ERROR | D_WARNING)) \
- __DEBUG_REQ(CDEBUG_LIMIT, level, req, fmt, ## args); \
- else \
- __DEBUG_REQ(CDEBUG, level, req, fmt, ## args); \
-} while (0)
-
-struct ptlrpc_bulk_page {
- struct list_head bp_link;
- int bp_buflen;
- int bp_pageoffset; /* offset within a page */
- struct page *bp_page;
-};
-
-#define BULK_GET_SOURCE 0
-#define BULK_PUT_SINK 1
-#define BULK_GET_SINK 2
-#define BULK_PUT_SOURCE 3
-
-struct ptlrpc_bulk_desc {
- unsigned int bd_success:1; /* completed successfully */
- unsigned int bd_network_rw:1; /* accessible to the network */
- unsigned int bd_type:2; /* {put,get}{source,sink} */
- unsigned int bd_registered:1; /* client side */
- spinlock_t bd_lock; /* serialise with callback */
- int bd_import_generation;
- struct obd_export *bd_export;
- struct obd_import *bd_import;
- __u32 bd_portal;
- struct ptlrpc_request *bd_req; /* associated request */
- wait_queue_head_t bd_waitq; /* server side only WQ */
- int bd_iov_count; /* # entries in bd_iov */
- int bd_max_iov; /* allocated size of bd_iov */
- int bd_nob; /* # bytes covered */
- int bd_nob_transferred; /* # bytes GOT/PUT */
-
- __u64 bd_last_xid;
-
- struct ptlrpc_cb_id bd_cbid; /* network callback info */
- lnet_handle_md_t bd_md_h; /* associated MD */
-
-#if defined(__KERNEL__)
- lnet_kiov_t bd_iov[0];
-#else
- lnet_md_iovec_t bd_iov[0];
+/* XXX Liang: should be moved to other header instead of here */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
+#ifndef WITH_GROUP_INFO
+#define WITH_GROUP_INFO
#endif
-};
-
-struct ptlrpc_thread {
-
- struct list_head t_link; /* active threads for service, from svc->srv_threads */
-
- void *t_data; /* thread-private data (preallocated memory) */
- __u32 t_flags;
-
- unsigned int t_id; /* service thread index, from ptlrpc_start_threads */
- wait_queue_head_t t_ctl_waitq;
-};
-
-struct ptlrpc_request_buffer_desc {
- struct list_head rqbd_list;
- struct list_head rqbd_reqs;
- struct ptlrpc_service *rqbd_service;
- lnet_handle_md_t rqbd_md_h;
- int rqbd_refcount;
- char *rqbd_buffer;
- struct ptlrpc_cb_id rqbd_cbid;
- struct ptlrpc_request rqbd_req;
-};
-
-typedef int (*svc_handler_t)(struct ptlrpc_request *req);
-typedef void (*svcreq_printfn_t)(void *, struct ptlrpc_request *);
-
-struct ptlrpc_service {
- struct list_head srv_list; /* chain thru all services */
- int srv_max_req_size; /* biggest request to receive */
- int srv_max_reply_size; /* biggest reply to send */
- int srv_buf_size; /* size of individual buffers */
- int srv_nbuf_per_group; /* # buffers to allocate in 1 group */
- int srv_nbufs; /* total # req buffer descs allocated */
- int srv_nthreads; /* # running threads */
- int srv_n_difficult_replies; /* # 'difficult' replies */
- int srv_n_active_reqs; /* # reqs being served */
- int srv_rqbd_timeout; /* timeout before re-posting reqs */
- int srv_watchdog_timeout; /* soft watchdog timeout, in ms */
- int srv_num_threads; /* # threads to start/started */
- unsigned srv_cpu_affinity:1; /* bind threads to CPUs */
-
- __u32 srv_req_portal;
- __u32 srv_rep_portal;
-
- int srv_n_queued_reqs; /* # reqs waiting to be served */
- struct list_head srv_request_queue; /* reqs waiting for service */
-
- struct list_head srv_request_history; /* request history */
- __u64 srv_request_seq; /* next request sequence # */
- __u64 srv_request_max_cull_seq; /* highest seq culled from history */
- svcreq_printfn_t srv_request_history_print_fn; /* service-specific print fn */
-
- struct list_head srv_idle_rqbds; /* request buffers to be reposted */
- struct list_head srv_active_rqbds; /* req buffers receiving */
- struct list_head srv_history_rqbds; /* request buffer history */
- int srv_nrqbd_receiving; /* # posted request buffers */
- int srv_n_history_rqbds; /* # request buffers in history */
- int srv_max_history_rqbds; /* max # request buffers in history */
-
- atomic_t srv_outstanding_replies;
- struct list_head srv_active_replies; /* all the active replies */
- struct list_head srv_reply_queue; /* replies waiting for service */
-
- wait_queue_head_t srv_waitq; /* all threads sleep on this */
-
- struct list_head srv_threads;
- struct obd_device *srv_obddev;
- svc_handler_t srv_handler;
-
- char *srv_name; /* only statically allocated strings here; we don't clean them */
-
- spinlock_t srv_lock;
-
- struct proc_dir_entry *srv_procroot;
- struct lprocfs_stats *srv_stats;
-
- /* List of free reply_states */
- struct list_head srv_free_rs_list;
- /* waitq to run, when adding stuff to srv_free_rs_list */
- wait_queue_head_t srv_free_rs_waitq;
-
- /*
- * if non-NULL called during thread creation (ptlrpc_start_thread())
- * to initialize service specific per-thread state.
- */
- int (*srv_init)(struct ptlrpc_thread *thread);
- /*
- * if non-NULL called during thread shutdown (ptlrpc_main()) to
- * destruct state created by ->srv_init().
- */
- void (*srv_done)(struct ptlrpc_thread *thread);
-
- //struct ptlrpc_srv_ni srv_interfaces[0];
-};
-
-/* ptlrpc/events.c */
-extern lnet_handle_eq_t ptlrpc_eq_h;
-extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
- lnet_process_id_t *peer, lnet_nid_t *self);
-extern void request_out_callback (lnet_event_t *ev);
-extern void reply_in_callback(lnet_event_t *ev);
-extern void client_bulk_callback (lnet_event_t *ev);
-extern void request_in_callback(lnet_event_t *ev);
-extern void reply_out_callback(lnet_event_t *ev);
-extern void server_bulk_callback (lnet_event_t *ev);
-
-/* ptlrpc/connection.c */
-void ptlrpc_dump_connections(void);
-void ptlrpc_readdress_connection(struct ptlrpc_connection *, struct obd_uuid *);
-struct ptlrpc_connection *ptlrpc_get_connection(lnet_process_id_t peer,
- lnet_nid_t self, struct obd_uuid *uuid);
-int ptlrpc_put_connection(struct ptlrpc_connection *c);
-struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
-void ptlrpc_init_connection(void);
-void ptlrpc_cleanup_connection(void);
-extern lnet_pid_t ptl_get_pid(void);
-
-/* ptlrpc/niobuf.c */
-int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
-void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
-int ptlrpc_register_bulk(struct ptlrpc_request *req);
-void ptlrpc_unregister_bulk (struct ptlrpc_request *req);
-
-static inline int ptlrpc_bulk_active (struct ptlrpc_bulk_desc *desc)
-{
- unsigned long flags;
- int rc;
-
- spin_lock_irqsave (&desc->bd_lock, flags);
- rc = desc->bd_network_rw;
- spin_unlock_irqrestore (&desc->bd_lock, flags);
- return (rc);
-}
-
-int ptlrpc_send_reply(struct ptlrpc_request *req, int);
-int ptlrpc_reply(struct ptlrpc_request *req);
-int ptlrpc_error(struct ptlrpc_request *req);
-void ptlrpc_resend_req(struct ptlrpc_request *request);
-int ptl_send_rpc(struct ptlrpc_request *request);
-int ptl_send_rpc_nowait(struct ptlrpc_request *request);
-int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd);
-
-/* ptlrpc/client.c */
-void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
- struct ptlrpc_client *);
-void ptlrpc_cleanup_client(struct obd_import *imp);
-struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
-
-static inline int
-ptlrpc_client_receiving_reply (struct ptlrpc_request *req)
-{
- unsigned long flags;
- int rc;
-
- spin_lock_irqsave(&req->rq_lock, flags);
- rc = req->rq_receiving_reply;
- spin_unlock_irqrestore(&req->rq_lock, flags);
- return (rc);
-}
-
-static inline int
-ptlrpc_client_replied (struct ptlrpc_request *req)
-{
- unsigned long flags;
- int rc;
-
- spin_lock_irqsave(&req->rq_lock, flags);
- rc = req->rq_replied;
- spin_unlock_irqrestore(&req->rq_lock, flags);
- return (rc);
-}
-
-static inline void
-ptlrpc_wake_client_req (struct ptlrpc_request *req)
-{
- if (req->rq_set == NULL)
- wake_up(&req->rq_reply_waitq);
- else
- wake_up(&req->rq_set->set_waitq);
-}
-
-int ptlrpc_queue_wait(struct ptlrpc_request *req);
-int ptlrpc_replay_req(struct ptlrpc_request *req);
-void ptlrpc_unregister_reply(struct ptlrpc_request *req);
-void ptlrpc_restart_req(struct ptlrpc_request *req);
-void ptlrpc_abort_inflight(struct obd_import *imp);
-
-struct ptlrpc_request_set *ptlrpc_prep_set(void);
-int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
-int ptlrpc_check_set(struct ptlrpc_request_set *set);
-int ptlrpc_set_wait(struct ptlrpc_request_set *);
-int ptlrpc_expired_set(void *data);
-void ptlrpc_interrupted_set(void *data);
-void ptlrpc_mark_interrupted(struct ptlrpc_request *req);
-void ptlrpc_set_destroy(struct ptlrpc_request_set *);
-void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *);
-void ptlrpc_set_add_new_req(struct ptlrpc_request_set *,
- struct ptlrpc_request *);
-
-void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool);
-void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
-struct ptlrpc_request_pool *ptlrpc_init_rq_pool(int, int,
- void (*populate_pool)(struct ptlrpc_request_pool *, int));
-struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, int opcode,
- int count, int *lengths, char **bufs);
-struct ptlrpc_request *ptlrpc_prep_req_pool(struct obd_import *imp, int opcode,
- int count, int *lengths,
- char **bufs,
- struct ptlrpc_request_pool *pool);
-void ptlrpc_free_req(struct ptlrpc_request *request);
-void ptlrpc_req_finished(struct ptlrpc_request *request);
-void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
-struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
-struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
- int npages, int type, int portal);
-struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
- int npages, int type, int portal);
-void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
-void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
- struct page *page, int pageoffset, int len);
-void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
- struct obd_import *imp);
-__u64 ptlrpc_next_xid(void);
-__u64 ptlrpc_sample_next_xid(void);
-__u64 ptlrpc_req_xid(struct ptlrpc_request *request);
-
-/* ptlrpc/service.c */
-void ptlrpc_save_lock (struct ptlrpc_request *req,
- struct lustre_handle *lock, int mode);
-void ptlrpc_commit_replies (struct obd_device *obd);
-void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
-struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
- int max_reply_size,
- int req_portal, int rep_portal,
- int watchdog_timeout, /* in ms */
- svc_handler_t, char *name,
- struct proc_dir_entry *proc_entry,
- svcreq_printfn_t, int num_threads);
-void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
-
-int ptlrpc_start_threads(struct obd_device *dev, struct ptlrpc_service *svc,
- char *base_name);
-int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc,
- char *name, int id);
-int ptlrpc_unregister_service(struct ptlrpc_service *service);
-int liblustre_check_services (void *arg);
-void ptlrpc_daemonize(void);
-int ptlrpc_service_health_check(struct ptlrpc_service *);
-
-
-struct ptlrpc_svc_data {
- char *name;
- struct ptlrpc_service *svc;
- struct ptlrpc_thread *thread;
- struct obd_device *dev;
-};
-
-/* ptlrpc/import.c */
-int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
-int ptlrpc_init_import(struct obd_import *imp);
-int ptlrpc_disconnect_import(struct obd_import *imp);
-int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
-
-/* ptlrpc/pack_generic.c */
-int lustre_msg_swabbed(struct lustre_msg *msg);
-int lustre_pack_request(struct ptlrpc_request *, int count, int *lens,
- char **bufs);
-int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
- char **bufs);
-void lustre_shrink_reply(struct ptlrpc_request *req,
- int segment, unsigned int newlen, int move_data);
-void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
-int lustre_msg_size(int count, int *lengths);
-int lustre_unpack_msg(struct lustre_msg *m, int len);
-void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
-int lustre_msg_buflen(struct lustre_msg *m, int n);
-char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
-void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
-void *lustre_swab_reqbuf (struct ptlrpc_request *req, int n, int minlen,
- void *swabber);
-void *lustre_swab_repbuf (struct ptlrpc_request *req, int n, int minlen,
- void *swabber);
-
-static inline void
-ptlrpc_rs_addref(struct ptlrpc_reply_state *rs)
-{
- LASSERT(atomic_read(&rs->rs_refcount) > 0);
- atomic_inc(&rs->rs_refcount);
-}
-
-static inline void
-ptlrpc_rs_decref(struct ptlrpc_reply_state *rs)
-{
- LASSERT(atomic_read(&rs->rs_refcount) > 0);
- if (atomic_dec_and_test(&rs->rs_refcount))
- lustre_free_reply_state(rs);
-}
-
-/* ldlm/ldlm_lib.c */
-int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
-int client_obd_cleanup(struct obd_device * obddev);
-int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid, struct obd_connect_data *);
-int client_disconnect_export(struct obd_export *exp);
-int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
- int priority);
-int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid);
-int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
-
-/* ptlrpc/pinger.c */
-int ptlrpc_pinger_add_import(struct obd_import *imp);
-int ptlrpc_pinger_del_import(struct obd_import *imp);
-
-/* ptlrpc/ptlrpcd.c */
-void ptlrpcd_wake(struct ptlrpc_request *req);
-void ptlrpcd_add_req(struct ptlrpc_request *req);
-int ptlrpcd_addref(void);
-void ptlrpcd_decref(void);
-
-/* ptlrpc/lproc_ptlrpc.c */
-#ifdef LPROCFS
-void ptlrpc_lprocfs_register_obd(struct obd_device *obd);
-void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd);
-#else
-static inline void ptlrpc_lprocfs_register_obd(struct obd_device *obd) {}
-static inline void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) {}
#endif
-/* ptlrpc/llog_server.c */
-int llog_origin_handle_create(struct ptlrpc_request *req);
-int llog_origin_handle_next_block(struct ptlrpc_request *req);
-int llog_origin_handle_read_header(struct ptlrpc_request *req);
-int llog_origin_handle_close(struct ptlrpc_request *req);
-int llog_origin_handle_cancel(struct ptlrpc_request *req);
-int llog_catinfo(struct ptlrpc_request *req);
-
-/* ptlrpc/llog_client.c */
-extern struct llog_operations llog_client_ops;
-
#endif
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*/
+#ifndef _LINUX_LUSTRE_QUOTA_H
+#define _LINUX_LUSTRE_QUOTA_H
+
#ifndef _LUSTRE_QUOTA_H
-#define _LUSTRE_QUOTA_H
+#error Do not #include this file directly. #include <lustre_quota.h> instead
+#endif
#ifdef __KERNEL__
#include <linux/version.h>
#include <linux/quota.h>
#include <linux/quotaops.h>
#endif
-#include <linux/lustre_idl.h>
-#include <linux/lustre_net.h>
-#include <linux/lvfs.h>
-
-struct obd_device;
-struct client_obd;
-
-#ifndef NR_DQHASH
-#define NR_DQHASH 45
-#endif
-
-#ifdef HAVE_QUOTA_SUPPORT
-
-#ifdef __KERNEL__
-
-/* structures to access admin quotafile */
-struct lustre_mem_dqinfo {
- unsigned int dqi_bgrace;
- unsigned int dqi_igrace;
- unsigned long dqi_flags;
- unsigned int dqi_blocks;
- unsigned int dqi_free_blk;
- unsigned int dqi_free_entry;
-};
-
-struct lustre_quota_info {
- struct file *qi_files[MAXQUOTAS];
- struct lustre_mem_dqinfo qi_info[MAXQUOTAS];
-};
-
-#define DQ_STATUS_AVAIL 0x0 /* Available dquot */
-#define DQ_STATUS_SET 0x01 /* Sombody is setting dquot */
-#define DQ_STATUS_RECOVERY 0x02 /* dquot is in recovery */
-
-struct lustre_dquot {
- /* Hash list in memory, protect by dquot_hash_lock */
- struct list_head dq_hash;
- /* Protect the data in lustre_dquot */
- struct semaphore dq_sem;
- /* Use count */
- int dq_refcnt;
- /* Pointer of quota info it belongs to */
- struct lustre_quota_info *dq_info;
-
- loff_t dq_off; /* Offset of dquot on disk */
- unsigned int dq_id; /* ID this applies to (uid, gid) */
- int dq_type; /* Type fo quota (USRQUOTA, GRPQUOUTA) */
- unsigned short dq_status; /* See DQ_STATUS_ */
- unsigned long dq_flags; /* See DQ_ in quota.h */
- struct mem_dqblk dq_dqb; /* Diskquota usage */
-};
-
-struct dquot_id {
- struct list_head di_link;
- __u32 di_id;
-};
-
-#define QFILE_CHK 1
-#define QFILE_RD_INFO 2
-#define QFILE_WR_INFO 3
-#define QFILE_INIT_INFO 4
-#define QFILE_GET_QIDS 5
-#define QFILE_RD_DQUOT 6
-#define QFILE_WR_DQUOT 7
-
-/* admin quotafile operations */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
-int lustre_check_quota_file(struct lustre_quota_info *lqi, int type);
-int lustre_read_quota_info(struct lustre_quota_info *lqi, int type);
-int lustre_write_quota_info(struct lustre_quota_info *lqi, int type);
-int lustre_read_dquot(struct lustre_dquot *dquot);
-int lustre_commit_dquot(struct lustre_dquot *dquot);
-int lustre_init_quota_info(struct lustre_quota_info *lqi, int type);
-int lustre_get_qids(struct lustre_quota_info *lqi, int type,
- struct list_head *list);
-#else
-
-#ifndef DQ_FAKE_B
-#define DQ_FAKE_B 6
-#endif
-
-static inline int lustre_check_quota_file(struct lustre_quota_info *lqi,
- int type)
-{
- return 0;
-}
-static inline int lustre_read_quota_info(struct lustre_quota_info *lqi,
- int type)
-{
- return 0;
-}
-static inline int lustre_write_quota_info(struct lustre_quota_info *lqi,
- int type)
-{
- return 0;
-}
-static inline int lustre_read_dquot(struct lustre_dquot *dquot)
-{
- return 0;
-}
-static inline int lustre_commit_dquot(struct lustre_dquot *dquot)
-{
- return 0;
-}
-static inline int lustre_init_quota_info(struct lustre_quota_info *lqi,
- int type)
-{
- return 0;
-}
-#endif /* KERNEL_VERSION(2,5,0) */
-
-#define LL_DQUOT_OFF(sb) DQUOT_OFF(sb)
-
-typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd,
- int opc);
-struct lustre_quota_ctxt {
- struct super_block *lqc_sb; /* superblock this applies to */
- struct obd_import *lqc_import; /* import used to send dqacq/dqrel RPC */
- dqacq_handler_t lqc_handler; /* dqacq/dqrel RPC handler, only for quota master */
- unsigned long lqc_recovery:1; /* Doing recovery */
- unsigned long lqc_iunit_sz; /* Unit size of file quota */
- unsigned long lqc_itune_sz; /* Trigger dqacq when available file quota less than
- * this value, trigger dqrel when available file quota
- * more than this value + 1 iunit */
- unsigned long lqc_bunit_sz; /* Unit size of block quota */
- unsigned long lqc_btune_sz; /* See comment of lqc_itune_sz */
-};
-
-#else
-
-struct lustre_quota_info {
-};
-
-struct lustre_quota_ctxt {
-};
-
-#endif /* !__KERNEL__ */
-
-#else
-
-#define LL_DQUOT_OFF(sb) do {} while(0)
-
-struct lustre_quota_info {
-};
-
-struct lustre_quota_ctxt {
-};
-
-#endif /* !HAVE_QUOTA_SUPPORT */
-
-/* If the (quota limit < qunit * slave count), the slave which can't
- * acquire qunit should set it's local limit as MIN_QLIMIT */
-#define MIN_QLIMIT 1
-
-struct quotacheck_thread_args {
- struct obd_export *qta_exp; /* obd export */
- struct obd_quotactl qta_oqctl; /* obd_quotactl args */
- struct super_block *qta_sb; /* obd super block */
- atomic_t *qta_sem; /* obt_quotachecking */
-};
-
-typedef struct {
- int (*quota_init) (void);
- int (*quota_exit) (void);
- int (*quota_setup) (struct obd_device *, struct lustre_cfg *);
- int (*quota_cleanup) (struct obd_device *);
- /* For quota master, close admin quota files */
- int (*quota_fs_cleanup) (struct obd_device *);
- int (*quota_ctl) (struct obd_export *, struct obd_quotactl *);
- int (*quota_check) (struct obd_export *, struct obd_quotactl *);
- int (*quota_recovery) (struct obd_device *);
-
- /* For quota master/slave, adjust quota limit after fs operation */
- int (*quota_adjust) (struct obd_device *, unsigned int[],
- unsigned int[], int, int);
-
- /* For quota slave, set import, trigger quota recovery */
- int (*quota_setinfo) (struct obd_export *, struct obd_device *);
-
- /* For quota slave, set proper thread resoure capability */
- int (*quota_enforce) (struct obd_device *, unsigned int);
-
- /* For quota slave, check whether specified uid/gid is over quota */
- int (*quota_getflag) (struct obd_device *, struct obdo *);
-
- /* For quota slave, acquire/release quota from master if needed */
- int (*quota_acquire) (struct obd_device *, unsigned int, unsigned int);
-
- /* For quota client, poll if the quota check done */
- int (*quota_poll_check) (struct obd_export *, struct if_quotacheck *);
-
- /* For quota client, check whether specified uid/gid is over quota */
- int (*quota_chkdq) (struct client_obd *, unsigned int, unsigned int);
-
- /* For quota client, set over quota flag for specifed uid/gid */
- int (*quota_setdq) (struct client_obd *, unsigned int, unsigned int,
- obd_flag, obd_flag);
-} quota_interface_t;
-
-#define Q_COPY(out, in, member) (out)->member = (in)->member
-
-#define QUOTA_OP(interface, op) interface->quota_ ## op
-
-#define QUOTA_CHECK_OP(interface, op) \
-do { \
- if (!interface) \
- RETURN(0); \
- if (!QUOTA_OP(interface, op)) { \
- CERROR("no quota operation: " #op "\n"); \
- RETURN(-EOPNOTSUPP); \
- } \
-} while(0)
-
-static inline int lquota_init(quota_interface_t *interface)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, init);
- rc = QUOTA_OP(interface, init)();
- RETURN(rc);
-}
-
-static inline int lquota_exit(quota_interface_t *interface)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, exit);
- rc = QUOTA_OP(interface, exit)();
- RETURN(rc);
-}
-
-static inline int lquota_setup(quota_interface_t *interface,
- struct obd_device *obd,
- struct lustre_cfg *lcfg)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, setup);
- rc = QUOTA_OP(interface, setup)(obd, lcfg);
- RETURN(rc);
-}
-
-static inline int lquota_cleanup(quota_interface_t *interface,
- struct obd_device *obd)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, cleanup);
- rc = QUOTA_OP(interface, cleanup)(obd);
- RETURN(rc);
-}
-
-static inline int lquota_fs_cleanup(quota_interface_t *interface,
- struct obd_device *obd)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, fs_cleanup);
- rc = QUOTA_OP(interface, fs_cleanup)(obd);
- RETURN(rc);
-}
-
-static inline int lquota_recovery(quota_interface_t *interface,
- struct obd_device *obd)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, recovery);
- rc = QUOTA_OP(interface, recovery)(obd);
- RETURN(rc);
-}
-
-static inline int lquota_adjust(quota_interface_t *interface,
- struct obd_device *obd,
- unsigned int qcids[],
- unsigned int qpids[],
- int rc, int opc)
-{
- int ret;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, adjust);
- ret = QUOTA_OP(interface, adjust)(obd, qcids, qpids, rc, opc);
- RETURN(ret);
-}
-
-static inline int lquota_chkdq(quota_interface_t *interface,
- struct client_obd *cli,
- unsigned int uid, unsigned int gid)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, chkdq);
- rc = QUOTA_OP(interface, chkdq)(cli, uid, gid);
- RETURN(rc);
-}
-
-static inline int lquota_setdq(quota_interface_t *interface,
- struct client_obd *cli,
- unsigned int uid, unsigned int gid,
- obd_flag valid, obd_flag flags)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, setdq);
- rc = QUOTA_OP(interface, setdq)(cli, uid, gid, valid, flags);
- RETURN(rc);
-}
-
-static inline int lquota_poll_check(quota_interface_t *interface,
- struct obd_export *exp,
- struct if_quotacheck *qchk)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, poll_check);
- rc = QUOTA_OP(interface, poll_check)(exp, qchk);
- RETURN(rc);
-}
-
-
-static inline int lquota_setinfo(quota_interface_t *interface,
- struct obd_export *exp,
- struct obd_device *obd)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, setinfo);
- rc = QUOTA_OP(interface, setinfo)(exp, obd);
- RETURN(rc);
-}
-
-static inline int lquota_enforce(quota_interface_t *interface,
- struct obd_device *obd,
- unsigned int ignore)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, enforce);
- rc = QUOTA_OP(interface, enforce)(obd, ignore);
- RETURN(rc);
-}
-
-static inline int lquota_getflag(quota_interface_t *interface,
- struct obd_device *obd, struct obdo *oa)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, getflag);
- rc = QUOTA_OP(interface, getflag)(obd, oa);
- RETURN(rc);
-}
-
-static inline int lquota_acquire(quota_interface_t *interface,
- struct obd_device *obd,
- unsigned int uid, unsigned int gid)
-{
- int rc;
- ENTRY;
-
- QUOTA_CHECK_OP(interface, acquire);
- rc = QUOTA_OP(interface, acquire)(obd, uid, gid);
- RETURN(rc);
-}
-
-#ifndef __KERNEL__
-extern quota_interface_t osc_quota_interface;
-extern quota_interface_t mdc_quota_interface;
-extern quota_interface_t lov_quota_interface;
-#endif
#endif /* _LUSTRE_QUOTA_H */
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * This file is part of Lustre, http://www.lustre.org
+ *
+ * Lustre public user-space interface definitions.
+ */
+
+#ifndef _LINUX_LUSTRE_USER_H
+#define _LINUX_LUSTRE_USER_H
+
+#ifdef HAVE_ASM_TYPES_H
+#include <asm/types.h>
+#else
+#include <lustre/types.h>
+#endif
+
+#ifdef HAVE_QUOTA_SUPPORT
+#include <linux/quota.h>
+#endif
+
+#ifndef __KERNEL__
+#define NEED_QUOTA_DEFS
+#else
+# include <linux/version.h>
+# if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,21)
+# define NEED_QUOTA_DEFS
+# endif
+#endif
+
+/*
+ * asm-x86_64/processor.h on some SLES 9 distros seems to use
+ * kernel-only typedefs. fortunately skipping it altogether is ok
+ * (for now).
+ */
+#define __ASM_X86_64_PROCESSOR_H
+
+#ifdef __KERNEL__
+#include <linux/string.h>
+#else
+#include <string.h>
+#include <sys/stat.h>
+#endif
+
+#if defined(__x86_64__) || defined(__ia64__) || defined(__ppc64__)
+typedef struct stat lstat_t;
+#define HAVE_LOV_USER_MDS_DATA
+#elif defined(__USE_LARGEFILE64) || defined(__KERNEL__)
+typedef struct stat64 lstat_t;
+#define HAVE_LOV_USER_MDS_DATA
+#endif
+
+#ifndef LPU64
+/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
+#if defined(__x86_64__) && defined(__KERNEL__)
+# define LPU64 "%Lu"
+# define LPD64 "%Ld"
+# define LPX64 "%#Lx"
+# define LPSZ "%lu"
+# define LPSSZ "%ld"
+#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
+# define LPU64 "%Lu"
+# define LPD64 "%Ld"
+# define LPX64 "%#Lx"
+# define LPSZ "%u"
+# define LPSSZ "%d"
+#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
+# define LPU64 "%lu"
+# define LPD64 "%ld"
+# define LPX64 "%#lx"
+# define LPSZ "%lu"
+# define LPSSZ "%ld"
+#endif
+#endif /* !LPU64 */
+
+#endif /* _LUSTRE_USER_H */
* lustre VFS/process permission interface
*/
-#ifndef __LVFS_H__
-#define __LVFS_H__
-
-#include <libcfs/kp30.h>
-#include <linux/lustre_ucache.h>
+#ifndef __LINUX_LVFS_H__
+#define __LINUX_LVFS_H__
-#define LL_FID_NAMELEN (16 + 1 + 8 + 1)
+#ifndef __LVFS_H__
+#error Do not #include this file directly. #include <lvfs.h> instead
+#endif
#if defined __KERNEL__
#include <linux/lustre_compat25.h>
struct group_info { /* unused */ };
#endif
-#ifdef LIBLUSTRE
-#include <lvfs_user_fs.h>
-#endif
+#define LLOG_LVFS
/* simple.c */
#define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
#endif
-/* lvfs_common.c */
-struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *, __u64, __u32, __u64 ,void *data);
-
-void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
- struct lvfs_ucred *cred);
-void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
- struct lvfs_ucred *cred);
-
#ifdef __KERNEL__
struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode, int fix);
}
#endif
-static inline int ll_fid2str(char *str, __u64 id, __u32 generation)
-{
- return sprintf(str, "%llx:%08x", (unsigned long long)id, generation);
-}
-
#endif
#include <linux/fs.h>
#include <linux/sched.h>
-#include <linux/lvfs.h>
+#include <lvfs.h>
#define l_file file
#define l_dentry dentry
* vim:expandtab:shiftwidth=8:tabstop=8:
*/
-#ifndef __OBD_H
-#define __OBD_H
-
-#define IOC_OSC_TYPE 'h'
-#define IOC_OSC_MIN_NR 20
-#define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
-#define IOC_OSC_MAX_NR 50
+#ifndef __LINUX_OBD_H
+#define __LINUX_OBD_H
-#define IOC_MDC_TYPE 'i'
-#define IOC_MDC_MIN_NR 20
-#define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
-/* Moved to lustre_user.h
-#define IOC_MDC_GETSTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *) */
-#define IOC_MDC_MAX_NR 50
+#ifndef __OBD_H
+#error Do not #include this file directly. #include <obd.h> instead
+#endif
#ifdef __KERNEL__
# include <linux/fs.h>
# include <linux/mount.h>
#endif
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_export.h>
-#include <linux/lustre_quota.h>
-
-/* this is really local to the OSC */
-struct loi_oap_pages {
- struct list_head lop_pending;
- int lop_num_pending;
- struct list_head lop_urgent;
- struct list_head lop_pending_group;
-};
-
-struct osc_async_rc {
- int ar_rc;
- int ar_force_sync;
- int ar_min_xid;
-};
-
-struct lov_oinfo { /* per-stripe data structure */
- __u64 loi_id; /* object ID on the target OST */
- __u64 loi_gr; /* object group on the target OST */
- int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
- int loi_ost_gen; /* generation of this loi_ost_idx */
+typedef spinlock_t client_obd_lock_t;
- /* used by the osc to keep track of what objects to build into rpcs */
- struct loi_oap_pages loi_read_lop;
- struct loi_oap_pages loi_write_lop;
- /* _cli_ is poorly named, it should be _ready_ */
- struct list_head loi_cli_item;
- struct list_head loi_write_item;
- struct list_head loi_read_item;
-
- unsigned loi_kms_valid:1;
- __u64 loi_kms; /* known minimum size */
- __u64 loi_rss; /* recently seen size */
- __u64 loi_mtime; /* recently seen mtime */
- __u64 loi_blocks; /* recently seen blocks */
-
- struct osc_async_rc loi_ar;
-};
-
-static inline void loi_init(struct lov_oinfo *loi)
+static inline void client_obd_list_lock_init(client_obd_lock_t *lock)
{
- INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
- INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
- INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
- INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
- INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
- INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
- INIT_LIST_HEAD(&loi->loi_cli_item);
- INIT_LIST_HEAD(&loi->loi_write_item);
- INIT_LIST_HEAD(&loi->loi_read_item);
+ spin_lock_init(lock);
}
-struct lov_stripe_md {
- spinlock_t lsm_lock;
- void *lsm_lock_owner; /* debugging */
+static inline void client_obd_list_lock_done(client_obd_lock_t *lock)
+{}
- /* Public members. */
- __u64 lsm_object_id; /* lov object id */
- __u64 lsm_object_gr; /* lov object id */
- __u64 lsm_maxbytes; /* maximum possible file size */
- unsigned long lsm_xfersize; /* optimal transfer size */
-
- /* LOV-private members start here -- only for use in lov/. */
- __u32 lsm_magic;
- __u32 lsm_stripe_size; /* size of the stripe */
- __u32 lsm_pattern; /* striping pattern (RAID0, RAID1) */
- unsigned lsm_stripe_count; /* number of objects being striped over */
- struct lov_oinfo lsm_oinfo[0];
-};
-
-/* compare all fields except for semaphore */
-static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
- struct lov_stripe_md *m2)
+static inline void client_obd_list_lock(client_obd_lock_t *lock)
{
- return memcmp(&m1->lsm_object_id, &m2->lsm_object_id,
- (char *)&m2->lsm_oinfo[0] - (char *)&m2->lsm_object_id);
+ spin_lock(lock);
}
-void lov_stripe_lock(struct lov_stripe_md *md);
-void lov_stripe_unlock(struct lov_stripe_md *md);
-
-struct obd_type {
- struct list_head typ_chain;
- struct obd_ops *typ_ops;
- struct proc_dir_entry *typ_procroot;
- char *typ_name;
- int typ_refcnt;
-};
-
-struct brw_page {
- obd_off off;
- struct page *pg;
- int count;
- obd_flag flag;
-};
-
-enum async_flags {
- ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
- page is added to an rpc */
- ASYNC_URGENT = 0x2,
- ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
- to give the caller a chance to update
- or cancel the size of the io */
- ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
- the page is accounted for in the
- obd_io_group given to
- obd_queue_group_io */
-};
-
-struct obd_async_page_ops {
- int (*ap_make_ready)(void *data, int cmd);
- int (*ap_refresh_count)(void *data, int cmd);
- void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
- void (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
-};
-
-/* the `oig' is passed down from a caller of obd rw methods. the callee
- * records enough state such that the caller can sleep on the oig and
- * be woken when all the callees have finished their work */
-struct obd_io_group {
- spinlock_t oig_lock;
- atomic_t oig_refcount;
- int oig_pending;
- int oig_rc;
- struct list_head oig_occ_list;
- wait_queue_head_t oig_waitq;
-};
-
-/* the oig callback context lets the callee of obd rw methods register
- * for callbacks from the caller. */
-struct oig_callback_context {
- struct list_head occ_oig_item;
- /* called when the caller has received a signal while sleeping.
- * callees of this method are encouraged to abort their state
- * in the oig. This may be called multiple times. */
- void (*occ_interrupted)(struct oig_callback_context *occ);
- unsigned int interrupted:1;
-};
-
-/* if we find more consumers this could be generalized */
-#define OBD_HIST_MAX 32
-struct obd_histogram {
- spinlock_t oh_lock;
- unsigned long oh_buckets[OBD_HIST_MAX];
-};
-
-/* Individual type definitions */
-
-struct ost_server_data;
-
-/* hold common fields for "target" device */
-struct obd_device_target {
- struct super_block *obt_sb;
- atomic_t obt_quotachecking;
- struct lustre_quota_ctxt obt_qctxt;
-};
-
-#define FILTER_GROUP_LLOG 1
-#define FILTER_GROUP_ECHO 2
-
-struct filter_ext {
- __u64 fe_start;
- __u64 fe_end;
-};
-
-struct filter_obd {
- /* NB this field MUST be first */
- struct obd_device_target fo_obt;
- const char *fo_fstype;
- struct vfsmount *fo_vfsmnt;
- struct dentry *fo_dentry_O;
- struct dentry **fo_dentry_O_groups;
- struct dentry **fo_dentry_O_sub;
- spinlock_t fo_objidlock; /* protect fo_lastobjid
- * increment */
-
- spinlock_t fo_translock; /* protect fsd_last_rcvd
- * increment */
-
- struct file *fo_rcvd_filp;
- struct filter_server_data *fo_fsd;
- unsigned long *fo_last_rcvd_slots;
- __u64 fo_mount_count;
-
- int fo_destroy_in_progress;
-
- struct file_operations *fo_fop;
- struct inode_operations *fo_iop;
- struct address_space_operations *fo_aops;
-
- struct list_head fo_export_list;
- int fo_subdir_count;
-
- obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
- obd_size fo_tot_granted; /* all values in bytes */
- obd_size fo_tot_pending;
-
- obd_size fo_readcache_max_filesize;
-
- struct obd_import *fo_mdc_imp;
- struct obd_uuid fo_mdc_uuid;
- struct lustre_handle fo_mdc_conn;
-#if 0
- struct ptlrpc_client fo_mdc_client;
-#endif
- struct file **fo_last_objid_files;
- __u64 *fo_last_objids; /* last created objid for groups */
-
- struct semaphore fo_alloc_lock;
-
- spinlock_t fo_stats_lock;
- int fo_r_in_flight; /* protected by fo_stats_lock */
- int fo_w_in_flight; /* protected by fo_stats_lock */
-
- /*
- * per-filter pool of kiobuf's allocated by filter_common_setup() and
- * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
- * which ->fo_iobuf_count were allocated.
- *
- * This pool contains kiobuf used by
- * filter_{prep,commit}rw_{read,write}() and is shared by all OST
- * threads.
- *
- * Locking: none, each OST thread uses only one element, determined by
- * its "ordinal number", ->t_id.
- *
- * This is (void *) array, because 2.4 and 2.6 use different iobuf
- * structures.
- */
- void **fo_iobuf_pool;
- int fo_iobuf_count;
-
- struct obd_histogram fo_r_pages;
- struct obd_histogram fo_w_pages;
- struct obd_histogram fo_read_rpc_hist;
- struct obd_histogram fo_write_rpc_hist;
- struct obd_histogram fo_r_io_time;
- struct obd_histogram fo_w_io_time;
- struct obd_histogram fo_r_discont_pages;
- struct obd_histogram fo_w_discont_pages;
- struct obd_histogram fo_r_discont_blocks;
- struct obd_histogram fo_w_discont_blocks;
- struct obd_histogram fo_r_disk_iosize;
- struct obd_histogram fo_w_disk_iosize;
-
- struct lustre_quota_ctxt fo_quota_ctxt;
- spinlock_t fo_quotacheck_lock;
- atomic_t fo_quotachecking;
-
- /* objids black list stuff. See for detailed comment in
- * filter_clear_orphans() */
- struct filter_ext *fo_blacklist;
- spinlock_t fo_blacklist_lock;
-};
-
-struct mds_server_data;
-
-#define OSC_MAX_RIF_DEFAULT 8
-#define OSC_MAX_RIF_MAX 64
-#define OSC_MAX_DIRTY_DEFAULT 32
-#define OSC_MAX_DIRTY_MB_MAX 512 /* totally arbitrary */
-
-struct mdc_rpc_lock;
-struct client_obd {
- struct obd_import *cl_import;
- struct semaphore cl_sem;
- int cl_conn_count;
- /* max_mds_easize is purely a performance thing so we don't have to
- * call obd_size_diskmd() all the time. */
- int cl_default_mds_easize;
- int cl_max_mds_easize;
- int cl_max_mds_cookiesize;
- kdev_t cl_sandev;
-
- //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
- void *cl_llcd_offset;
-
- /* the grant values are protected by loi_list_lock below */
- long cl_dirty; /* all _dirty_ in bytes */
- long cl_dirty_max; /* allowed w/o rpc */
- long cl_avail_grant; /* bytes of credit for ost */
- long cl_lost_grant; /* lost credits (trunc) */
- struct list_head cl_cache_waiters; /* waiting for cache/grant */
-
- /* keep track of objects that have lois that contain pages which
- * have been queued for async brw. this lock also protects the
- * lists of osc_client_pages that hang off of the loi */
- spinlock_t cl_loi_list_lock;
- struct list_head cl_loi_ready_list;
- struct list_head cl_loi_write_list;
- struct list_head cl_loi_read_list;
- int cl_r_in_flight;
- int cl_w_in_flight;
- /* just a sum of the loi/lop pending numbers to be exported by /proc */
- int cl_pending_w_pages;
- int cl_pending_r_pages;
- int cl_max_pages_per_rpc;
- int cl_max_rpcs_in_flight;
- struct obd_histogram cl_read_rpc_hist;
- struct obd_histogram cl_write_rpc_hist;
- struct obd_histogram cl_read_page_hist;
- struct obd_histogram cl_write_page_hist;
- struct obd_histogram cl_read_offset_hist;
- struct obd_histogram cl_write_offset_hist;
-
- struct mdc_rpc_lock *cl_rpc_lock;
- struct mdc_rpc_lock *cl_setattr_lock;
- struct osc_creator cl_oscc;
-
- /* Flags section */
- unsigned int cl_checksum:1; /* debug checksums */
-
- /* also protected by the poorly named _loi_list_lock lock above */
- struct osc_async_rc cl_ar;
-
- /* used by quotacheck */
- int cl_qchk_stat; /* quotacheck stat of the peer */
- struct ptlrpc_request_pool *cl_rq_pool; /* emergency pool of requests */
-};
-
-#define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */
-
-struct mds_obd {
- /* NB this field MUST be first */
- struct obd_device_target mds_obt;
- struct ptlrpc_service *mds_service;
- struct ptlrpc_service *mds_setattr_service;
- struct ptlrpc_service *mds_readpage_service;
- struct vfsmount *mds_vfsmnt;
- struct dentry *mds_fid_de;
- int mds_max_mdsize;
- int mds_max_cookiesize;
- struct file *mds_rcvd_filp;
- spinlock_t mds_transno_lock;
- __u64 mds_last_transno;
- __u64 mds_mount_count;
- __u64 mds_io_epoch;
- struct semaphore mds_epoch_sem;
- struct ll_fid mds_rootfid;
- struct mds_server_data *mds_server_data;
- struct dentry *mds_pending_dir;
- struct dentry *mds_logs_dir;
- struct dentry *mds_objects_dir;
- struct llog_handle *mds_cfg_llh;
-// struct llog_handle *mds_catalog;
- struct obd_device *mds_osc_obd; /* XXX lov_obd */
- struct obd_uuid mds_lov_uuid;
- char *mds_profile;
- struct obd_export *mds_osc_exp; /* XXX lov_exp */
- int mds_has_lov_desc;
- struct lov_desc mds_lov_desc;
- obd_id *mds_lov_objids;
- int mds_lov_nextid_set;
- struct file *mds_lov_objid_filp;
- unsigned long *mds_client_bitmap;
- struct semaphore mds_orphan_recovery_sem;
- struct upcall_cache *mds_group_hash;
-
- struct lustre_quota_info mds_quota_info;
- struct semaphore mds_qonoff_sem;
- struct semaphore mds_health_sem;
- unsigned long mds_lov_objids_valid:1,
- mds_fl_user_xattr:1,
- mds_fl_acl:1;
-};
-
-struct echo_obd {
- struct obdo eo_oa;
- spinlock_t eo_lock;
- __u64 eo_lastino;
- struct lustre_handle eo_nl_lock;
- atomic_t eo_prep;
-};
-
-/*
- * this struct does double-duty acting as either a client or
- * server instance .. maybe not wise.
- */
-struct ptlbd_obd {
- /* server's */
- struct ptlrpc_service *ptlbd_service;
- struct file *filp;
- /* client's */
- struct ptlrpc_client bd_client;
- struct obd_import *bd_import;
- struct obd_uuid bd_server_uuid;
- struct obd_export *bd_exp;
- int refcount; /* XXX sigh */
-};
-
-struct recovd_obd {
- spinlock_t recovd_lock;
- struct list_head recovd_managed_items; /* items managed */
- struct list_head recovd_troubled_items; /* items in recovery */
-
- wait_queue_head_t recovd_recovery_waitq;
- wait_queue_head_t recovd_ctl_waitq;
- wait_queue_head_t recovd_waitq;
- struct task_struct *recovd_thread;
- __u32 recovd_state;
-};
-
-struct ost_obd {
- struct ptlrpc_service *ost_service;
- struct ptlrpc_service *ost_create_service;
- struct semaphore ost_health_sem;
-};
-
-struct echo_client_obd {
- struct obd_export *ec_exp; /* the local connection to osc/lov */
- spinlock_t ec_lock;
- struct list_head ec_objects;
- int ec_nstripes;
- __u64 ec_unique;
-};
-
-struct cache_obd {
- struct obd_export *cobd_target_exp;/* local connection to target obd */
- struct obd_export *cobd_cache_exp; /* local connection to cache obd */
-};
-
-struct lov_tgt_desc {
- struct obd_uuid uuid;
- __u32 ltd_gen;
- struct obd_export *ltd_exp;
- int active; /* is this target up for requests */
- int index; /* index of target array in lov_obd */
- struct list_head qos_bavail_list; /* link entry to lov_obd */
-};
-
-struct lov_obd {
- spinlock_t lov_lock;
- struct lov_desc desc;
- int bufsize;
- int refcount;
- unsigned int lo_catalog_loaded:1;
- struct list_head qos_bavail_list; /* tgts list, sorted by available space, protected by lov_lock */
- struct lov_tgt_desc *tgts;
-};
-
-struct niobuf_local {
- __u64 offset;
- __u32 len;
- __u32 flags;
- struct page *page;
- struct dentry *dentry;
- int lnb_grant_used;
- int rc;
-};
-
-
-/* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
-#define N_LOCAL_TEMP_PAGE 0x10000000
-
-struct obd_trans_info {
- __u64 oti_transno;
- __u64 *oti_objid;
- /* Only used on the server side for tracking acks. */
- struct oti_req_ack_lock {
- struct lustre_handle lock;
- __u32 mode;
- } oti_ack_locks[4];
- void *oti_handle;
- struct llog_cookie oti_onecookie;
- struct llog_cookie *oti_logcookies;
- int oti_numcookies;
-
- /* initial thread handling transaction */
- struct ptlrpc_thread *oti_thread;
-};
-
-static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
-{
- if (!oti)
- return;
-
- if (num_cookies == 1)
- oti->oti_logcookies = &oti->oti_onecookie;
- else
- OBD_ALLOC(oti->oti_logcookies,
- num_cookies * sizeof(oti->oti_onecookie));
-
- oti->oti_numcookies = num_cookies;
-}
-
-static inline void oti_free_cookies(struct obd_trans_info *oti)
+static inline void client_obd_list_unlock(client_obd_lock_t *lock)
{
- if (!oti || !oti->oti_logcookies)
- return;
-
- if (oti->oti_logcookies == &oti->oti_onecookie)
- LASSERT(oti->oti_numcookies == 1);
- else
- OBD_FREE(oti->oti_logcookies,
- oti->oti_numcookies * sizeof(oti->oti_onecookie));
- oti->oti_logcookies = NULL;
- oti->oti_numcookies = 0;
-}
-
-/* llog contexts */
-enum llog_ctxt_id {
- LLOG_CONFIG_ORIG_CTXT = 0,
- LLOG_CONFIG_REPL_CTXT = 1,
- LLOG_MDS_OST_ORIG_CTXT = 2,
- LLOG_MDS_OST_REPL_CTXT = 3,
- LLOG_SIZE_ORIG_CTXT = 4,
- LLOG_SIZE_REPL_CTXT = 5,
- LLOG_MD_ORIG_CTXT = 6,
- LLOG_MD_REPL_CTXT = 7,
- LLOG_RD1_ORIG_CTXT = 8,
- LLOG_RD1_REPL_CTXT = 9,
- LLOG_TEST_ORIG_CTXT = 10,
- LLOG_TEST_REPL_CTXT = 11,
- LLOG_MAX_CTXTS
-};
-
-
-/* corresponds to one of the obd's */
-struct obd_device {
- struct obd_type *obd_type;
-
- /* common and UUID name of this device */
- char *obd_name;
- struct obd_uuid obd_uuid;
-
- int obd_minor;
- unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
- obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
- obd_no_recov:1, obd_stopping:1, obd_starting:1,
- obd_force:1, obd_fail:1, obd_async_recov:1;
- atomic_t obd_refcount;
- wait_queue_head_t obd_refcount_waitq;
- struct proc_dir_entry *obd_proc_entry;
- struct list_head obd_exports;
- int obd_num_exports;
- struct ldlm_namespace *obd_namespace;
- struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
- /* a spinlock is OK for what we do now, may need a semaphore later */
- spinlock_t obd_dev_lock;
- __u64 obd_last_committed;
- struct fsfilt_operations *obd_fsops;
- spinlock_t obd_osfs_lock;
- struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
- unsigned long obd_osfs_age; /* jiffies */
- struct lvfs_run_ctxt obd_lvfs_ctxt;
- struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
- struct obd_device *obd_observer;
- struct obd_export *obd_self_export;
- /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
- struct list_head obd_exports_timed;
- time_t obd_eviction_timer; /* for ping evictor */
-
- /* XXX encapsulate all this recovery data into one struct */
- svc_handler_t obd_recovery_handler;
- int obd_max_recoverable_clients;
- int obd_connected_clients;
- int obd_recoverable_clients;
- spinlock_t obd_processing_task_lock;
- pid_t obd_processing_task;
- __u64 obd_next_recovery_transno;
- int obd_replayed_requests;
- int obd_requests_queued_for_recovery;
- wait_queue_head_t obd_next_transno_waitq;
- struct list_head obd_uncommitted_replies;
- spinlock_t obd_uncommitted_replies_lock;
- struct timer_list obd_recovery_timer;
- struct list_head obd_recovery_queue;
- struct list_head obd_delayed_reply_queue;
- time_t obd_recovery_start;
- time_t obd_recovery_end;
-
- union {
- struct obd_device_target obt;
- struct filter_obd filter;
- struct mds_obd mds;
- struct client_obd cli;
- struct ost_obd ost;
- struct echo_client_obd echo_client;
- struct echo_obd echo;
- struct recovd_obd recovd;
- struct lov_obd lov;
- struct cache_obd cobd;
- struct ptlbd_obd ptlbd;
- } u;
- /* Fields used by LProcFS */
- unsigned int obd_cntr_base;
- struct lprocfs_stats *obd_stats;
- struct proc_dir_entry *obd_svc_procroot;
- struct lprocfs_stats *obd_svc_stats;
-};
-
-#define OBD_OPT_FORCE 0x0001
-#define OBD_OPT_FAILOVER 0x0002
-
-#define OBD_LLOG_FL_SENDNOW 0x0001
-
-struct obd_ops {
- struct module *o_owner;
- int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
- void *karg, void *uarg);
- int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
- __u32 *vallen, void *val);
- int (*o_set_info)(struct obd_export *, __u32 keylen, void *key,
- __u32 vallen, void *val);
- int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
- int (*o_detach)(struct obd_device *dev);
- int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
- int (*o_precleanup)(struct obd_device *dev, int cleanup_stage);
- int (*o_cleanup)(struct obd_device *dev);
- int (*o_process_config)(struct obd_device *dev, obd_count len,
- void *data);
- int (*o_postrecov)(struct obd_device *dev);
- int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
- int priority);
- int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
- /* connect to the target device with given connection
- * data. @ocd->ocd_connect_flags is modified to reflect flags actually
- * granted by the target, which are guaranteed to be a subset of flags
- * asked for. If @ocd == NULL, use default parameters. */
- int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
- struct obd_uuid *cluuid, struct obd_connect_data *ocd);
- int (*o_disconnect)(struct obd_export *exp);
-
- int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
- unsigned long max_age);
- int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
- struct lov_stripe_md *mem_src);
- int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
- struct lov_mds_md *disk_src, int disk_len);
- int (*o_preallocate)(struct lustre_handle *, obd_count *req,
- obd_id *ids);
- int (*o_create)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md **ea, struct obd_trans_info *oti);
- int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, struct obd_trans_info *oti);
- int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, struct obd_trans_info *oti);
- int (*o_setattr_async)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, struct obd_trans_info *oti);
- int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea);
- int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea,
- struct ptlrpc_request_set *set);
- int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_count oa_bufs,
- struct brw_page *pgarr, struct obd_trans_info *oti);
- int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_count oa_bufs,
- struct brw_page *pgarr, struct ptlrpc_request_set *,
- struct obd_trans_info *oti);
- int (*o_prep_async_page)(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct page *page, obd_off offset,
- struct obd_async_page_ops *ops, void *data,
- void **res);
- int (*o_queue_async_io)(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi, void *cookie,
- int cmd, obd_off off, int count,
- obd_flag brw_flags, obd_flag async_flags);
- int (*o_queue_group_io)(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct obd_io_group *oig,
- void *cookie, int cmd, obd_off off, int count,
- obd_flag brw_flags, obd_flag async_flags);
- int (*o_trigger_group_io)(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct obd_io_group *oig);
- int (*o_set_async_flags)(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi, void *cookie,
- obd_flag async_flags);
- int (*o_teardown_async_page)(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi, void *cookie);
- int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
- obd_off size, int shrink);
- int (*o_punch)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_size start,
- obd_size end, struct obd_trans_info *oti);
- int (*o_sync)(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_size start, obd_size end);
- int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
- struct lov_stripe_md *src, obd_size start,
- obd_size end, struct obd_trans_info *oti);
- int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
- struct lustre_handle *srconn, struct lov_stripe_md *src,
- obd_size start, obd_size end, struct obd_trans_info *);
- int (*o_iterate)(struct lustre_handle *conn,
- int (*)(obd_id, obd_gr, void *),
- obd_id *startid, obd_gr group, void *data);
- int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
- int objcount, struct obd_ioobj *obj,
- int niocount, struct niobuf_remote *remote,
- struct niobuf_local *local, struct obd_trans_info *oti);
- int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
- int objcount, struct obd_ioobj *obj,
- int niocount, struct niobuf_local *local,
- struct obd_trans_info *oti, int rc);
- int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
- __u32 type, ldlm_policy_data_t *, __u32 mode,
- int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
- void *data, __u32 lvb_len, void *lvb_swabber,
- struct lustre_handle *lockh);
- int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
- ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
- struct lustre_handle *lockh);
- int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
- ldlm_iterator_t it, void *data);
- int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
- __u32 mode, struct lustre_handle *);
- int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
- int flags, void *opaque);
- int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
- int join);
- int (*o_san_preprw)(int cmd, struct obd_export *exp,
- struct obdo *oa, int objcount,
- struct obd_ioobj *obj, int niocount,
- struct niobuf_remote *remote);
- int (*o_init_export)(struct obd_export *exp);
- int (*o_destroy_export)(struct obd_export *exp);
-
- /* llog related obd_methods */
- int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
- int count, struct llog_catid *logid);
- int (*o_llog_finish)(struct obd_device *obd, int count);
-
- /* metadata-only methods */
- int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
- struct obd_client_handle *, int flag);
- int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
-
- int (*o_import_event)(struct obd_device *, struct obd_import *,
- enum obd_import_event);
-
- int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
- int active);
-
- int (*o_health_check)(struct obd_device *);
-
- /* quota methods */
- int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
- int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
-
- /*
- * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
- * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
- * Also, add a wrapper function in include/linux/obd_class.h.
- *
- * Also note that if you add it to the END, you also have to change
- * the num_stats calculation.
- *
- */
-};
-
-
-static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
- int error)
-{
- if (error) {
- CERROR("%s: transno "LPD64" commit error: %d\n",
- obd->obd_name, transno, error);
- return;
- }
- CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
- obd->obd_name, transno);
- if (transno > obd->obd_last_committed) {
- obd->obd_last_committed = transno;
- ptlrpc_commit_replies (obd);
- }
-}
-
-static inline void init_obd_quota_ops(quota_interface_t *interface,
- struct obd_ops *obd_ops)
-{
- if (!interface)
- return;
-
- LASSERT(obd_ops);
- obd_ops->o_quotacheck = QUOTA_OP(interface, check);
- obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
+ spin_unlock(lock);
}
-#endif /* __OBD_H */
+#endif /* __LINUX_OBD_H */
#ifndef __LINUX_CLASS_OBD_H
#define __LINUX_CLASS_OBD_H
+#ifndef __CLASS_OBD_H
+#error Do not #include this file directly. #include <obd_class.h> instead
+#endif
+
#ifndef __KERNEL__
#include <sys/types.h>
#include <libcfs/list.h>
#include <linux/timer.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_import.h>
-#include <linux/lustre_net.h>
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lprocfs_status.h>
-
-/* OBD Device Declarations */
-#define MAX_OBD_DEVICES 520
-extern struct obd_device obd_dev[MAX_OBD_DEVICES];
-extern spinlock_t obd_dev_lock;
-
-/* OBD Operations Declarations */
-extern struct obd_device *class_conn2obd(struct lustre_handle *);
-extern struct obd_device *class_exp2obd(struct obd_export *);
-
-/* genops.c */
-struct obd_export *class_conn2export(struct lustre_handle *);
-int class_register_type(struct obd_ops *ops, struct lprocfs_vars *, char *nm);
-int class_unregister_type(char *nm);
-
-struct obd_device *class_newdev(struct obd_type *type, char *name);
-void class_release_dev(struct obd_device *obd);
-
-int class_name2dev(char *name);
-struct obd_device *class_name2obd(char *name);
-int class_uuid2dev(struct obd_uuid *uuid);
-struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
-struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
- char * typ_name,
- struct obd_uuid *grp_uuid);
-struct obd_device * class_find_client_notype(struct obd_uuid *tgt_uuid,
- struct obd_uuid *grp_uuid);
-struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
- int *next);
-
-int oig_init(struct obd_io_group **oig);
-void oig_add_one(struct obd_io_group *oig,
- struct oig_callback_context *occ);
-void oig_complete_one(struct obd_io_group *oig,
- struct oig_callback_context *occ, int rc);
-void oig_release(struct obd_io_group *oig);
-int oig_wait(struct obd_io_group *oig);
-/* ping evictor */
-#ifdef __KERNEL__
-void ping_evictor_start(void);
-void ping_evictor_stop(void);
-#else
-#define ping_evictor_start() do {} while (0)
-#define ping_evictor_stop() do {} while (0)
-#endif
-
-
-char *obd_export_nid2str(struct obd_export *exp);
-
-int obd_export_evict_by_nid(struct obd_device *obd, char *nid);
-int obd_export_evict_by_uuid(struct obd_device *obd, char *uuid);
-
-/* config.c */
-int class_process_config(struct lustre_cfg *lcfg);
-int class_attach(struct lustre_cfg *lcfg);
-int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
-int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
-int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
-void class_decref(struct obd_device *obd);
-
-/* Passed as data param to class_config_parse_llog */
-struct config_llog_instance {
- char * cfg_instance;
- struct obd_uuid cfg_uuid;
-};
-int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
- struct config_llog_instance *cfg);
-int class_config_dump_llog(struct llog_ctxt *ctxt, char *name,
- struct config_llog_instance *cfg);
-
-struct lustre_profile {
- struct list_head lp_list;
- char * lp_profile;
- char * lp_osc;
- char * lp_mdc;
-};
-
-struct lustre_profile *class_get_profile(char * prof);
-void class_del_profile(char *prof);
-
-#define class_export_get(exp) \
-({ \
- struct obd_export *exp_ = exp; \
- atomic_inc(&exp_->exp_refcount); \
- CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp_, \
- atomic_read(&exp_->exp_refcount)); \
- exp_; \
-})
-
-#define class_export_put(exp) \
-do { \
- LASSERT((exp) != NULL); \
- CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", (exp), \
- atomic_read(&(exp)->exp_refcount) - 1); \
- LASSERT(atomic_read(&(exp)->exp_refcount) > 0); \
- LASSERT(atomic_read(&(exp)->exp_refcount) < 0x5a5a5a); \
- __class_export_put(exp); \
-} while (0)
-void __class_export_put(struct obd_export *);
-struct obd_export *class_new_export(struct obd_device *obddev);
-void class_unlink_export(struct obd_export *exp);
-void class_update_export_timer(struct obd_export *exp, time_t extra_delay);
-
-struct obd_import *class_import_get(struct obd_import *);
-void class_import_put(struct obd_import *);
-struct obd_import *class_new_import(void);
-void class_destroy_import(struct obd_import *exp);
-
-struct obd_type *class_get_type(char *name);
-void class_put_type(struct obd_type *type);
-int class_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid);
-int class_disconnect(struct obd_export *exp);
-void class_fail_export(struct obd_export *exp);
-void class_disconnect_exports(struct obd_device *obddev);
-void class_disconnect_stale_exports(struct obd_device *obddev);
-void class_manual_cleanup(struct obd_device *obd);
-
/* obdo.c */
#ifdef __KERNEL__
void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned ia_valid);
void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid);
void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid);
#endif
-void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid);
-int obdo_cmp_md(struct obdo *dst, struct obdo *src, obd_flag compare);
-void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj);
-
-
-#define OBT(dev) (dev)->obd_type
-#define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op
-#define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op
-
-/* Ensure obd_setup: used for cleanup which must be called
- while obd is stopping */
-#define OBD_CHECK_DEV(obd) \
-do { \
- if (!(obd)) { \
- CERROR("NULL device\n"); \
- RETURN(-ENODEV); \
- } \
-} while (0)
-
-/* ensure obd_setup and !obd_stopping */
-#define OBD_CHECK_DEV_ACTIVE(obd) \
-do { \
- OBD_CHECK_DEV(obd); \
- if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
- CERROR("Device %d not setup\n", \
- (obd)->obd_minor); \
- RETURN(-ENODEV); \
- } \
-} while (0)
-
-
-#ifdef LPROCFS
-#define OBD_COUNTER_OFFSET(op) \
- ((offsetof(struct obd_ops, o_ ## op) - \
- offsetof(struct obd_ops, o_iocontrol)) \
- / sizeof(((struct obd_ops *)(0))->o_iocontrol))
-
-#define OBD_COUNTER_INCREMENT(obd, op) \
- if ((obd)->obd_stats != NULL) { \
- unsigned int coffset; \
- coffset = (unsigned int)(obd)->obd_cntr_base + \
- OBD_COUNTER_OFFSET(op); \
- LASSERT(coffset < obd->obd_stats->ls_num); \
- lprocfs_counter_incr(obd->obd_stats, coffset); \
- }
-#else
-#define OBD_COUNTER_OFFSET(op)
-#define OBD_COUNTER_INCREMENT(obd, op)
-#endif
-
-#define OBD_CHECK_OP(obd, op, err) \
-do { \
- if (!OBT(obd) || !OBP((obd), op)) {\
- if (err) \
- CERROR("obd_" #op ": dev %d no operation\n", \
- obd->obd_minor); \
- RETURN(err); \
- } \
-} while (0)
-
-#define EXP_CHECK_OP(exp, op) \
-do { \
- if ((exp) == NULL) { \
- CERROR("obd_" #op ": NULL export\n"); \
- RETURN(-ENODEV); \
- } \
- if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \
- CERROR("obd_" #op ": cleaned up obd\n"); \
- RETURN(-EOPNOTSUPP); \
- } \
- if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \
- CERROR("obd_" #op ": dev %d no operation\n", \
- (exp)->exp_obd->obd_minor); \
- RETURN(-EOPNOTSUPP); \
- } \
-} while (0)
-
-#define CTXT_CHECK_OP(ctxt, op, err) \
-do { \
- if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \
- if (err) \
- CERROR("lop_" #op ": dev %d no operation\n", \
- ctxt->loc_obd->obd_minor); \
- RETURN(err); \
- } \
-} while (0)
-
-static inline int obd_get_info(struct obd_export *exp, __u32 keylen,
- void *key, __u32 *vallen, void *val)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, get_info);
- OBD_COUNTER_INCREMENT(exp->exp_obd, get_info);
-
- rc = OBP(exp->exp_obd, get_info)(exp, keylen, key, vallen, val);
- RETURN(rc);
-}
-
-static inline int obd_set_info(struct obd_export *exp, obd_count keylen,
- void *key, obd_count vallen, void *val)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, set_info);
- OBD_COUNTER_INCREMENT(exp->exp_obd, set_info);
-
- rc = OBP(exp->exp_obd, set_info)(exp, keylen, key, vallen, val);
- RETURN(rc);
-}
-
-static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(obd, setup, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(obd, setup);
-
- rc = OBP(obd, setup)(obd, datalen, data);
- RETURN(rc);
-}
-
-static inline int obd_precleanup(struct obd_device *obd, int cleanup_stage)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(obd, precleanup, 0);
- OBD_COUNTER_INCREMENT(obd, precleanup);
-
- rc = OBP(obd, precleanup)(obd, cleanup_stage);
- RETURN(rc);
-}
-
-static inline int obd_cleanup(struct obd_device *obd)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_DEV(obd);
- OBD_CHECK_OP(obd, cleanup, 0);
- OBD_COUNTER_INCREMENT(obd, cleanup);
-
- rc = OBP(obd, cleanup)(obd);
- RETURN(rc);
-}
-
-static inline int
-obd_process_config(struct obd_device *obd, int datalen, void *data)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(obd, process_config, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(obd, process_config);
-
- rc = OBP(obd, process_config)(obd, datalen, data);
- RETURN(rc);
-}
-
-/* Pack an in-memory MD struct for storage on disk.
- * Returns +ve size of packed MD (0 for free), or -ve error.
- *
- * If @disk_tgt == NULL, MD size is returned (max size if @mem_src == NULL).
- * If @*disk_tgt != NULL and @mem_src == NULL, @*disk_tgt will be freed.
- * If @*disk_tgt == NULL, it will be allocated
- */
-static inline int obd_packmd(struct obd_export *exp,
- struct lov_mds_md **disk_tgt,
- struct lov_stripe_md *mem_src)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, packmd);
- OBD_COUNTER_INCREMENT(exp->exp_obd, packmd);
-
- rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src);
- RETURN(rc);
-}
-
-static inline int obd_size_diskmd(struct obd_export *exp,
- struct lov_stripe_md *mem_src)
-{
- return obd_packmd(exp, NULL, mem_src);
-}
-
-/* helper functions */
-static inline int obd_alloc_diskmd(struct obd_export *exp,
- struct lov_mds_md **disk_tgt)
-{
- LASSERT(disk_tgt);
- LASSERT(*disk_tgt == NULL);
- return obd_packmd(exp, disk_tgt, NULL);
-}
-
-static inline int obd_free_diskmd(struct obd_export *exp,
- struct lov_mds_md **disk_tgt)
-{
- LASSERT(disk_tgt);
- LASSERT(*disk_tgt);
- return obd_packmd(exp, disk_tgt, NULL);
-}
-
-/* Unpack an MD struct from disk to in-memory format.
- * Returns +ve size of unpacked MD (0 for free), or -ve error.
- *
- * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL).
- * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed.
- * If @*mem_tgt == NULL, it will be allocated
- */
-static inline int obd_unpackmd(struct obd_export *exp,
- struct lov_stripe_md **mem_tgt,
- struct lov_mds_md *disk_src,
- int disk_len)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, unpackmd);
- OBD_COUNTER_INCREMENT(exp->exp_obd, unpackmd);
-
- rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len);
- RETURN(rc);
-}
-
-/* helper functions */
-static inline int obd_alloc_memmd(struct obd_export *exp,
- struct lov_stripe_md **mem_tgt)
-{
- LASSERT(mem_tgt);
- LASSERT(*mem_tgt == NULL);
- return obd_unpackmd(exp, mem_tgt, NULL, 0);
-}
-
-static inline int obd_free_memmd(struct obd_export *exp,
- struct lov_stripe_md **mem_tgt)
-{
- LASSERT(mem_tgt);
- LASSERT(*mem_tgt);
- return obd_unpackmd(exp, mem_tgt, NULL, 0);
-}
-
-static inline int obd_create(struct obd_export *exp, struct obdo *obdo,
- struct lov_stripe_md **ea,
- struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, create);
- OBD_COUNTER_INCREMENT(exp->exp_obd, create);
-
- rc = OBP(exp->exp_obd, create)(exp, obdo, ea, oti);
- RETURN(rc);
-}
-
-static inline int obd_destroy(struct obd_export *exp, struct obdo *obdo,
- struct lov_stripe_md *ea,
- struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, destroy);
- OBD_COUNTER_INCREMENT(exp->exp_obd, destroy);
-
- rc = OBP(exp->exp_obd, destroy)(exp, obdo, ea, oti);
- RETURN(rc);
-}
-
-static inline int obd_getattr(struct obd_export *exp, struct obdo *obdo,
- struct lov_stripe_md *ea)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, getattr);
- OBD_COUNTER_INCREMENT(exp->exp_obd, getattr);
-
- rc = OBP(exp->exp_obd, getattr)(exp, obdo, ea);
- RETURN(rc);
-}
-
-static inline int obd_getattr_async(struct obd_export *exp,
- struct obdo *obdo, struct lov_stripe_md *ea,
- struct ptlrpc_request_set *set)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, getattr);
- OBD_COUNTER_INCREMENT(exp->exp_obd, getattr);
-
- rc = OBP(exp->exp_obd, getattr_async)(exp, obdo, ea, set);
- RETURN(rc);
-}
-
-static inline int obd_setattr(struct obd_export *exp, struct obdo *obdo,
- struct lov_stripe_md *ea,
- struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, setattr);
- OBD_COUNTER_INCREMENT(exp->exp_obd, setattr);
-
- rc = OBP(exp->exp_obd, setattr)(exp, obdo, ea, oti);
- RETURN(rc);
-}
-
-static inline int obd_setattr_async(struct obd_export *exp,
- struct obdo *obdo,
- struct lov_stripe_md *ea,
- struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, setattr_async);
- OBD_COUNTER_INCREMENT(exp->exp_obd, setattr_async);
-
- rc = OBP(exp->exp_obd, setattr_async)(exp, obdo, ea, oti);
- RETURN(rc);
-}
-
-static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
- int priority)
-{
- struct obd_device *obd = imp->imp_obd;
- int rc;
- ENTRY;
-
- OBD_CHECK_DEV_ACTIVE(obd);
- OBD_CHECK_OP(obd, add_conn, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(obd, add_conn);
-
- rc = OBP(obd, add_conn)(imp, uuid, priority);
- RETURN(rc);
-}
-
-static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
-{
- struct obd_device *obd = imp->imp_obd;
- int rc;
- ENTRY;
-
- OBD_CHECK_DEV_ACTIVE(obd);
- OBD_CHECK_OP(obd, del_conn, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(obd, del_conn);
-
- rc = OBP(obd, del_conn)(imp, uuid);
- RETURN(rc);
-}
-
-static inline int obd_connect(struct lustre_handle *conn, struct obd_device *obd,
- struct obd_uuid *cluuid,
- struct obd_connect_data *d)
-{
- int rc;
- __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */
- ENTRY;
-
- OBD_CHECK_DEV_ACTIVE(obd);
- OBD_CHECK_OP(obd, connect, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(obd, connect);
-
- rc = OBP(obd, connect)(conn, obd, cluuid, d);
- /* check that only subset is granted */
- LASSERT(ergo(d != NULL,
- (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
- RETURN(rc);
-}
-
-static inline int obd_disconnect(struct obd_export *exp)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, disconnect);
- OBD_COUNTER_INCREMENT(exp->exp_obd, disconnect);
-
- rc = OBP(exp->exp_obd, disconnect)(exp);
- RETURN(rc);
-}
-
-static inline int obd_init_export(struct obd_export *exp)
-{
- int rc = 0;
-
- ENTRY;
- if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
- OBP((exp)->exp_obd, init_export))
- rc = OBP(exp->exp_obd, init_export)(exp);
- RETURN(rc);
-}
-
-static inline int obd_destroy_export(struct obd_export *exp)
-{
- ENTRY;
- if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
- OBP((exp)->exp_obd, destroy_export))
- OBP(exp->exp_obd, destroy_export)(exp);
- RETURN(0);
-}
-
-static inline struct dentry *
-obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
-{
- LASSERT(exp->exp_obd);
-
- return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr,
- exp->exp_obd);
-}
-
-#ifndef time_before
-#define time_before(t1, t2) ((long)t2 - (long)t1 > 0)
-#endif
-
-/* @max_age is the oldest time in jiffies that we accept using a cached data.
- * If the cache is older than @max_age we will get a new value from the
- * target. Use a value of "jiffies + HZ" to guarantee freshness. */
-static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
- unsigned long max_age)
-{
- int rc = 0;
- ENTRY;
-
- if (obd == NULL)
- RETURN(-EINVAL);
-
- OBD_CHECK_OP(obd, statfs, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(obd, statfs);
-
- CDEBUG(D_SUPER, "osfs %lu, max_age %lu\n", obd->obd_osfs_age, max_age);
- if (time_before(obd->obd_osfs_age, max_age)) {
- rc = OBP(obd, statfs)(obd, osfs, max_age);
- if (rc == 0) {
- spin_lock(&obd->obd_osfs_lock);
- memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
- obd->obd_osfs_age = jiffies;
- spin_unlock(&obd->obd_osfs_lock);
- }
- } else {
- CDEBUG(D_SUPER, "using cached obd_statfs data\n");
- spin_lock(&obd->obd_osfs_lock);
- memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
- spin_unlock(&obd->obd_osfs_lock);
- }
- RETURN(rc);
-}
-
-static inline int obd_sync(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_size start,
- obd_size end)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, sync, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, sync);
-
- rc = OBP(exp->exp_obd, sync)(exp, oa, ea, start, end);
- RETURN(rc);
-}
-
-static inline int obd_punch(struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_size start,
- obd_size end, struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, punch);
- OBD_COUNTER_INCREMENT(exp->exp_obd, punch);
-
- rc = OBP(exp->exp_obd, punch)(exp, oa, ea, start, end, oti);
- RETURN(rc);
-}
-
-static inline int obd_brw(int cmd, struct obd_export *exp, struct obdo *oa,
- struct lov_stripe_md *ea, obd_count oa_bufs,
- struct brw_page *pg, struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, brw);
- OBD_COUNTER_INCREMENT(exp->exp_obd, brw);
-
- if (!(cmd & (OBD_BRW_RWMASK | OBD_BRW_CHECK))) {
- CERROR("obd_brw: cmd must be OBD_BRW_READ, OBD_BRW_WRITE, "
- "or OBD_BRW_CHECK\n");
- LBUG();
- }
-
- rc = OBP(exp->exp_obd, brw)(cmd, exp, oa, ea, oa_bufs, pg, oti);
- RETURN(rc);
-}
-
-static inline int obd_brw_async(int cmd, struct obd_export *exp,
- struct obdo *oa, struct lov_stripe_md *ea,
- obd_count oa_bufs, struct brw_page *pg,
- struct ptlrpc_request_set *set,
- struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, brw_async);
- OBD_COUNTER_INCREMENT(exp->exp_obd, brw_async);
-
- if (!(cmd & OBD_BRW_RWMASK)) {
- CERROR("obd_brw: cmd must be OBD_BRW_READ or OBD_BRW_WRITE\n");
- LBUG();
- }
-
- rc = OBP(exp->exp_obd, brw_async)(cmd, exp, oa, ea, oa_bufs, pg, set,
- oti);
- RETURN(rc);
-}
-
-static inline int obd_prep_async_page(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct page *page, obd_off offset,
- struct obd_async_page_ops *ops,
- void *data, void **res)
-{
- int ret;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, prep_async_page, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, prep_async_page);
-
- ret = OBP(exp->exp_obd, prep_async_page)(exp, lsm, loi, page, offset,
- ops, data, res);
- RETURN(ret);
-}
-
-static inline int obd_queue_async_io(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi, void *cookie,
- int cmd, obd_off off, int count,
- obd_flag brw_flags, obd_flag async_flags)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, queue_async_io, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, queue_async_io);
- LASSERT(cmd & OBD_BRW_RWMASK);
-
- rc = OBP(exp->exp_obd, queue_async_io)(exp, lsm, loi, cookie, cmd, off,
- count, brw_flags, async_flags);
- RETURN(rc);
-}
-
-static inline int obd_set_async_flags(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi, void *cookie,
- obd_flag async_flags)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, set_async_flags, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, set_async_flags);
-
- rc = OBP(exp->exp_obd, set_async_flags)(exp, lsm, loi, cookie,
- async_flags);
- RETURN(rc);
-}
-
-static inline int obd_queue_group_io(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct obd_io_group *oig,
- void *cookie, int cmd, obd_off off,
- int count, obd_flag brw_flags,
- obd_flag async_flags)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, queue_group_io, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, queue_group_io);
- LASSERT(cmd & OBD_BRW_RWMASK);
-
- rc = OBP(exp->exp_obd, queue_group_io)(exp, lsm, loi, oig, cookie,
- cmd, off, count, brw_flags,
- async_flags);
- RETURN(rc);
-}
-
-static inline int obd_trigger_group_io(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct obd_io_group *oig)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, trigger_group_io, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, trigger_group_io);
-
- rc = OBP(exp->exp_obd, trigger_group_io)(exp, lsm, loi, oig);
- RETURN(rc);
-}
-
-static inline int obd_teardown_async_page(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi, void *cookie)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, teardown_async_page, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, teardown_async_page);
-
- rc = OBP(exp->exp_obd, teardown_async_page)(exp, lsm, loi, cookie);
- RETURN(rc);
-}
-
-static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
- int objcount, struct obd_ioobj *obj,
- int niocount, struct niobuf_remote *remote,
- struct niobuf_local *local,
- struct obd_trans_info *oti)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, preprw, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, preprw);
-
- rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, niocount,
- remote, local, oti);
- RETURN(rc);
-}
-
-static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
- int objcount, struct obd_ioobj *obj,
- int niocount, struct niobuf_local *local,
- struct obd_trans_info *oti, int rc)
-{
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, commitrw, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, commitrw);
-
- rc = OBP(exp->exp_obd, commitrw)(cmd, exp, oa, objcount, obj, niocount,
- local, oti, rc);
- RETURN(rc);
-}
-
-/* b1_4_bug5047 has changes to make this an obd_merge_lvb() method */
-__u64 lov_merge_size(struct lov_stripe_md *lsm, int kms_only);
-__u64 lov_merge_blocks(struct lov_stripe_md *lsm);
-__u64 lov_merge_mtime(struct lov_stripe_md *lsm, __u64 current_time);
-
-static inline int obd_adjust_kms(struct obd_export *exp,
- struct lov_stripe_md *lsm, obd_off size,
- int shrink)
-{
- int rc;
- ENTRY;
-
- OBD_CHECK_OP(exp->exp_obd, adjust_kms, -EOPNOTSUPP);
- OBD_COUNTER_INCREMENT(exp->exp_obd, adjust_kms);
-
- rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink);
- RETURN(rc);
-}
-
-static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
- int len, void *karg, void *uarg)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, iocontrol);
- OBD_COUNTER_INCREMENT(exp->exp_obd, iocontrol);
-
- rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
- RETURN(rc);
-}
-
-static inline int obd_enqueue(struct obd_export *exp, struct lov_stripe_md *ea,
- __u32 type, ldlm_policy_data_t *policy,
- __u32 mode, int *flags, void *bl_cb, void *cp_cb,
- void *gl_cb, void *data, __u32 lvb_len,
- void *lvb_swabber, struct lustre_handle *lockh)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, enqueue);
- OBD_COUNTER_INCREMENT(exp->exp_obd, enqueue);
-
- rc = OBP(exp->exp_obd, enqueue)(exp, ea, type, policy, mode, flags,
- bl_cb, cp_cb, gl_cb, data, lvb_len,
- lvb_swabber, lockh);
- RETURN(rc);
-}
-
-static inline int obd_match(struct obd_export *exp, struct lov_stripe_md *ea,
- __u32 type, ldlm_policy_data_t *policy, __u32 mode,
- int *flags, void *data, struct lustre_handle *lockh)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, match);
- OBD_COUNTER_INCREMENT(exp->exp_obd, match);
-
- rc = OBP(exp->exp_obd, match)(exp, ea, type, policy, mode, flags, data,
- lockh);
- RETURN(rc);
-}
-
-static inline int obd_change_cbdata(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- ldlm_iterator_t it, void *data)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, change_cbdata);
- OBD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata);
-
- rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data);
- RETURN(rc);
-}
-
-static inline int obd_cancel(struct obd_export *exp,
- struct lov_stripe_md *ea, __u32 mode,
- struct lustre_handle *lockh)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, cancel);
- OBD_COUNTER_INCREMENT(exp->exp_obd, cancel);
-
- rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh);
- RETURN(rc);
-}
-
-static inline int obd_cancel_unused(struct obd_export *exp,
- struct lov_stripe_md *ea, int flags,
- void *opaque)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, cancel_unused);
- OBD_COUNTER_INCREMENT(exp->exp_obd, cancel_unused);
-
- rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque);
- RETURN(rc);
-}
-
-static inline int obd_join_lru(struct obd_export *exp,
- struct lov_stripe_md *ea, int join)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, join_lru);
- OBD_COUNTER_INCREMENT(exp->exp_obd, join_lru);
-
- rc = OBP(exp->exp_obd, join_lru)(exp, ea, join);
- RETURN(rc);
-}
-
-static inline int obd_san_preprw(int cmd, struct obd_export *exp,
- struct obdo *oa,
- int objcount, struct obd_ioobj *obj,
- int niocount, struct niobuf_remote *remote)
-{
- int rc;
-
- EXP_CHECK_OP(exp, preprw);
- OBD_COUNTER_INCREMENT(exp->exp_obd, preprw);
-
- rc = OBP(exp->exp_obd, san_preprw)(cmd, exp, oa, objcount, obj,
- niocount, remote);
- class_export_put(exp);
- return(rc);
-}
-
-static inline int obd_pin(struct obd_export *exp, obd_id ino, __u32 gen,
- int type, struct obd_client_handle *handle, int flag)
-{
- int rc;
-
- EXP_CHECK_OP(exp, pin);
- OBD_COUNTER_INCREMENT(exp->exp_obd, pin);
-
- rc = OBP(exp->exp_obd, pin)(exp, ino, gen, type, handle, flag);
- return(rc);
-}
-
-static inline int obd_unpin(struct obd_export *exp,
- struct obd_client_handle *handle, int flag)
-{
- int rc;
-
- EXP_CHECK_OP(exp, unpin);
- OBD_COUNTER_INCREMENT(exp->exp_obd, unpin);
-
- rc = OBP(exp->exp_obd, unpin)(exp, handle, flag);
- return(rc);
-}
-
-
-static inline void obd_import_event(struct obd_device *obd,
- struct obd_import *imp,
- enum obd_import_event event)
-{
- if (!obd) {
- CERROR("NULL device\n");
- EXIT;
- return;
- }
- if (obd->obd_set_up && OBP(obd, import_event)) {
- OBD_COUNTER_INCREMENT(obd, import_event);
- OBP(obd, import_event)(obd, imp, event);
- }
-}
-
-static inline int obd_notify(struct obd_device *obd,
- struct obd_device *watched,
- int active)
-{
- OBD_CHECK_DEV(obd);
- if (!obd->obd_set_up) {
- CERROR("obd %s not set up\n", obd->obd_name);
- return -EINVAL;
- }
-
- if (!OBP(obd, notify)) {
- CERROR("obd %s has no notify handler\n", obd->obd_name);
- return -ENOSYS;
- }
-
- OBD_COUNTER_INCREMENT(obd, notify);
- return OBP(obd, notify)(obd, watched, active);
-}
-
-static inline int obd_quotacheck(struct obd_export *exp,
- struct obd_quotactl *oqctl)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, quotacheck);
- OBD_COUNTER_INCREMENT(exp->exp_obd, quotacheck);
-
- rc = OBP(exp->exp_obd, quotacheck)(exp, oqctl);
- RETURN(rc);
-}
-
-static inline int obd_quotactl(struct obd_export *exp,
- struct obd_quotactl *oqctl)
-{
- int rc;
- ENTRY;
-
- EXP_CHECK_OP(exp, quotactl);
- OBD_COUNTER_INCREMENT(exp->exp_obd, quotactl);
-
- rc = OBP(exp->exp_obd, quotactl)(exp, oqctl);
- RETURN(rc);
-}
-
-static inline int obd_health_check(struct obd_device *obd)
-{
- /* returns: 0 on healthy
- * >0 on unhealthy + reason code/flag
- * however the only suppored reason == 1 right now
- * We'll need to define some better reasons
- * or flags in the future.
- * <0 on error
- */
- int rc;
- ENTRY;
-
- /* don't use EXP_CHECK_OP, because NULL method is normal here */
- if (obd == NULL || !OBT(obd)) {
- CERROR("cleaned up obd\n");
- RETURN(-EOPNOTSUPP);
- }
- if (!obd->obd_set_up || obd->obd_stopping)
- RETURN(0);
- if (!OBP(obd, health_check))
- RETURN(0);
-
- rc = OBP(obd, health_check)(obd);
- RETURN(rc);
-}
-
-static inline int obd_register_observer(struct obd_device *obd,
- struct obd_device *observer)
-{
- ENTRY;
- OBD_CHECK_DEV(obd);
- if (obd->obd_observer && observer)
- RETURN(-EALREADY);
- obd->obd_observer = observer;
- RETURN(0);
-}
-
-/* OBD Metadata Support */
-
-extern int obd_init_caches(void);
-extern void obd_cleanup_caches(void);
-
-/* support routines */
-extern kmem_cache_t *obdo_cachep;
-static inline struct obdo *obdo_alloc(void)
-{
- struct obdo *oa;
-
- OBD_SLAB_ALLOC(oa, obdo_cachep, SLAB_KERNEL, sizeof(*oa));
-
- return oa;
-}
-
-static inline void obdo_free(struct obdo *oa)
-{
- OBD_SLAB_FREE(oa, obdo_cachep, sizeof(*oa));
-}
#if !defined(__KERNEL__) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#define to_kdev_t(dev) dev
#define kdev_t_to_nr(dev) dev
#endif
-/* I'm as embarrassed about this as you are.
- *
- * <shaver> // XXX do not look into _superhack with remaining eye
- * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
-extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
-extern void (*ptlrpc_abort_inflight_superhack)(struct obd_import *imp);
-
-/* sysctl.c */
-extern void obd_sysctl_init (void);
-extern void obd_sysctl_clean (void);
-
-/* uuid.c */
-typedef __u8 class_uuid_t[16];
-//int class_uuid_parse(struct obd_uuid in, class_uuid_t out);
-void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out);
-
-/* lustre_peer.c */
-int lustre_uuid_to_peer(char *uuid, lnet_nid_t *peer_nid, int index);
-int class_add_uuid(char *uuid, __u64 nid);
-int class_del_uuid (char *uuid);
-void class_init_uuidlist(void);
-void class_exit_uuidlist(void);
-
#endif /* __LINUX_OBD_CLASS_H */
*
*/
+#ifndef _LINUX_OBD_SUPPORT
+#define _LINUX_OBD_SUPPORT
+
#ifndef _OBD_SUPPORT
-#define _OBD_SUPPORT
+#error Do not #include this file directly. #include <obd_support.h> instead
+#endif
#ifdef __KERNEL__
#include <linux/config.h>
#include <libcfs/kp30.h>
#include <linux/lustre_compat25.h>
-/* global variables */
-extern atomic_t obd_memory;
-extern int obd_memmax;
-extern unsigned int obd_fail_loc;
-extern unsigned int obd_dump_on_timeout;
-extern unsigned int obd_timeout; /* seconds */
-#define PING_INTERVAL max(obd_timeout / 4, 1U)
-#define STATFS_INTERVAL max(obd_timeout / 20, 1U)
-extern unsigned int ldlm_timeout;
-extern unsigned int obd_health_check_timeout;
-extern char obd_lustre_upcall[128];
-extern unsigned int obd_sync_filter;
-extern wait_queue_head_t obd_race_waitq;
-
-#define OBD_FAIL_MDS 0x100
-#define OBD_FAIL_MDS_HANDLE_UNPACK 0x101
-#define OBD_FAIL_MDS_GETATTR_NET 0x102
-#define OBD_FAIL_MDS_GETATTR_PACK 0x103
-#define OBD_FAIL_MDS_READPAGE_NET 0x104
-#define OBD_FAIL_MDS_READPAGE_PACK 0x105
-#define OBD_FAIL_MDS_SENDPAGE 0x106
-#define OBD_FAIL_MDS_REINT_NET 0x107
-#define OBD_FAIL_MDS_REINT_UNPACK 0x108
-#define OBD_FAIL_MDS_REINT_SETATTR 0x109
-#define OBD_FAIL_MDS_REINT_SETATTR_WRITE 0x10a
-#define OBD_FAIL_MDS_REINT_CREATE 0x10b
-#define OBD_FAIL_MDS_REINT_CREATE_WRITE 0x10c
-#define OBD_FAIL_MDS_REINT_UNLINK 0x10d
-#define OBD_FAIL_MDS_REINT_UNLINK_WRITE 0x10e
-#define OBD_FAIL_MDS_REINT_LINK 0x10f
-#define OBD_FAIL_MDS_REINT_LINK_WRITE 0x110
-#define OBD_FAIL_MDS_REINT_RENAME 0x111
-#define OBD_FAIL_MDS_REINT_RENAME_WRITE 0x112
-#define OBD_FAIL_MDS_OPEN_NET 0x113
-#define OBD_FAIL_MDS_OPEN_PACK 0x114
-#define OBD_FAIL_MDS_CLOSE_NET 0x115
-#define OBD_FAIL_MDS_CLOSE_PACK 0x116
-#define OBD_FAIL_MDS_CONNECT_NET 0x117
-#define OBD_FAIL_MDS_CONNECT_PACK 0x118
-#define OBD_FAIL_MDS_REINT_NET_REP 0x119
-#define OBD_FAIL_MDS_DISCONNECT_NET 0x11a
-#define OBD_FAIL_MDS_GETSTATUS_NET 0x11b
-#define OBD_FAIL_MDS_GETSTATUS_PACK 0x11c
-#define OBD_FAIL_MDS_STATFS_PACK 0x11d
-#define OBD_FAIL_MDS_STATFS_NET 0x11e
-#define OBD_FAIL_MDS_GETATTR_NAME_NET 0x11f
-#define OBD_FAIL_MDS_PIN_NET 0x120
-#define OBD_FAIL_MDS_UNPIN_NET 0x121
-#define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
-#define OBD_FAIL_MDS_ALL_REQUEST_NET 0x123
-#define OBD_FAIL_MDS_SYNC_NET 0x124
-#define OBD_FAIL_MDS_SYNC_PACK 0x125
-#define OBD_FAIL_MDS_DONE_WRITING_NET 0x126
-#define OBD_FAIL_MDS_DONE_WRITING_PACK 0x127
-#define OBD_FAIL_MDS_ALLOC_OBDO 0x128
-#define OBD_FAIL_MDS_PAUSE_OPEN 0x129
-#define OBD_FAIL_MDS_STATFS_LCW_SLEEP 0x12a
-#define OBD_FAIL_MDS_OPEN_CREATE 0x12b
-#define OBD_FAIL_MDS_OST_SETATTR 0x12c
-#define OBD_FAIL_MDS_QUOTACHECK_NET 0x12d
-#define OBD_FAIL_MDS_QUOTACTL_NET 0x12e
-#define OBD_FAIL_MDS_CLIENT_ADD 0x12f
-#define OBD_FAIL_MDS_GETXATTR_NET 0x130
-#define OBD_FAIL_MDS_GETXATTR_PACK 0x131
-#define OBD_FAIL_MDS_SETXATTR_NET 0x132
-#define OBD_FAIL_MDS_SETXATTR 0x133
-#define OBD_FAIL_MDS_SETXATTR_WRITE 0x134
-
-#define OBD_FAIL_OST 0x200
-#define OBD_FAIL_OST_CONNECT_NET 0x201
-#define OBD_FAIL_OST_DISCONNECT_NET 0x202
-#define OBD_FAIL_OST_GET_INFO_NET 0x203
-#define OBD_FAIL_OST_CREATE_NET 0x204
-#define OBD_FAIL_OST_DESTROY_NET 0x205
-#define OBD_FAIL_OST_GETATTR_NET 0x206
-#define OBD_FAIL_OST_SETATTR_NET 0x207
-#define OBD_FAIL_OST_OPEN_NET 0x208
-#define OBD_FAIL_OST_CLOSE_NET 0x209
-#define OBD_FAIL_OST_BRW_NET 0x20a
-#define OBD_FAIL_OST_PUNCH_NET 0x20b
-#define OBD_FAIL_OST_STATFS_NET 0x20c
-#define OBD_FAIL_OST_HANDLE_UNPACK 0x20d
-#define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
-#define OBD_FAIL_OST_BRW_READ_BULK 0x20f
-#define OBD_FAIL_OST_SYNC_NET 0x210
-#define OBD_FAIL_OST_ALL_REPLY_NET 0x211
-#define OBD_FAIL_OST_ALL_REQUESTS_NET 0x212
-#define OBD_FAIL_OST_LDLM_REPLY_NET 0x213
-#define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
-#define OBD_FAIL_OST_ENOSPC 0x215
-#define OBD_FAIL_OST_EROFS 0x216
-#define OBD_FAIL_OST_ENOENT 0x217
-#define OBD_FAIL_OST_QUOTACHECK_NET 0x218
-#define OBD_FAIL_OST_QUOTACTL_NET 0x219
-
-#define OBD_FAIL_LDLM 0x300
-#define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301
-#define OBD_FAIL_LDLM_ENQUEUE 0x302
-#define OBD_FAIL_LDLM_CONVERT 0x303
-#define OBD_FAIL_LDLM_CANCEL 0x304
-#define OBD_FAIL_LDLM_BL_CALLBACK 0x305
-#define OBD_FAIL_LDLM_CP_CALLBACK 0x306
-#define OBD_FAIL_LDLM_GL_CALLBACK 0x307
-#define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
-#define OBD_FAIL_LDLM_ENQUEUE_INTENT_ERR 0x309
-#define OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
-#define OBD_FAIL_LDLM_ENQUEUE_BLOCKED 0x30b
-#define OBD_FAIL_LDLM_REPLY 0x30c
-#define OBD_FAIL_LDLM_RECOV_CLIENTS 0x30d
-#define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
-
-#define OBD_FAIL_OSC 0x400
-#define OBD_FAIL_OSC_BRW_READ_BULK 0x401
-#define OBD_FAIL_OSC_BRW_WRITE_BULK 0x402
-#define OBD_FAIL_OSC_LOCK_BL_AST 0x403
-#define OBD_FAIL_OSC_LOCK_CP_AST 0x404
-#define OBD_FAIL_OSC_MATCH 0x405
-#define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
-#define OBD_FAIL_OSC_SHUTDOWN 0x407
-
-#define OBD_FAIL_PTLRPC 0x500
-#define OBD_FAIL_PTLRPC_ACK 0x501
-#define OBD_FAIL_PTLRPC_RQBD 0x502
-#define OBD_FAIL_PTLRPC_BULK_GET_NET 0x503
-#define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504
-#define OBD_FAIL_PTLRPC_DROP_RPC 0x505
-
-#define OBD_FAIL_OBD_PING_NET 0x600
-#define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
-#define OBD_FAIL_OBD_LOGD_NET 0x602
-#define OBD_FAIL_OBD_QC_CALLBACK_NET 0x603
-#define OBD_FAIL_OBD_DQACQ 0x604
-
-#define OBD_FAIL_TGT_REPLY_NET 0x700
-#define OBD_FAIL_TGT_CONN_RACE 0x701
-
-#define OBD_FAIL_MDC_REVALIDATE_PAUSE 0x800
-
-#define OBD_FAIL_OST_CROW_EIO 0x801
-#define OBD_FAIL_OST_CLEAR_ORPHANS_RACE 0x802
-
-/* preparation for a more advanced failure testbed (not functional yet) */
-#define OBD_FAIL_MASK_SYS 0x0000FF00
-#define OBD_FAIL_MASK_LOC (0x000000FF | OBD_FAIL_MASK_SYS)
-#define OBD_FAIL_ONCE 0x80000000
-#define OBD_FAILED 0x40000000
-#define OBD_FAIL_MDS_ALL_NET 0x01000000
-#define OBD_FAIL_OST_ALL_NET 0x02000000
-
-#define OBD_FAIL_CHECK(id) (((obd_fail_loc & OBD_FAIL_MASK_LOC) == \
- ((id) & OBD_FAIL_MASK_LOC)) && \
- ((obd_fail_loc & (OBD_FAILED | OBD_FAIL_ONCE))!= \
- (OBD_FAILED | OBD_FAIL_ONCE)))
-
-#define OBD_FAIL_CHECK_ONCE(id) \
-({ int _ret_ = 0; \
- if (OBD_FAIL_CHECK(id)) { \
- CERROR("*** obd_fail_loc=%x ***\n", id); \
- obd_fail_loc |= OBD_FAILED; \
- if ((id) & OBD_FAIL_ONCE) \
- obd_fail_loc |= OBD_FAIL_ONCE; \
- _ret_ = 1; \
- } \
- _ret_; \
-})
-
-#define OBD_FAIL_RETURN(id, ret) \
-do { \
- if (OBD_FAIL_CHECK_ONCE(id)) { \
- RETURN(ret); \
- } \
-} while(0)
-
-#define OBD_FAIL_TIMEOUT(id, secs) \
-do { \
- if (OBD_FAIL_CHECK_ONCE(id)) { \
- CERROR("obd_fail_timeout id %x sleeping for %d secs\n", \
- (id), (secs)); \
- set_current_state(TASK_UNINTERRUPTIBLE); \
- schedule_timeout((secs) * HZ); \
- set_current_state(TASK_RUNNING); \
- CERROR("obd_fail_timeout id %x awake\n", (id)); \
- } \
-} while(0)
-
/* Prefer the kernel's version, if it exports it, because it might be
* optimized for this CPU. */
#if defined(__KERNEL__) && (defined(CONFIG_CRC32) || defined(CONFIG_CRC32_MODULE))
#endif
#ifdef __KERNEL__
-/* The idea here is to synchronise two threads to force a race. The
- * first thread that calls this with a matching fail_loc is put to
- * sleep. The next thread that calls with the same fail_loc wakes up
- * the first and continues. */
-#define OBD_RACE(id) \
-do { \
- if (OBD_FAIL_CHECK_ONCE(id)) { \
- CERROR("obd_race id %x sleeping\n", (id)); \
- interruptible_sleep_on(&obd_race_waitq); \
- CERROR("obd_fail_race id %x awake\n", (id)); \
- } else if ((obd_fail_loc & OBD_FAIL_MASK_LOC) == \
- ((id) & OBD_FAIL_MASK_LOC)) { \
- wake_up(&obd_race_waitq); \
- } \
-} while(0)
-#else
-/* sigh. an expedient fix until OBD_RACE is fixed up */
-#define OBD_RACE(foo) do {} while(0)
-#endif
-
-#define fixme() CDEBUG(D_OTHER, "FIXME\n");
-
-#ifdef __KERNEL__
# include <linux/types.h>
# include <linux/blkdev.h>
-# include <linux/lvfs.h>
+# include <lvfs.h>
static inline void OBD_FAIL_WRITE(int id, struct super_block *sb)
{
obd_fail_loc |= OBD_FAILED | OBD_FAIL_ONCE;
}
}
+
+#define OBD_SLEEP_ON(wq) interruptible_sleep_on(wq)
+
+
#else /* !__KERNEL__ */
# define LTIME_S(time) (time)
/* for obd_class.h */
# endif
#endif /* __KERNEL__ */
-extern atomic_t libcfs_kmemory;
-
-#if defined(LUSTRE_UTILS) /* this version is for utils only */
-#define OBD_ALLOC_GFP(ptr, size, gfp_mask) \
-do { \
- (ptr) = kmalloc(size, (gfp_mask)); \
- if ((ptr) == NULL) { \
- CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
- (int)(size), __FILE__, __LINE__); \
- } else { \
- memset(ptr, 0, size); \
- CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p\n", \
- (int)(size), ptr); \
- } \
-} while (0)
-#else /* this version is for the kernel and liblustre */
-#define OBD_ALLOC_GFP(ptr, size, gfp_mask) \
-do { \
- (ptr) = kmalloc(size, (gfp_mask)); \
- if ((ptr) == NULL) { \
- CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
- (int)(size), __FILE__, __LINE__); \
- CERROR("%d total bytes allocated by Lustre, %d by Portals\n", \
- atomic_read(&obd_memory), atomic_read(&libcfs_kmemory));\
- } else { \
- memset(ptr, 0, size); \
- atomic_add(size, &obd_memory); \
- if (atomic_read(&obd_memory) > obd_memmax) \
- obd_memmax = atomic_read(&obd_memory); \
- CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d)\n", \
- (int)(size), ptr, atomic_read(&obd_memory)); \
- } \
-} while (0)
-#endif
-
-#ifndef OBD_GFP_MASK
-# define OBD_GFP_MASK GFP_NOFS
-#endif
-
-#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, OBD_GFP_MASK)
-#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_KERNEL)
-#define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof *(ptr))
-#define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof *(ptr))
-
-#ifdef __arch_um__
-# define OBD_VMALLOC(ptr, size) OBD_ALLOC(ptr, size)
-#else
-# define OBD_VMALLOC(ptr, size) \
-do { \
- (ptr) = vmalloc(size); \
- if ((ptr) == NULL) { \
- CERROR("vmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
- (int)(size), __FILE__, __LINE__); \
- CERROR("%d total bytes allocated by Lustre, %d by Portals\n", \
- atomic_read(&obd_memory), atomic_read(&libcfs_kmemory));\
- } else { \
- memset(ptr, 0, size); \
- atomic_add(size, &obd_memory); \
- if (atomic_read(&obd_memory) > obd_memmax) \
- obd_memmax = atomic_read(&obd_memory); \
- CDEBUG(D_MALLOC, "vmalloced '" #ptr "': %d at %p (tot %d)\n", \
- (int)(size), ptr, atomic_read(&obd_memory)); \
- } \
-} while (0)
-#endif
-
-#ifdef CONFIG_DEBUG_SLAB
-#define POISON(ptr, c, s) do {} while (0)
-#else
-#define POISON(ptr, c, s) memset(ptr, c, s)
-#endif
-
-#if POISON_BULK
-#define POISON_PAGE(page, val) do { memset(kmap(page), val, PAGE_SIZE); \
- kunmap(page); } while (0)
-#else
-#define POISON_PAGE(page, val) do { } while (0)
-#endif
-
-#ifdef __KERNEL__
-#define OBD_FREE(ptr, size) \
-do { \
- LASSERT(ptr); \
- atomic_sub(size, &obd_memory); \
- CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n", \
- (int)(size), ptr, atomic_read(&obd_memory)); \
- POISON(ptr, 0x5a, size); \
- kfree(ptr); \
- (ptr) = (void *)0xdeadbeef; \
-} while (0)
-#else
-#define OBD_FREE(ptr, size) ((void)(size), free((ptr)))
-#endif
-
-#ifdef __arch_um__
-# define OBD_VFREE(ptr, size) OBD_FREE(ptr, size)
-#else
-# define OBD_VFREE(ptr, size) \
-do { \
- LASSERT(ptr); \
- atomic_sub(size, &obd_memory); \
- CDEBUG(D_MALLOC, "vfreed '" #ptr "': %d at %p (tot %d).\n", \
- (int)(size), ptr, atomic_read(&obd_memory)); \
- POISON(ptr, 0x5a, size); \
- vfree(ptr); \
- (ptr) = (void *)0xdeadbeef; \
-} while (0)
-#endif
-
-/* we memset() the slab object to 0 when allocation succeeds, so DO NOT
- * HAVE A CTOR THAT DOES ANYTHING. its work will be cleared here. we'd
- * love to assert on that, but slab.c keeps kmem_cache_s all to itself. */
-#define OBD_SLAB_ALLOC(ptr, slab, type, size) \
-do { \
- LASSERT(!in_interrupt()); \
- (ptr) = kmem_cache_alloc(slab, (type)); \
- if ((ptr) == NULL) { \
- CERROR("slab-alloc of '"#ptr"' (%d bytes) failed at %s:%d\n", \
- (int)(size), __FILE__, __LINE__); \
- CERROR("%d total bytes allocated by Lustre, %d by Portals\n", \
- atomic_read(&obd_memory), atomic_read(&libcfs_kmemory));\
- } else { \
- memset(ptr, 0, size); \
- atomic_add(size, &obd_memory); \
- if (atomic_read(&obd_memory) > obd_memmax) \
- obd_memmax = atomic_read(&obd_memory); \
- CDEBUG(D_MALLOC, "slab-alloced '"#ptr"': %d at %p (tot %d)\n",\
- (int)(size), ptr, atomic_read(&obd_memory)); \
- } \
-} while (0)
-
-#define OBD_FREE_PTR(ptr) OBD_FREE(ptr, sizeof *(ptr))
-
-#define OBD_SLAB_FREE(ptr, slab, size) \
-do { \
- LASSERT(ptr); \
- CDEBUG(D_MALLOC, "slab-freed '" #ptr "': %d at %p (tot %d).\n", \
- (int)(size), ptr, atomic_read(&obd_memory)); \
- atomic_sub(size, &obd_memory); \
- POISON(ptr, 0x5a, size); \
- kmem_cache_free(slab, ptr); \
- (ptr) = (void *)0xdeadbeef; \
-} while (0)
-
-#define KEY_IS(str) \
- (keylen == strlen(str) && memcmp(key, str, keylen) == 0)
-
#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Top level header file for LProc SNMP
+ * Author: Hariharan Thantry thantry@users.sourceforge.net
+ */
+#ifndef _LPROCFS_SNMP_H
+#define _LPROCFS_SNMP_H
+
+#if defined(__linux__)
+#include <linux/lprocfs_status.h>
+#elif defined(__APPLE__)
+#include <darwin/lprocfs_status.h>
+#elif defined(__WINNT__)
+#include <winnt/lprocfs_status.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#undef LPROCFS
+#if (defined(__KERNEL__) && defined(CONFIG_PROC_FS))
+# define LPROCFS
+#endif
+
+struct lprocfs_vars {
+ const char *name;
+ cfs_read_proc_t *read_fptr;
+ cfs_write_proc_t *write_fptr;
+ void *data;
+};
+
+struct lprocfs_static_vars {
+ struct lprocfs_vars *module_vars;
+ struct lprocfs_vars *obd_vars;
+};
+
+/* An lprocfs counter can be configured using the enum bit masks below.
+ *
+ * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
+ * protects this counter from concurrent updates. If not specified,
+ * lprocfs an internal per-counter lock variable. External locks are
+ * not used to protect counter increments, but are used to protect
+ * counter readout and resets.
+ *
+ * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
+ * (i.e. counter can be incremented by more than "1"). When specified,
+ * the counter maintains min, max and sum in addition to a simple
+ * invocation count. This allows averages to be be computed.
+ * If not specified, the counter is an increment-by-1 counter.
+ * min, max, sum, etc. are not maintained.
+ *
+ * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
+ * squares (for multi-valued counter samples only). This allows
+ * external computation of standard deviation, but involves a 64-bit
+ * multiply per counter increment.
+ */
+
+enum {
+ LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
+ LPROCFS_CNTR_AVGMINMAX = 0x0002,
+ LPROCFS_CNTR_STDDEV = 0x0004,
+
+ /* counter data type */
+ LPROCFS_TYPE_REGS = 0x0100,
+ LPROCFS_TYPE_BYTES = 0x0200,
+ LPROCFS_TYPE_PAGES = 0x0400,
+ LPROCFS_TYPE_CYCLE = 0x0800,
+};
+
+struct lprocfs_atomic {
+ atomic_t la_entry;
+ atomic_t la_exit;
+};
+
+struct lprocfs_counter {
+ struct lprocfs_atomic lc_cntl; /* may need to move to per set */
+ unsigned int lc_config;
+ __u64 lc_count;
+ __u64 lc_sum;
+ __u64 lc_min;
+ __u64 lc_max;
+ __u64 lc_sumsquare;
+ const char *lc_name; /* must be static */
+ const char *lc_units; /* must be static */
+};
+
+struct lprocfs_percpu {
+ struct lprocfs_counter lp_cntr[0];
+};
+
+
+struct lprocfs_stats {
+ unsigned int ls_num; /* # of counters */
+ unsigned int ls_percpu_size;
+ struct lprocfs_percpu *ls_percpu[0];
+};
+
+
+/* class_obd.c */
+extern cfs_proc_dir_entry_t *proc_lustre_root;
+
+struct obd_device;
+struct file;
+struct obd_histogram;
+
+#ifdef LPROCFS
+
+/* Two optimized LPROCFS counter increment functions are provided:
+ * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
+ * lprocfs_counter_add(cntr) - use for multi-valued counters
+ * Counter data layout allows config flag, counter lock and the
+ * count itself to reside within a single cache line.
+ */
+
+static inline void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
+ long amount)
+{
+ struct lprocfs_counter *percpu_cntr;
+
+ LASSERT(stats != NULL);
+ percpu_cntr = &(stats->ls_percpu[smp_processor_id()]->lp_cntr[idx]);
+ atomic_inc(&percpu_cntr->lc_cntl.la_entry);
+ percpu_cntr->lc_count++;
+
+ if (percpu_cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) {
+ percpu_cntr->lc_sum += amount;
+ if (percpu_cntr->lc_config & LPROCFS_CNTR_STDDEV)
+ percpu_cntr->lc_sumsquare += (__u64)amount * amount;
+ if (amount < percpu_cntr->lc_min)
+ percpu_cntr->lc_min = amount;
+ if (amount > percpu_cntr->lc_max)
+ percpu_cntr->lc_max = amount;
+ }
+ atomic_inc(&percpu_cntr->lc_cntl.la_exit);
+}
+
+static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, int idx)
+{
+ struct lprocfs_counter *percpu_cntr;
+
+ LASSERT(stats != NULL);
+ percpu_cntr = &(stats->ls_percpu[smp_processor_id()]->lp_cntr[idx]);
+ atomic_inc(&percpu_cntr->lc_cntl.la_entry);
+ percpu_cntr->lc_count++;
+ atomic_inc(&percpu_cntr->lc_cntl.la_exit);
+}
+
+extern struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num);
+extern void lprocfs_free_stats(struct lprocfs_stats *stats);
+extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
+ unsigned int num_private_stats);
+extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
+ unsigned conf, const char *name,
+ const char *units);
+extern void lprocfs_free_obd_stats(struct obd_device *obddev);
+extern int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name,
+ struct lprocfs_stats *stats);
+
+#define LPROCFS_INIT_VARS(name, vclass, vinstance) \
+void lprocfs_##name##_init_vars(struct lprocfs_static_vars *x) \
+{ \
+ x->module_vars = vclass; \
+ x->obd_vars = vinstance; \
+} \
+
+#define lprocfs_init_vars(NAME, VAR) \
+do { \
+ extern void lprocfs_##NAME##_init_vars(struct lprocfs_static_vars *); \
+ lprocfs_##NAME##_init_vars(VAR); \
+} while (0)
+/* lprocfs_status.c */
+extern int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
+ struct lprocfs_vars *var,
+ void *data);
+
+extern cfs_proc_dir_entry_t *lprocfs_register(const char *name,
+ cfs_proc_dir_entry_t *parent,
+ struct lprocfs_vars *list,
+ void *data);
+
+extern void lprocfs_remove(cfs_proc_dir_entry_t *root);
+
+extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
+ const char *name);
+
+extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
+extern int lprocfs_obd_cleanup(struct obd_device *obd);
+
+/* Generic callbacks */
+
+extern int lprocfs_rd_u64(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_atomic(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_uuid(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_name(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_fstype(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+extern int lprocfs_wr_ping(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+
+/* Statfs helpers */
+extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_filestotal(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+
+extern int lprocfs_write_helper(const char *buffer, unsigned long count,
+ int *val);
+extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
+ __u64 *val);
+int lprocfs_obd_seq_create(struct obd_device *dev, char *name, mode_t mode,
+ struct file_operations *seq_fops, void *data);
+void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
+void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
+void lprocfs_oh_clear(struct obd_histogram *oh);
+unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
+
+/* lprocfs_status.c: counter read/write functions */
+extern int lprocfs_counter_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+extern int lprocfs_counter_write(struct file *file, const char *buffer,
+ unsigned long count, void *data);
+
+/* lprocfs_status.c: recovery status */
+int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+#else
+/* LPROCFS is not defined */
+static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
+ int index, long amount) { return; }
+static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
+ int index) { return; }
+static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
+ int index, unsigned conf,
+ const char *name, const char *units)
+{ return; }
+
+static inline struct lprocfs_stats* lprocfs_alloc_stats(unsigned int num)
+{ return NULL; }
+static inline void lprocfs_free_stats(struct lprocfs_stats *stats)
+{ return; }
+
+static inline int lprocfs_register_stats(cfs_proc_dir_entry_t *root,
+ const char *name,
+ struct lprocfs_stats *stats)
+{ return 0; }
+static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
+ unsigned int num_private_stats)
+{ return 0; }
+static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
+{ return; }
+
+static inline cfs_proc_dir_entry_t *
+lprocfs_register(const char *name, cfs_proc_dir_entry_t *parent,
+ struct lprocfs_vars *list, void *data) { return NULL; }
+#define LPROCFS_INIT_VARS(name, vclass, vinstance)
+#define lprocfs_init_vars(...) do {} while (0)
+static inline int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
+ struct lprocfs_vars *var,
+ void *data) { return 0; }
+static inline void lprocfs_remove(cfs_proc_dir_entry_t *root) {};
+static inline cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *head,
+ const char *name) {return 0;}
+static inline int lprocfs_obd_setup(struct obd_device *dev,
+ struct lprocfs_vars *list) { return 0; }
+static inline int lprocfs_obd_cleanup(struct obd_device *dev) { return 0; }
+static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline int lprocfs_rd_name(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{ return 0; }
+static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{ return 0; }
+static inline int lprocfs_rd_num_exports(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{ return 0; }
+static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{ return 0; }
+static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{ return 0; }
+static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{ return 0; }
+
+
+/* Statfs helpers */
+static inline
+int lprocfs_rd_blksize(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+int lprocfs_rd_filestotal(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+int lprocfs_rd_filesfree(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+int lprocfs_rd_filegroups(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value) {}
+static inline
+void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value) {}
+static inline
+void lprocfs_oh_clear(struct obd_histogram *oh) {}
+static inline
+unsigned long lprocfs_oh_sum(struct obd_histogram *oh) { return 0; }
+static inline
+int lprocfs_counter_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data) { return 0; }
+static inline
+int lprocfs_counter_write(struct file *file, const char *buffer,
+ unsigned long count, void *data) { return 0; }
+#endif /* LPROCFS */
+
+#endif /* LPROCFS_SNMP_H */
#ifndef _LUSTRE_USER_H
#define _LUSTRE_USER_H
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
+#if defined(__linux__)
+#include <linux/lustre_user.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_user.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_user.h>
#else
-#include <lustre/types.h>
-#endif
-
-#ifdef HAVE_QUOTA_SUPPORT
-#include <linux/quota.h>
-#endif
-
-/*
- * asm-x86_64/processor.h on some SLES 9 distros seems to use
- * kernel-only typedefs. fortunately skipping it altogether is ok
- * (for now).
- */
-#define __ASM_X86_64_PROCESSOR_H
-
-#ifdef __KERNEL__
-#include <linux/string.h>
-#else
-#include <string.h>
-#include <sys/stat.h>
+#error Unsupported operating system.
#endif
/* for statfs() */
struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
} __attribute__((packed));
-#if defined(__x86_64__) || defined(__ia64__) || defined(__ppc64__)
-typedef struct stat lstat_t;
-#define HAVE_LOV_USER_MDS_DATA
-#elif defined(__USE_LARGEFILE64) || defined(__KERNEL__)
-typedef struct stat64 lstat_t;
-#define HAVE_LOV_USER_MDS_DATA
-#endif
-
/* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
* use this. It is unsafe to #define those values in this header as it
* is possible the application has already #included <sys/stat.h>. */
__u32 mgd_groups[0];
};
-
-#ifndef __KERNEL__
-#define NEED_QUOTA_DEFS
-#else
-# include <linux/version.h>
-# if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,21)
-# define NEED_QUOTA_DEFS
-# endif
-#endif
-
#ifdef NEED_QUOTA_DEFS
#ifndef QUOTABLOCK_BITS
#define QUOTABLOCK_BITS 10
struct obd_uuid obd_uuid;
};
-#ifndef LPU64
-/* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
-#if defined(__x86_64__) && defined(__KERNEL__)
-# define LPU64 "%Lu"
-# define LPD64 "%Ld"
-# define LPX64 "%#Lx"
-# define LPSZ "%lu"
-# define LPSSZ "%ld"
-#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
-# define LPU64 "%Lu"
-# define LPD64 "%Ld"
-# define LPX64 "%#Lx"
-# define LPSZ "%u"
-# define LPSSZ "%d"
-#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
-# define LPU64 "%lu"
-# define LPD64 "%ld"
-# define LPX64 "%#lx"
-# define LPSZ "%lu"
-# define LPSSZ "%ld"
-#endif
-#endif /* !LPU64 */
-
#ifndef offsetof
# define offsetof(typ,memb) ((unsigned long)((char *)&(((typ *)0)->memb)))
#endif
}
-#include <linux/obd_support.h>
+#include <obd_support.h>
static inline struct lustre_cfg *lustre_cfg_new(int cmd,
struct lustre_cfg_bufs *bufs)
{
int len;
+ ENTRY;
len = lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens);
OBD_FREE(lcfg, len);
#ifndef _LUSTRE_COMMIT_CONFD_H
#define _LUSTRE_COMMIT_CONFD_H
-#include <linux/lustre_log.h>
+#include <lustre_log.h>
struct llog_canceld_ctxt {
struct list_head llcd_list; /* free or pending struct list */
int lcm_thread_max; /* <= num_osts normally */
int lcm_flags;
- wait_queue_head_t lcm_waitq;
+ cfs_waitq_t lcm_waitq;
struct list_head lcm_llcd_pending; /* llog_canceld_ctxt to send */
struct list_head lcm_llcd_resend; /* try to resend this data */
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _LUSTRE_DEBUG_H
+#define _LUSTRE_DEBUG_H
+
+#include <lustre_net.h>
+
+#if defined(__linux__)
+#include <linux/lustre_debug.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_debug.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_debug.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#define ASSERT_MAX_SIZE_MB 60000ULL
+#define ASSERT_PAGE_INDEX(index, OP) \
+do { if (index > ASSERT_MAX_SIZE_MB << (20 - CFS_PAGE_SHIFT)) { \
+ CERROR("bad page index %lu > %Lu\n", index, \
+ ASSERT_MAX_SIZE_MB << (20 - CFS_PAGE_SHIFT)); \
+ libcfs_debug = ~0UL; \
+ OP; \
+}} while(0)
+
+#define ASSERT_FILE_OFFSET(offset, OP) \
+do { if (offset > ASSERT_MAX_SIZE_MB << 20) { \
+ CERROR("bad file offset %Lu > %Lu\n", offset, \
+ ASSERT_MAX_SIZE_MB << 20); \
+ libcfs_debug = ~0UL; \
+ OP; \
+}} while(0)
+
+/* lib/debug.c */
+int dump_lniobuf(struct niobuf_local *lnb);
+int dump_rniobuf(struct niobuf_remote *rnb);
+int dump_ioo(struct obd_ioobj *nb);
+int dump_req(struct ptlrpc_request *req);
+int dump_obdo(struct obdo *oa);
+void dump_lsm(int level, struct lov_stripe_md *lsm);
+int block_debug_setup(void *addr, int len, __u64 off, __u64 id);
+int block_debug_check(char *who, void *addr, int len, __u64 off, __u64 id);
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * (visit-tags-table FILE)
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+
+#ifndef _LUSTRE_DLM_H__
+#define _LUSTRE_DLM_H__
+
+#if defined(__linux__)
+#include <linux/lustre_dlm.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_dlm.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_dlm.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#include <lustre_lib.h>
+#include <lustre_net.h>
+#include <lustre_import.h>
+#include <lustre_handles.h>
+#include <lustre_export.h> /* for obd_export, for LDLM_DEBUG */
+
+struct obd_ops;
+struct obd_device;
+
+#define OBD_LDLM_DEVICENAME "ldlm"
+
+#define LDLM_DEFAULT_LRU_SIZE 100
+
+typedef enum {
+ ELDLM_OK = 0,
+
+ ELDLM_LOCK_CHANGED = 300,
+ ELDLM_LOCK_ABORTED = 301,
+ ELDLM_LOCK_REPLACED = 302,
+ ELDLM_NO_LOCK_DATA = 303,
+
+ ELDLM_NAMESPACE_EXISTS = 400,
+ ELDLM_BAD_NAMESPACE = 401
+} ldlm_error_t;
+
+#define LDLM_NAMESPACE_SERVER 0
+#define LDLM_NAMESPACE_CLIENT 1
+
+#define LDLM_FL_LOCK_CHANGED 0x000001 /* extent, mode, or resource changed */
+
+/* If the server returns one of these flags, then the lock was put on that list.
+ * If the client sends one of these flags (during recovery ONLY!), it wants the
+ * lock added to the specified list, no questions asked. -p */
+#define LDLM_FL_BLOCK_GRANTED 0x000002
+#define LDLM_FL_BLOCK_CONV 0x000004
+#define LDLM_FL_BLOCK_WAIT 0x000008
+
+#define LDLM_FL_CBPENDING 0x000010 /* this lock is being destroyed */
+#define LDLM_FL_AST_SENT 0x000020 /* blocking or cancel packet was sent */
+#define LDLM_FL_WAIT_NOREPROC 0x000040 /* not a real flag, not saved in lock */
+#define LDLM_FL_CANCEL 0x000080 /* cancellation callback already run */
+
+/* Lock is being replayed. This could probably be implied by the fact that one
+ * of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */
+#define LDLM_FL_REPLAY 0x000100
+
+#define LDLM_FL_INTENT_ONLY 0x000200 /* don't grant lock, just do intent */
+#define LDLM_FL_LOCAL_ONLY 0x000400 /* see ldlm_cli_cancel_unused */
+
+/* don't run the cancel callback under ldlm_cli_cancel_unused */
+#define LDLM_FL_FAILED 0x000800
+
+#define LDLM_FL_HAS_INTENT 0x001000 /* lock request has intent */
+#define LDLM_FL_CANCELING 0x002000 /* lock cancel has already been sent */
+#define LDLM_FL_LOCAL 0x004000 /* local lock (ie, no srv/cli split) */
+#define LDLM_FL_WARN 0x008000 /* see ldlm_cli_cancel_unused */
+#define LDLM_FL_DISCARD_DATA 0x010000 /* discard (no writeback) on cancel */
+
+#define LDLM_FL_NO_TIMEOUT 0x020000 /* Blocked by group lock - wait
+ * indefinitely */
+
+/* file & record locking */
+#define LDLM_FL_BLOCK_NOWAIT 0x040000 // server told not to wait if blocked
+#define LDLM_FL_TEST_LOCK 0x080000 // return blocking lock
+
+/* XXX FIXME: This is being added to b_size as a low-risk fix to the fact that
+ * the LVB filling happens _after_ the lock has been granted, so another thread
+ * can match before the LVB has been updated. As a dirty hack, we set
+ * LDLM_FL_CAN_MATCH only after we've done the LVB poop.
+ *
+ * The proper fix is to do the granting inside of the completion AST, which can
+ * be replaced with a LVB-aware wrapping function for OSC locks. That change is
+ * pretty high-risk, though, and would need a lot more testing. */
+#define LDLM_FL_CAN_MATCH 0x100000
+
+/* A lock contributes to the kms calculation until it has finished the part
+ * of it's cancelation that performs write back on its dirty pages. It
+ * can remain on the granted list during this whole time. Threads racing
+ * to update the kms after performing their writeback need to know to
+ * exclude each others locks from the calculation as they walk the granted
+ * list. */
+#define LDLM_FL_KMS_IGNORE 0x200000
+
+/* Don't drop lock covering mmapped file in LRU */
+#define LDLM_FL_NO_LRU 0x400000
+
+/* Immediatelly cancel such locks when they block some other locks. Send
+ cancel notification to original lock holder, but expect no reply. */
+#define LDLM_FL_CANCEL_ON_BLOCK 0x800000
+
+/* Flags flags inherited from parent lock when doing intents. */
+#define LDLM_INHERIT_FLAGS (LDLM_FL_CANCEL_ON_BLOCK)
+
+/* These are flags that are mapped into the flags and ASTs of blocking locks */
+#define LDLM_AST_DISCARD_DATA 0x80000000 /* Add FL_DISCARD to blocking ASTs */
+/* Flags sent in AST lock_flags to be mapped into the receiving lock. */
+#define LDLM_AST_FLAGS (LDLM_FL_DISCARD_DATA)
+
+/* The blocking callback is overloaded to perform two functions. These flags
+ * indicate which operation should be performed. */
+#define LDLM_CB_BLOCKING 1
+#define LDLM_CB_CANCELING 2
+
+/* compatibility matrix */
+#define LCK_COMPAT_EX LCK_NL
+#define LCK_COMPAT_PW (LCK_COMPAT_EX | LCK_CR)
+#define LCK_COMPAT_PR (LCK_COMPAT_PW | LCK_PR)
+#define LCK_COMPAT_CW (LCK_COMPAT_PW | LCK_CW)
+#define LCK_COMPAT_CR (LCK_COMPAT_CW | LCK_PR | LCK_PW)
+#define LCK_COMPAT_NL (LCK_COMPAT_CR | LCK_EX)
+#define LCK_COMPAT_GROUP (LCK_GROUP | LCK_NL)
+
+static ldlm_mode_t lck_compat_array[] = {
+ [LCK_EX] LCK_COMPAT_EX,
+ [LCK_PW] LCK_COMPAT_PW,
+ [LCK_PR] LCK_COMPAT_PR,
+ [LCK_CW] LCK_COMPAT_CW,
+ [LCK_CR] LCK_COMPAT_CR,
+ [LCK_NL] LCK_COMPAT_NL,
+ [LCK_GROUP] LCK_COMPAT_GROUP
+};
+
+static inline void lockmode_verify(ldlm_mode_t mode)
+{
+ LASSERT(mode > LCK_MINMODE && mode < LCK_MAXMODE);
+}
+
+static inline int lockmode_compat(ldlm_mode_t exist, ldlm_mode_t new)
+{
+ return (lck_compat_array[exist] & new);
+}
+
+/*
+ *
+ * cluster name spaces
+ *
+ */
+
+#define DLM_OST_NAMESPACE 1
+#define DLM_MDS_NAMESPACE 2
+
+/* XXX
+ - do we just separate this by security domains and use a prefix for
+ multiple namespaces in the same domain?
+ -
+*/
+
+struct ldlm_lock;
+struct ldlm_resource;
+struct ldlm_namespace;
+
+typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **,
+ void *req_cookie, ldlm_mode_t mode, int flags,
+ void *data);
+
+struct ldlm_valblock_ops {
+ int (*lvbo_init)(struct ldlm_resource *res);
+ int (*lvbo_update)(struct ldlm_resource *res, struct lustre_msg *m,
+ int buf_idx, int increase);
+};
+
+struct ldlm_namespace {
+ char *ns_name;
+ __u32 ns_client; /* is this a client-side lock tree? */
+ struct list_head *ns_hash; /* hash table for ns */
+ cfs_waitq_t ns_refcount_waitq; /* for cleanup */
+ atomic_t ns_refcount; /* count of resources in the hash */
+ struct list_head ns_root_list; /* all root resources in ns */
+ struct lustre_lock ns_lock; /* protects hash, refcount, list */
+ struct list_head ns_list_chain; /* position in global NS list */
+
+ struct list_head ns_unused_list; /* all root resources in ns */
+ int ns_nr_unused;
+ unsigned int ns_max_unused;
+ cfs_time_t ns_next_dump; /* next debug dump, jiffies */
+
+ spinlock_t ns_counter_lock;
+ __u64 ns_locks;
+ ldlm_res_policy ns_policy;
+ struct ldlm_valblock_ops *ns_lvbo;
+ void *ns_lvbp;
+};
+
+/*
+ *
+ * Resource hash table
+ *
+ */
+
+#define RES_HASH_BITS 10
+#define RES_HASH_SIZE (1UL << RES_HASH_BITS)
+#define RES_HASH_MASK (RES_HASH_SIZE - 1)
+
+struct ldlm_lock;
+
+typedef int (*ldlm_blocking_callback)(struct ldlm_lock *lock,
+ struct ldlm_lock_desc *new, void *data,
+ int flag);
+typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags,
+ void *data);
+typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);
+
+struct ldlm_lock {
+ struct portals_handle l_handle; // must be first in the structure
+ atomic_t l_refc;
+ struct ldlm_resource *l_resource;
+ struct ldlm_lock *l_parent;
+ struct list_head l_children;
+ struct list_head l_childof;
+ struct list_head l_lru;
+ struct list_head l_res_link; // position in one of three res lists
+ struct list_head l_export_chain; // per-export chain of locks
+
+ ldlm_mode_t l_req_mode;
+ ldlm_mode_t l_granted_mode;
+
+ ldlm_completion_callback l_completion_ast;
+ ldlm_blocking_callback l_blocking_ast;
+ ldlm_glimpse_callback l_glimpse_ast;
+
+ struct obd_export *l_export;
+ struct obd_export *l_conn_export;
+ __u32 l_flags;
+ struct lustre_handle l_remote_handle;
+ ldlm_policy_data_t l_policy_data;
+
+ __u32 l_readers;
+ __u32 l_writers;
+ __u8 l_destroyed;
+
+ /* If the lock is granted, a process sleeps on this waitq to learn when
+ * it's no longer in use. If the lock is not granted, a process sleeps
+ * on this waitq to learn when it becomes granted. */
+ cfs_waitq_t l_waitq;
+ struct timeval l_enqueued_time;
+
+ unsigned long l_last_used; /* jiffies */
+ struct ldlm_extent l_req_extent;
+
+ /* Client-side-only members */
+ __u32 l_lvb_len; /* temporary storage for */
+ void *l_lvb_data; /* an LVB received during */
+ void *l_lvb_swabber; /* an enqueue */
+ void *l_ast_data;
+
+ /* Server-side-only members */
+ struct list_head l_pending_chain; /* callbacks pending */
+ cfs_time_t l_callback_timeout; /* jiffies */
+
+ __u32 l_pid; /* pid which created this lock */
+};
+
+struct ldlm_resource {
+ struct ldlm_namespace *lr_namespace;
+ struct list_head lr_hash;
+ struct ldlm_resource *lr_parent; /* 0 for a root resource */
+ struct list_head lr_children; /* list head for child resources */
+ struct list_head lr_childof; /* part of ns_root_list if root res,
+ * part of lr_children if child */
+
+ struct list_head lr_granted;
+ struct list_head lr_converting;
+ struct list_head lr_waiting;
+ ldlm_mode_t lr_most_restr;
+ ldlm_type_t lr_type; /* LDLM_{PLAIN,EXTENT,FLOCK} */
+ struct ldlm_resource *lr_root;
+ struct ldlm_res_id lr_name;
+ atomic_t lr_refcount;
+
+ /* Server-side-only lock value block elements */
+ struct semaphore lr_lvb_sem;
+ __u32 lr_lvb_len;
+ void *lr_lvb_data;
+
+ /* lr_tmp holds a list head temporarily, during the building of a work
+ * queue. see ldlm_add_ast_work_item and ldlm_run_ast_work */
+ void *lr_tmp;
+};
+
+struct ldlm_ast_work {
+ struct ldlm_lock *w_lock;
+ int w_blocking;
+ struct ldlm_lock_desc w_desc;
+ struct list_head w_list;
+ int w_flags;
+ void *w_data;
+ int w_datalen;
+};
+
+extern struct obd_ops ldlm_obd_ops;
+
+extern char *ldlm_lockname[];
+extern char *ldlm_typename[];
+extern char *ldlm_it2str(int it);
+
+#define __LDLM_DEBUG(level, lock, format, a...) \
+do { \
+ if (lock->l_resource == NULL) { \
+ CDEBUG(level, "### " format \
+ " ns: \?\? lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s "\
+ "res: \?\? rrc=\?\? type: \?\?\? flags: %x remote: " \
+ LPX64" expref: %d pid: %u\n" , ## a, lock, \
+ lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
+ lock->l_readers, lock->l_writers, \
+ ldlm_lockname[lock->l_granted_mode], \
+ ldlm_lockname[lock->l_req_mode], \
+ lock->l_flags, lock->l_remote_handle.cookie, \
+ lock->l_export ? \
+ atomic_read(&lock->l_export->exp_refcount) : -99, \
+ lock->l_pid); \
+ break; \
+ } \
+ if (lock->l_resource->lr_type == LDLM_EXTENT) { \
+ CDEBUG(level, "### " format \
+ " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
+ "res: "LPU64"/"LPU64" rrc: %d type: %s ["LPU64"->"LPU64\
+ "] (req "LPU64"->"LPU64") flags: %x remote: "LPX64 \
+ " expref: %d pid: %u\n" , ## a, \
+ lock->l_resource->lr_namespace->ns_name, lock, \
+ lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
+ lock->l_readers, lock->l_writers, \
+ ldlm_lockname[lock->l_granted_mode], \
+ ldlm_lockname[lock->l_req_mode], \
+ lock->l_resource->lr_name.name[0], \
+ lock->l_resource->lr_name.name[1], \
+ atomic_read(&lock->l_resource->lr_refcount), \
+ ldlm_typename[lock->l_resource->lr_type], \
+ lock->l_policy_data.l_extent.start, \
+ lock->l_policy_data.l_extent.end, \
+ lock->l_req_extent.start, lock->l_req_extent.end, \
+ lock->l_flags, lock->l_remote_handle.cookie, \
+ lock->l_export ? \
+ atomic_read(&lock->l_export->exp_refcount) : -99, \
+ lock->l_pid); \
+ break; \
+ } \
+ if (lock->l_resource->lr_type == LDLM_FLOCK) { \
+ CDEBUG(level, "### " format \
+ " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
+ "res: "LPU64"/"LPU64" rrc: %d type: %s pid: %d " \
+ "["LPU64"->"LPU64"] flags: %x remote: "LPX64 \
+ " expref: %d pid: %u\n" , ## a, \
+ lock->l_resource->lr_namespace->ns_name, lock, \
+ lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \
+ lock->l_readers, lock->l_writers, \
+ ldlm_lockname[lock->l_granted_mode], \
+ ldlm_lockname[lock->l_req_mode], \
+ lock->l_resource->lr_name.name[0], \
+ lock->l_resource->lr_name.name[1], \
+ atomic_read(&lock->l_resource->lr_refcount), \
+ ldlm_typename[lock->l_resource->lr_type], \
+ lock->l_policy_data.l_flock.pid, \
+ lock->l_policy_data.l_flock.start, \
+ lock->l_policy_data.l_flock.end, \
+ lock->l_flags, lock->l_remote_handle.cookie, \
+ lock->l_export ? \
+ atomic_read(&lock->l_export->exp_refcount) : -99, \
+ lock->l_pid); \
+ break; \
+ } \
+ if (lock->l_resource->lr_type == LDLM_IBITS) { \
+ CDEBUG(level, "### " format \
+ " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
+ "res: "LPU64"/"LPU64" bits "LPX64" rrc: %d type: %s " \
+ "flags: %x remote: "LPX64" expref: %d " \
+ "pid %u\n" , ## a, \
+ lock->l_resource->lr_namespace->ns_name, \
+ lock, lock->l_handle.h_cookie, \
+ atomic_read (&lock->l_refc), \
+ lock->l_readers, lock->l_writers, \
+ ldlm_lockname[lock->l_granted_mode], \
+ ldlm_lockname[lock->l_req_mode], \
+ lock->l_resource->lr_name.name[0], \
+ lock->l_resource->lr_name.name[1], \
+ lock->l_policy_data.l_inodebits.bits, \
+ atomic_read(&lock->l_resource->lr_refcount), \
+ ldlm_typename[lock->l_resource->lr_type], \
+ lock->l_flags, lock->l_remote_handle.cookie, \
+ lock->l_export ? \
+ atomic_read(&lock->l_export->exp_refcount) : -99, \
+ lock->l_pid); \
+ break; \
+ } \
+ { \
+ CDEBUG(level, "### " format \
+ " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \
+ "res: "LPU64"/"LPU64" rrc: %d type: %s flags: %x " \
+ "remote: "LPX64" expref: %d pid: %u\n" , ## a, \
+ lock->l_resource->lr_namespace->ns_name, \
+ lock, lock->l_handle.h_cookie, \
+ atomic_read (&lock->l_refc), \
+ lock->l_readers, lock->l_writers, \
+ ldlm_lockname[lock->l_granted_mode], \
+ ldlm_lockname[lock->l_req_mode], \
+ lock->l_resource->lr_name.name[0], \
+ lock->l_resource->lr_name.name[1], \
+ atomic_read(&lock->l_resource->lr_refcount), \
+ ldlm_typename[lock->l_resource->lr_type], \
+ lock->l_flags, lock->l_remote_handle.cookie, \
+ lock->l_export ? \
+ atomic_read(&lock->l_export->exp_refcount) : -99, \
+ lock->l_pid); \
+ } \
+} while (0)
+
+#define LDLM_DEBUG(lock, format, a...) __LDLM_DEBUG(D_DLMTRACE, lock, \
+ format, ## a)
+#define LDLM_ERROR(lock, format, a...) __LDLM_DEBUG(D_ERROR, lock, format, ## a)
+
+#define LDLM_DEBUG_NOLOCK(format, a...) \
+ CDEBUG(D_DLMTRACE, "### " format "\n" , ## a)
+
+typedef int (*ldlm_processing_policy)(struct ldlm_lock *lock, int *flags,
+ int first_enq, ldlm_error_t *err);
+
+/*
+ * Iterators.
+ */
+
+#define LDLM_ITER_CONTINUE 1 /* keep iterating */
+#define LDLM_ITER_STOP 2 /* stop iterating */
+
+typedef int (*ldlm_iterator_t)(struct ldlm_lock *, void *);
+typedef int (*ldlm_res_iterator_t)(struct ldlm_resource *, void *);
+
+int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
+ void *closure);
+int ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter,
+ void *closure);
+int ldlm_namespace_foreach_res(struct ldlm_namespace *ns,
+ ldlm_res_iterator_t iter, void *closure);
+
+int ldlm_replay_locks(struct obd_import *imp);
+void ldlm_change_cbdata(struct ldlm_namespace *, struct ldlm_res_id *,
+ ldlm_iterator_t iter, void *data);
+
+/* ldlm_flock.c */
+int ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data);
+
+/* ldlm_extent.c */
+__u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms);
+
+
+/* ldlm_lockd.c */
+int ldlm_server_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
+ void *data, int flag);
+int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data);
+int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data);
+int ldlm_handle_enqueue(struct ptlrpc_request *req, ldlm_completion_callback,
+ ldlm_blocking_callback, ldlm_glimpse_callback);
+int ldlm_handle_convert(struct ptlrpc_request *req);
+int ldlm_handle_cancel(struct ptlrpc_request *req);
+int ldlm_del_waiting_lock(struct ldlm_lock *lock);
+int ldlm_get_ref(void);
+void ldlm_put_ref(int force);
+
+/* ldlm_lock.c */
+ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res);
+void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg);
+void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh);
+struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *, int flags);
+void ldlm_cancel_callback(struct ldlm_lock *);
+int ldlm_lock_set_data(struct lustre_handle *, void *data);
+void ldlm_lock_remove_from_lru(struct ldlm_lock *);
+struct ldlm_lock *ldlm_handle2lock_ns(struct ldlm_namespace *,
+ struct lustre_handle *);
+
+static inline struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *h)
+{
+ return __ldlm_handle2lock(h, 0);
+}
+
+#define LDLM_LOCK_PUT(lock) \
+do { \
+ /*LDLM_DEBUG((lock), "put");*/ \
+ ldlm_lock_put(lock); \
+} while (0)
+
+#define LDLM_LOCK_GET(lock) \
+({ \
+ ldlm_lock_get(lock); \
+ /*LDLM_DEBUG((lock), "get");*/ \
+ lock; \
+})
+
+struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
+void ldlm_lock_put(struct ldlm_lock *lock);
+void ldlm_lock_destroy(struct ldlm_lock *lock);
+void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc);
+void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode);
+void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode);
+void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode);
+void ldlm_lock_allow_match(struct ldlm_lock *lock);
+int ldlm_lock_match(struct ldlm_namespace *ns, int flags, struct ldlm_res_id *,
+ __u32 type, ldlm_policy_data_t *, ldlm_mode_t mode,
+ struct lustre_handle *);
+struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
+ int *flags);
+void ldlm_lock_cancel(struct ldlm_lock *lock);
+void ldlm_cancel_locks_for_export(struct obd_export *export);
+void ldlm_reprocess_all(struct ldlm_resource *res);
+void ldlm_reprocess_all_ns(struct ldlm_namespace *ns);
+void ldlm_lock_dump(int level, struct ldlm_lock *lock, int pos);
+void ldlm_lock_dump_handle(int level, struct lustre_handle *);
+
+/* resource.c */
+struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 local);
+int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int flags);
+int ldlm_namespace_free(struct ldlm_namespace *ns, int force);
+int ldlm_proc_setup(void);
+#ifdef LPROCFS
+void ldlm_proc_cleanup(void);
+#else
+static inline void ldlm_proc_cleanup(void) {}
+#endif
+
+/* resource.c - internal */
+struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
+ struct ldlm_resource *parent,
+ struct ldlm_res_id, __u32 type,
+ int create);
+struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res);
+int ldlm_resource_putref(struct ldlm_resource *res);
+void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head,
+ struct ldlm_lock *lock);
+void ldlm_resource_unlink_lock(struct ldlm_lock *lock);
+void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc);
+void ldlm_dump_all_namespaces(int level);
+void ldlm_namespace_dump(int level, struct ldlm_namespace *);
+void ldlm_resource_dump(int level, struct ldlm_resource *);
+int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
+ struct ldlm_res_id);
+
+/* ldlm_request.c */
+int ldlm_expired_completion_wait(void *data);
+int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
+ void *data, int flag);
+int ldlm_glimpse_ast(struct ldlm_lock *lock, void *reqp);
+int ldlm_completion_ast(struct ldlm_lock *lock, int flags, void *data);
+int ldlm_cli_enqueue(struct obd_export *exp,
+ struct ptlrpc_request *req,
+ struct ldlm_namespace *ns,
+ struct ldlm_res_id,
+ __u32 type,
+ ldlm_policy_data_t *,
+ ldlm_mode_t mode,
+ int *flags,
+ ldlm_blocking_callback blocking,
+ ldlm_completion_callback completion,
+ ldlm_glimpse_callback glimpse,
+ void *data,
+ void *lvb,
+ __u32 lvb_len,
+ void *lvb_swabber,
+ struct lustre_handle *lockh);
+int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new,
+ void *data, __u32 data_len);
+int ldlm_cli_convert(struct lustre_handle *, int new_mode, int *flags);
+int ldlm_cli_cancel(struct lustre_handle *lockh);
+int ldlm_cli_cancel_unused(struct ldlm_namespace *, struct ldlm_res_id *,
+ int flags, void *opaque);
+int ldlm_cli_join_lru(struct ldlm_namespace *, struct ldlm_res_id *,
+ int join);
+
+/* mds/handler.c */
+/* This has to be here because recursive inclusion sucks. */
+int intent_disposition(struct ldlm_reply *rep, int flag);
+void intent_set_disposition(struct ldlm_reply *rep, int flag);
+
+
+/* ioctls for trying requests */
+#define IOC_LDLM_TYPE 'f'
+#define IOC_LDLM_MIN_NR 40
+
+#define IOC_LDLM_TEST _IOWR('f', 40, long)
+#define IOC_LDLM_DUMP _IOWR('f', 41, long)
+#define IOC_LDLM_REGRESS_START _IOWR('f', 42, long)
+#define IOC_LDLM_REGRESS_STOP _IOWR('f', 43, long)
+#define IOC_LDLM_MAX_NR 43
+
+#endif
#ifndef __EXPORT_H
#define __EXPORT_H
-#include <linux/lustre_idl.h>
-#include <linux/lustre_dlm.h>
+#include <lustre_idl.h>
+#include <lustre_dlm.h>
struct mds_client_data;
struct obd_device *oscc_obd;
int oscc_flags;
obd_id oscc_next_id;
- wait_queue_head_t oscc_waitq;
+ cfs_waitq_t oscc_waitq;
};
struct ldlm_export_data {
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001-2004 Cluster File Systems, Inc. <info@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Filesystem interface helper.
+ *
+ */
+
+#ifndef _LUSTRE_FSFILT_H
+#define _LUSTRE_FSFILT_H
+
+#if defined(__linux__)
+#include <linux/lustre_fsfilt.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_fsfilt.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_fsfilt.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#endif
--- /dev/null
+#ifndef __LUSTRE_HANDLES_H_
+#define __LUSTRE_HANDLES_H_
+
+#if defined(__linux__)
+#include <linux/lustre_handles.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_handles.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_handles.h>
+#else
+#error Unsupported operating system.
+#endif
+
+typedef void (*portals_handle_addref_cb)(void *object);
+
+/* These handles are most easily used by having them appear at the very top of
+ * whatever object that you want to make handles for. ie:
+ *
+ * struct ldlm_lock {
+ * struct portals_handle handle;
+ * ...
+ * };
+ *
+ * Now you're able to assign the results of cookie2handle directly to an
+ * ldlm_lock. If it's not at the top, you'll want to hack up a macro that
+ * uses some offsetof() magic. */
+
+struct portals_handle {
+ struct list_head h_link;
+ __u64 h_cookie;
+ portals_handle_addref_cb h_addref;
+};
+
+/* handles.c */
+
+/* Add a handle to the hash table */
+void class_handle_hash(struct portals_handle *, portals_handle_addref_cb);
+void class_handle_unhash(struct portals_handle *);
+void *class_handle2object(__u64 cookie);
+int class_handle_init(void);
+void class_handle_cleanup(void);
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * This file is part of Lustre, http://www.lustre.org
+ *
+ * Lustre wire protocol definitions.
+ *
+ * All structs passing over the wire should be declared here (lov_mds_md
+ * being the lone exception). Structs must be properly aligned to put
+ * 64-bit values on an 8-byte boundary. Any structs being added here
+ * must also be added to utils/wirecheck.c and "make newwiretest" run
+ * to regenerate the utils/wiretest.c sources. This allows us to verify
+ * that wire structs have the proper alignment/size on all architectures.
+ *
+ * We assume all nodes are either little-endian or big-endian, and we
+ * always send messages in the sender's native format. The receiver
+ * detects the message format by checking the 'magic' field of the message
+ * (see lustre_msg_swabbed() below).
+ *
+ * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines,
+ * implemented either here, inline (trivial implementations) or in
+ * ptlrpc/pack_generic.c. These 'swabbers' convert the type from "other"
+ * endian, in-place in the message buffer.
+ *
+ * A swabber takes a single pointer argument. The caller must already have
+ * verified that the length of the message buffer >= sizeof (type).
+ *
+ * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine
+ * may be defined that swabs just the variable part, after the caller has
+ * verified that the message buffer is large enough.
+ */
+
+#ifndef _LUSTRE_IDL_H_
+#define _LUSTRE_IDL_H_
+
+#if defined(__linux__)
+#include <linux/lustre_idl.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_idl.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_idl.h>
+#else
+#error Unsupported operating system.
+#endif
+
+/* Defn's shared with user-space. */
+#include <lustre/lustre_user.h>
+
+/*
+ * this file contains all data structures used in Lustre interfaces:
+ * - obdo and obd_request records
+ * - mds_request records
+ * - ldlm data
+ * - ioctl's
+ */
+
+/*
+ * GENERAL STUFF
+ */
+/* FOO_REQUEST_PORTAL is for incoming requests on the FOO
+ * FOO_REPLY_PORTAL is for incoming replies on the FOO
+ * FOO_BULK_PORTAL is for incoming bulk on the FOO
+ */
+
+#define CONNMGR_REQUEST_PORTAL 1
+#define CONNMGR_REPLY_PORTAL 2
+//#define OSC_REQUEST_PORTAL 3
+#define OSC_REPLY_PORTAL 4
+//#define OSC_BULK_PORTAL 5
+#define OST_REQUEST_PORTAL 6
+#define OST_CREATE_PORTAL 7
+#define OST_BULK_PORTAL 8
+//#define MDC_REQUEST_PORTAL 9
+#define MDC_REPLY_PORTAL 10
+//#define MDC_BULK_PORTAL 11
+#define MDS_REQUEST_PORTAL 12
+//#define MDS_REPLY_PORTAL 13
+#define MDS_BULK_PORTAL 14
+#define LDLM_CB_REQUEST_PORTAL 15
+#define LDLM_CB_REPLY_PORTAL 16
+#define LDLM_CANCEL_REQUEST_PORTAL 17
+#define LDLM_CANCEL_REPLY_PORTAL 18
+#define PTLBD_REQUEST_PORTAL 19
+#define PTLBD_REPLY_PORTAL 20
+#define PTLBD_BULK_PORTAL 21
+#define MDS_SETATTR_PORTAL 22
+#define MDS_READPAGE_PORTAL 23
+#define MGMT_REQUEST_PORTAL 24
+#define MGMT_REPLY_PORTAL 25
+#define MGMT_CLI_REQUEST_PORTAL 26
+#define MGMT_CLI_REPLY_PORTAL 27
+
+#define SVC_KILLED 1
+#define SVC_EVENT 2
+#define SVC_SIGNAL 4
+#define SVC_RUNNING 8
+#define SVC_STOPPING 16
+#define SVC_STOPPED 32
+
+/* packet types */
+#define PTL_RPC_MSG_REQUEST 4711
+#define PTL_RPC_MSG_ERR 4712
+#define PTL_RPC_MSG_REPLY 4713
+
+#define PTLRPC_MSG_MAGIC 0x0BD00BD0
+
+
+#define PTLRPC_MSG_VERSION 0x00000003
+#define LUSTRE_VERSION_MASK 0xffff0000
+#define LUSTRE_OBD_VERSION 0x00010000
+#define LUSTRE_MDS_VERSION 0x00020000
+#define LUSTRE_OST_VERSION 0x00030000
+#define LUSTRE_DLM_VERSION 0x00040000
+#define LUSTRE_LOG_VERSION 0x00050000
+#define LUSTRE_PBD_VERSION 0x00060000
+
+struct lustre_handle {
+ __u64 cookie;
+};
+#define DEAD_HANDLE_MAGIC 0xdeadbeefcafebabeULL
+
+/* we depend on this structure to be 8-byte aligned */
+/* this type is only endian-adjusted in lustre_unpack_msg() */
+struct lustre_msg {
+ struct lustre_handle handle;
+ __u32 magic;
+ __u32 type;
+ __u32 version;
+ __u32 opc;
+ __u64 last_xid;
+ __u64 last_committed;
+ __u64 transno;
+ __u32 status;
+ __u32 flags;
+ __u32 conn_cnt;
+ __u32 bufcount;
+ __u32 buflens[0];
+};
+
+/* Flags that are operation-specific go in the top 16 bits. */
+#define MSG_OP_FLAG_MASK 0xffff0000
+#define MSG_OP_FLAG_SHIFT 16
+
+/* Flags that apply to all requests are in the bottom 16 bits */
+#define MSG_GEN_FLAG_MASK 0x0000ffff
+#define MSG_LAST_REPLAY 1
+#define MSG_RESENT 2
+#define MSG_REPLAY 4
+
+static inline int lustre_msg_get_flags(struct lustre_msg *msg)
+{
+ return (msg->flags & MSG_GEN_FLAG_MASK);
+}
+
+static inline void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
+{
+ msg->flags |= MSG_GEN_FLAG_MASK & flags;
+}
+
+static inline void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
+{
+ msg->flags &= ~MSG_GEN_FLAG_MASK;
+ lustre_msg_add_flags(msg, flags);
+}
+
+static inline void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
+{
+ msg->flags &= ~(MSG_GEN_FLAG_MASK & flags);
+}
+
+static inline int lustre_msg_get_op_flags(struct lustre_msg *msg)
+{
+ return (msg->flags >> MSG_OP_FLAG_SHIFT);
+}
+
+static inline void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
+{
+ msg->flags |= ((flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT);
+}
+
+static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
+{
+ msg->flags &= ~MSG_OP_FLAG_MASK;
+ lustre_msg_add_op_flags(msg, flags);
+}
+
+/*
+ * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
+ */
+
+#define MSG_CONNECT_RECOVERING 0x1
+#define MSG_CONNECT_RECONNECT 0x2
+#define MSG_CONNECT_REPLAYABLE 0x4
+//#define MSG_CONNECT_PEER 0x8
+#define MSG_CONNECT_LIBCLIENT 0x10
+#define MSG_CONNECT_INITIAL 0x20
+#define MSG_CONNECT_ASYNC 0x40
+
+/* Connect flags */
+#define OBD_CONNECT_RDONLY 0x0001ULL
+#define OBD_CONNECT_SRVLOCK 0x0010ULL /* server takes locks for client */
+#define OBD_CONNECT_ACL 0x0080ULL
+#define OBD_CONNECT_USER_XATTR 0x0100ULL
+#define OBD_CONNECT_CROW 0x0200ULL /* OST is CROW able */
+
+#define MDS_CONNECT_SUPPORTED (OBD_CONNECT_RDONLY | \
+ OBD_CONNECT_ACL | \
+ OBD_CONNECT_USER_XATTR)
+#define OST_CONNECT_SUPPORTED (OBD_CONNECT_SRVLOCK | OBD_CONNECT_CROW)
+#define ECHO_CONNECT_SUPPORTED (0)
+
+/* This structure is used for both request and reply.
+ *
+ * If we eventually have separate connect data for different types, which we
+ * almost certainly will, then perhaps we stick a union in here. */
+struct obd_connect_data {
+ __u64 ocd_connect_flags; /* connection flags, server should return
+ * subset of what is asked for. */
+
+ __u64 padding[8];
+};
+
+extern void lustre_swab_connect(struct obd_connect_data *ocd);
+
+/*
+ * OST requests: OBDO & OBD request records
+ */
+
+/* opcodes */
+typedef enum {
+ OST_REPLY = 0, /* reply ? */
+ OST_GETATTR = 1,
+ OST_SETATTR = 2,
+ OST_READ = 3,
+ OST_WRITE = 4,
+ OST_CREATE = 5,
+ OST_DESTROY = 6,
+ OST_GET_INFO = 7,
+ OST_CONNECT = 8,
+ OST_DISCONNECT = 9,
+ OST_PUNCH = 10,
+ OST_OPEN = 11,
+ OST_CLOSE = 12,
+ OST_STATFS = 13,
+ OST_SAN_READ = 14,
+ OST_SAN_WRITE = 15,
+ OST_SYNC = 16,
+ OST_SET_INFO = 17,
+ OST_QUOTACHECK = 18,
+ OST_QUOTACTL = 19,
+ OST_LAST_OPC
+} ost_cmd_t;
+#define OST_FIRST_OPC OST_REPLY
+
+typedef uint64_t obd_id;
+typedef uint64_t obd_gr;
+typedef uint64_t obd_time;
+typedef uint64_t obd_size;
+typedef uint64_t obd_off;
+typedef uint64_t obd_blocks;
+typedef uint32_t obd_blksize;
+typedef uint32_t obd_mode;
+typedef uint32_t obd_uid;
+typedef uint32_t obd_gid;
+typedef uint32_t obd_flag;
+typedef uint64_t obd_valid;
+typedef uint32_t obd_count;
+
+#define OBD_FL_INLINEDATA (0x00000001)
+#define OBD_FL_OBDMDEXISTS (0x00000002)
+#define OBD_FL_DELORPHAN (0x00000004) /* if set in o_flags delete orphans */
+#define OBD_FL_NORPC (0x00000008) /* set in o_flags do in OSC not OST */
+#define OBD_FL_IDONLY (0x00000010) /* set in o_flags only adjust obj id*/
+#define OBD_FL_RECREATE_OBJS (0x00000020) /* recreate missing obj */
+#define OBD_FL_DEBUG_CHECK (0x00000040) /* echo client/server debug check */
+#define OBD_FL_NO_USRQUOTA (0x00000100) /* the object's owner is over quota */
+#define OBD_FL_NO_GRPQUOTA (0x00000200) /* the object's group is over quota */
+#define OBD_FL_CREATE_CROW (0x00000400) /* object should be created with crow */
+
+/* this should be not smaller than sizeof(struct lustre_handle) + sizeof(struct
+ * llog_cookie) + sizeof(ll_fid). Nevertheless struct ll_fid is not longer
+ * stored in o_inline, we keep this just for case. */
+#define OBD_INLINESZ 80
+
+/* Note: 64-bit types are 64-bit aligned in structure */
+struct obdo {
+ obd_valid o_valid; /* hot fields in this obdo */
+ obd_id o_id;
+ obd_gr o_gr;
+ obd_id o_fid;
+ obd_size o_size; /* o_size-o_blocks == ost_lvb */
+ obd_time o_mtime;
+ obd_time o_atime;
+ obd_time o_ctime;
+ obd_blocks o_blocks; /* brw: cli sent cached bytes */
+ obd_size o_grant;
+
+ /* 32-bit fields start here: keep an even number of them via padding */
+ obd_blksize o_blksize; /* optimal IO blocksize */
+ obd_mode o_mode; /* brw: cli sent cache remain */
+ obd_uid o_uid;
+ obd_gid o_gid;
+ obd_flag o_flags;
+ obd_count o_nlink; /* brw: checksum */
+ obd_count o_generation;
+ obd_count o_misc; /* brw: o_dropped */
+ __u32 o_easize; /* epoch in ost writes */
+ __u32 o_mds;
+ __u32 o_stripe_idx; /* holds stripe idx */
+ __u32 o_padding_1;
+ char o_inline[OBD_INLINESZ]; /* fid in ost writes */
+};
+
+#define o_dirty o_blocks
+#define o_undirty o_mode
+#define o_dropped o_misc
+#define o_cksum o_nlink
+
+#define OBDO_URGENT_CREATE(oa) \
+ (!((oa)->o_valid & OBD_MD_FLFLAGS) || \
+ !((oa)->o_flags & OBD_FL_CREATE_CROW) || \
+ ((oa)->o_flags & OBD_FL_RECREATE_OBJS))
+
+extern void lustre_swab_obdo (struct obdo *o);
+
+#define LOV_MAGIC_V1 0x0BD10BD0
+#define LOV_MAGIC LOV_MAGIC_V1
+
+#define LOV_PATTERN_RAID0 0x001 /* stripes are used round-robin */
+#define LOV_PATTERN_RAID1 0x002 /* stripes are mirrors of each other */
+#define LOV_PATTERN_FIRST 0x100 /* first stripe is not in round-robin */
+#define LOV_PATTERN_CMOBD 0x200
+
+#define lov_ost_data lov_ost_data_v1
+struct lov_ost_data_v1 { /* per-stripe data structure (little-endian)*/
+ __u64 l_object_id; /* OST object ID */
+ __u64 l_object_gr; /* OST object group (creating MDS number) */
+ __u32 l_ost_gen; /* generation of this l_ost_idx */
+ __u32 l_ost_idx; /* OST index in LOV (lov_tgt_desc->tgts) */
+};
+
+#define lov_mds_md lov_mds_md_v1
+struct lov_mds_md_v1 { /* LOV EA mds/wire data (little-endian) */
+ __u32 lmm_magic; /* magic number = LOV_MAGIC_V1 */
+ __u32 lmm_pattern; /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
+ __u64 lmm_object_id; /* LOV object ID */
+ __u64 lmm_object_gr; /* LOV object group */
+ __u32 lmm_stripe_size; /* size of stripe in bytes */
+ __u32 lmm_stripe_count; /* num stripes in use for this object */
+ struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
+};
+
+#define OBD_MD_FLID (0x00000001ULL) /* object ID */
+#define OBD_MD_FLATIME (0x00000002ULL) /* access time */
+#define OBD_MD_FLMTIME (0x00000004ULL) /* data modification time */
+#define OBD_MD_FLCTIME (0x00000008ULL) /* change time */
+#define OBD_MD_FLSIZE (0x00000010ULL) /* size */
+#define OBD_MD_FLBLOCKS (0x00000020ULL) /* allocated blocks count */
+#define OBD_MD_FLBLKSZ (0x00000040ULL) /* block size */
+#define OBD_MD_FLMODE (0x00000080ULL) /* access bits (mode & ~S_IFMT) */
+#define OBD_MD_FLTYPE (0x00000100ULL) /* object type (mode & S_IFMT) */
+#define OBD_MD_FLUID (0x00000200ULL) /* user ID */
+#define OBD_MD_FLGID (0x00000400ULL) /* group ID */
+#define OBD_MD_FLFLAGS (0x00000800ULL) /* flags word */
+#define OBD_MD_FLNLINK (0x00002000ULL) /* link count */
+#define OBD_MD_FLGENER (0x00004000ULL) /* generation number */
+#define OBD_MD_FLINLINE (0x00008000ULL) /* inline data */
+#define OBD_MD_FLRDEV (0x00010000ULL) /* device number */
+#define OBD_MD_FLEASIZE (0x00020000ULL) /* extended attribute data */
+#define OBD_MD_LINKNAME (0x00040000ULL) /* symbolic link target */
+#define OBD_MD_FLHANDLE (0x00080000ULL) /* file handle */
+#define OBD_MD_FLCKSUM (0x00100000ULL) /* bulk data checksum */
+#define OBD_MD_FLQOS (0x00200000ULL) /* quality of service stats */
+#define OBD_MD_FLOSCOPQ (0x00400000ULL) /* osc opaque data */
+#define OBD_MD_FLCOOKIE (0x00800000ULL) /* log cancellation cookie */
+#define OBD_MD_FLGROUP (0x01000000ULL) /* group */
+#define OBD_MD_FLFID (0x02000000ULL) /* ->ost write inline fid */
+#define OBD_MD_FLEPOCH (0x04000000ULL) /* ->ost write easize is epoch */
+#define OBD_MD_FLGRANT (0x08000000ULL) /* ost preallocation space grant */
+#define OBD_MD_FLDIREA (0x10000000ULL) /* dir's extended attribute data */
+#define OBD_MD_FLUSRQUOTA (0x20000000ULL) /* over quota flags sent from ost */
+#define OBD_MD_FLGRPQUOTA (0x40000000ULL) /* over quota flags sent from ost */
+
+#define OBD_MD_MDS (0x0000000100000000ULL) /* where an inode lives on */
+#define OBD_MD_REINT (0x0000000200000000ULL) /* reintegrate oa */
+
+#define OBD_MD_FLXATTR (0x0000001000000000ULL) /* xattr */
+#define OBD_MD_FLXATTRLS (0x0000002000000000ULL) /* xattr list */
+#define OBD_MD_FLXATTRRM (0x0000004000000000ULL) /* xattr remove */
+#define OBD_MD_FLACL (0x0000008000000000ULL) /* ACL */
+
+#define OBD_MD_FLGETATTR (OBD_MD_FLID | OBD_MD_FLATIME | OBD_MD_FLMTIME | \
+ OBD_MD_FLCTIME | OBD_MD_FLSIZE | OBD_MD_FLBLKSZ | \
+ OBD_MD_FLMODE | OBD_MD_FLTYPE | OBD_MD_FLUID | \
+ OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \
+ OBD_MD_FLGENER | OBD_MD_FLRDEV | OBD_MD_FLGROUP)
+
+static inline struct lustre_handle *obdo_handle(struct obdo *oa)
+{
+ return (struct lustre_handle *)oa->o_inline;
+}
+
+static inline struct llog_cookie *obdo_logcookie(struct obdo *oa)
+{
+ return (struct llog_cookie *)(oa->o_inline +
+ sizeof(struct lustre_handle));
+}
+/* don't forget obdo_fid which is way down at the bottom so it can
+ * come after the definition of llog_cookie */
+
+struct obd_statfs {
+ __u64 os_type;
+ __u64 os_blocks;
+ __u64 os_bfree;
+ __u64 os_bavail;
+ __u64 os_files;
+ __u64 os_ffree;
+ __u8 os_fsid[40];
+ __u32 os_bsize;
+ __u32 os_namelen;
+ __u64 os_maxbytes;
+ __u32 os_state;
+ __u32 os_spare1;
+ __u32 os_spare2;
+ __u32 os_spare3;
+ __u32 os_spare4;
+ __u32 os_spare5;
+ __u32 os_spare6;
+ __u32 os_spare7;
+ __u32 os_spare8;
+ __u32 os_spare9;
+};
+
+extern void lustre_swab_obd_statfs (struct obd_statfs *os);
+
+/* ost_body.data values for OST_BRW */
+
+#define OBD_BRW_READ 0x01
+#define OBD_BRW_WRITE 0x02
+#define OBD_BRW_RWMASK (OBD_BRW_READ | OBD_BRW_WRITE)
+#define OBD_BRW_SYNC 0x08
+#define OBD_BRW_CHECK 0x10
+#define OBD_BRW_FROM_GRANT 0x20 /* the osc manages this under llite */
+#define OBD_BRW_GRANTED 0x40 /* the ost manages this */
+#define OBD_BRW_DROP 0x80 /* drop the page after IO */
+#define OBD_BRW_NOQUOTA 0x100
+#define OBD_BRW_SRVLOCK 0x200 /* Client holds no lock over this page */
+
+#define OBD_OBJECT_EOF 0xffffffffffffffffULL
+
+#define OST_MIN_PRECREATE 32
+#define OST_MAX_PRECREATE 20000
+
+struct obd_ioobj {
+ obd_id ioo_id;
+ obd_gr ioo_gr;
+ __u32 ioo_type;
+ __u32 ioo_bufcnt;
+};
+
+extern void lustre_swab_obd_ioobj (struct obd_ioobj *ioo);
+
+/* multiple of 8 bytes => can array */
+struct niobuf_remote {
+ __u64 offset;
+ __u32 len;
+ __u32 flags;
+};
+
+extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
+
+/* request structure for OST's */
+
+struct ost_body {
+ struct obdo oa;
+};
+
+extern void lustre_swab_ost_body (struct ost_body *b);
+extern void lustre_swab_ost_last_id(obd_id *id);
+
+/* lock value block communicated between the filter and llite */
+
+struct ost_lvb {
+ __u64 lvb_size;
+ __u64 lvb_mtime;
+ __u64 lvb_atime;
+ __u64 lvb_ctime;
+ __u64 lvb_blocks;
+};
+
+extern void lustre_swab_ost_lvb(struct ost_lvb *);
+
+/*
+ * MDS REQ RECORDS
+ */
+
+/* opcodes */
+typedef enum {
+ MDS_GETATTR = 33,
+ MDS_GETATTR_NAME = 34,
+ MDS_CLOSE = 35,
+ MDS_REINT = 36,
+ MDS_READPAGE = 37,
+ MDS_CONNECT = 38,
+ MDS_DISCONNECT = 39,
+ MDS_GETSTATUS = 40,
+ MDS_STATFS = 41,
+ MDS_PIN = 42,
+ MDS_UNPIN = 43,
+ MDS_SYNC = 44,
+ MDS_DONE_WRITING = 45,
+ MDS_SET_INFO = 46,
+ MDS_QUOTACHECK = 47,
+ MDS_QUOTACTL = 48,
+ MDS_GETXATTR = 49,
+ MDS_SETXATTR = 50,
+ MDS_LAST_OPC
+} mds_cmd_t;
+
+#define MDS_FIRST_OPC MDS_GETATTR
+
+/*
+ * Do not exceed 63
+ */
+
+typedef enum {
+ REINT_SETATTR = 1,
+ REINT_CREATE = 2,
+ REINT_LINK = 3,
+ REINT_UNLINK = 4,
+ REINT_RENAME = 5,
+ REINT_OPEN = 6,
+// REINT_CLOSE = 7,
+// REINT_WRITE = 8,
+ REINT_MAX
+} mds_reint_t;
+
+/* the disposition of the intent outlines what was executed */
+#define DISP_IT_EXECD 0x01
+#define DISP_LOOKUP_EXECD 0x02
+#define DISP_LOOKUP_NEG 0x04
+#define DISP_LOOKUP_POS 0x08
+#define DISP_OPEN_CREATE 0x10
+#define DISP_OPEN_OPEN 0x20
+#define DISP_ENQ_COMPLETE 0x40
+
+/* INODE LOCK PARTS */
+#define MDS_INODELOCK_LOOKUP 0x000001 /* dentry, mode, owner, group */
+#define MDS_INODELOCK_UPDATE 0x000002 /* size, links, timestamps */
+#define MDS_INODELOCK_OPEN 0x000004 /* For opened files */
+
+/* Do not forget to increase MDS_INODELOCK_MAXSHIFT when adding new bits */
+#define MDS_INODELOCK_MAXSHIFT 2
+/* This FULL lock is useful to take on unlink sort of operations */
+#define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1)
+
+struct ll_fid {
+ __u64 id; /* holds object id */
+ __u32 generation; /* holds object generation */
+
+ __u32 f_type; /* holds object type or stripe idx when passing it to
+ * OST for saving into EA. */
+};
+
+extern void lustre_swab_ll_fid (struct ll_fid *fid);
+
+#define MDS_STATUS_CONN 1
+#define MDS_STATUS_LOV 2
+
+struct mds_status_req {
+ __u32 flags;
+ __u32 repbuf;
+};
+
+extern void lustre_swab_mds_status_req (struct mds_status_req *r);
+
+#define MDS_BFLAG_UNCOMMITTED_WRITES 0x1
+
+struct mds_body {
+ struct ll_fid fid1;
+ struct ll_fid fid2;
+ struct lustre_handle handle;
+ __u64 valid;
+ __u64 size; /* Offset, in the case of MDS_READPAGE */
+ __u64 mtime;
+ __u64 atime;
+ __u64 ctime;
+ __u64 blocks; /* XID, in the case of MDS_READPAGE */
+ __u64 io_epoch;
+ __u64 ino;
+ __u32 fsuid;
+ __u32 fsgid;
+ __u32 capability;
+ __u32 mode;
+ __u32 uid;
+ __u32 gid;
+ __u32 flags; /* from vfs for pin/unpin, MDS_BFLAG for close */
+ __u32 rdev;
+ __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */
+ __u32 generation;
+ __u32 suppgid;
+ __u32 eadatasize;
+ __u32 aclsize;
+ __u32 padding_2; /* also fix lustre_swab_mds_body */
+ __u32 padding_3; /* also fix lustre_swab_mds_body */
+ __u32 padding_4; /* also fix lustre_swab_mds_body */
+};
+
+extern void lustre_swab_mds_body (struct mds_body *b);
+
+#define Q_QUOTACHECK 0x800100
+#define Q_INITQUOTA 0x800101 /* init slave limits */
+#define Q_GETOINFO 0x800102 /* get obd quota info */
+#define Q_GETOQUOTA 0x800103 /* get obd quotas */
+
+#define Q_TYPESET(oqc, type) \
+ ((oqc)->qc_type == type || (oqc)->qc_type == UGQUOTA)
+
+#define Q_GETOCMD(oqc) \
+ ((oqc)->qc_cmd == Q_GETOINFO || (oqc)->qc_cmd == Q_GETOQUOTA)
+
+struct obd_quotactl {
+ __u32 qc_cmd;
+ __u32 qc_type;
+ __u32 qc_id;
+ __u32 qc_stat;
+ struct obd_dqinfo qc_dqinfo;
+ struct obd_dqblk qc_dqblk;
+};
+
+extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
+
+struct mds_rec_setattr {
+ __u32 sa_opcode;
+ __u32 sa_fsuid;
+ __u32 sa_fsgid;
+ __u32 sa_cap;
+ __u32 sa_suppgid;
+ __u32 sa_mode;
+ struct ll_fid sa_fid;
+ __u64 sa_valid;
+ __u64 sa_size;
+ __u64 sa_mtime;
+ __u64 sa_atime;
+ __u64 sa_ctime;
+ __u32 sa_uid;
+ __u32 sa_gid;
+ __u32 sa_attr_flags;
+ __u32 sa_padding; /* also fix lustre_swab_mds_rec_setattr */
+};
+
+/* Remove this once we declare it in include/linux/fs.h (v21 kernel patch?) */
+#ifndef ATTR_CTIME_SET
+#define ATTR_CTIME_SET 0x2000
+#endif
+
+extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
+
+#ifndef FMODE_READ
+#define FMODE_READ 00000001
+#define FMODE_WRITE 00000002
+#endif
+#ifndef FMODE_EXEC
+#define FMODE_EXEC 00000004
+#endif
+#define MDS_OPEN_CREAT 00000100
+#define MDS_OPEN_EXCL 00000200
+#define MDS_OPEN_TRUNC 00001000
+#define MDS_OPEN_APPEND 00002000
+#define MDS_OPEN_SYNC 00010000
+#define MDS_OPEN_DIRECTORY 00200000
+
+#define MDS_OPEN_DELAY_CREATE 0100000000 /* delay initial object create */
+#define MDS_OPEN_OWNEROVERRIDE 0200000000 /* NFSD rw-reopen ro file for owner */
+#define MDS_OPEN_HAS_EA 010000000000 /* specify object create pattern */
+#define MDS_OPEN_HAS_OBJS 020000000000 /* Just set the EA the obj exist */
+
+struct mds_rec_create {
+ __u32 cr_opcode;
+ __u32 cr_fsuid;
+ __u32 cr_fsgid;
+ __u32 cr_cap;
+ __u32 cr_flags; /* for use with open */
+ __u32 cr_mode;
+ struct ll_fid cr_fid;
+ struct ll_fid cr_replayfid;
+ __u64 cr_time;
+ __u64 cr_rdev;
+ __u32 cr_suppgid;
+ __u32 cr_padding_1; /* also fix lustre_swab_mds_rec_create */
+ __u32 cr_padding_2; /* also fix lustre_swab_mds_rec_create */
+ __u32 cr_padding_3; /* also fix lustre_swab_mds_rec_create */
+ __u32 cr_padding_4; /* also fix lustre_swab_mds_rec_create */
+ __u32 cr_padding_5; /* also fix lustre_swab_mds_rec_create */
+};
+
+extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr);
+
+struct mds_rec_link {
+ __u32 lk_opcode;
+ __u32 lk_fsuid;
+ __u32 lk_fsgid;
+ __u32 lk_cap;
+ __u32 lk_suppgid1;
+ __u32 lk_suppgid2;
+ struct ll_fid lk_fid1;
+ struct ll_fid lk_fid2;
+ __u64 lk_time;
+ __u32 lk_padding_1; /* also fix lustre_swab_mds_rec_link */
+ __u32 lk_padding_2; /* also fix lustre_swab_mds_rec_link */
+ __u32 lk_padding_3; /* also fix lustre_swab_mds_rec_link */
+ __u32 lk_padding_4; /* also fix lustre_swab_mds_rec_link */
+};
+
+extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk);
+
+struct mds_rec_unlink {
+ __u32 ul_opcode;
+ __u32 ul_fsuid;
+ __u32 ul_fsgid;
+ __u32 ul_cap;
+ __u32 ul_suppgid;
+ __u32 ul_mode;
+ struct ll_fid ul_fid1;
+ struct ll_fid ul_fid2;
+ __u64 ul_time;
+ __u32 ul_padding_1; /* also fix lustre_swab_mds_rec_unlink */
+ __u32 ul_padding_2; /* also fix lustre_swab_mds_rec_unlink */
+ __u32 ul_padding_3; /* also fix lustre_swab_mds_rec_unlink */
+ __u32 ul_padding_4; /* also fix lustre_swab_mds_rec_unlink */
+};
+
+extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul);
+
+struct mds_rec_rename {
+ __u32 rn_opcode;
+ __u32 rn_fsuid;
+ __u32 rn_fsgid;
+ __u32 rn_cap;
+ __u32 rn_suppgid1;
+ __u32 rn_suppgid2;
+ struct ll_fid rn_fid1;
+ struct ll_fid rn_fid2;
+ __u64 rn_time;
+ __u32 rn_padding_1; /* also fix lustre_swab_mds_rec_rename */
+ __u32 rn_padding_2; /* also fix lustre_swab_mds_rec_rename */
+ __u32 rn_padding_3; /* also fix lustre_swab_mds_rec_rename */
+ __u32 rn_padding_4; /* also fix lustre_swab_mds_rec_rename */
+};
+
+extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
+
+/*
+ * LOV data structures
+ */
+
+#define LOV_MIN_STRIPE_SIZE 65536 /* maximum PAGE_SIZE (ia64), power of 2 */
+#define LOV_MAX_STRIPE_COUNT 160 /* until bug 4424 is fixed */
+
+#define LOV_MAX_UUID_BUFFER_SIZE 8192
+/* The size of the buffer the lov/mdc reserves for the
+ * array of UUIDs returned by the MDS. With the current
+ * protocol, this will limit the max number of OSTs per LOV */
+
+#define LOV_DESC_MAGIC 0xB0CCDE5C
+
+struct lov_desc {
+ __u32 ld_tgt_count; /* how many OBD's */
+ __u32 ld_active_tgt_count; /* how many active */
+ __u32 ld_default_stripe_count; /* how many objects are used */
+ __u32 ld_pattern; /* PATTERN_RAID0, PATTERN_RAID1 */
+ __u64 ld_default_stripe_size; /* in bytes */
+ __u64 ld_default_stripe_offset; /* in bytes */
+ __u32 ld_qos_threshold; /* in MB */
+ __u32 ld_qos_maxage; /* in second */
+ __u32 ld_padding_1; /* also fix lustre_swab_lov_desc */
+ __u32 ld_padding_2; /* also fix lustre_swab_lov_desc */
+ struct obd_uuid ld_uuid;
+};
+
+#define ld_magic ld_active_tgt_count /* for swabbing from llogs */
+
+extern void lustre_swab_lov_desc (struct lov_desc *ld);
+
+/*
+ * LDLM requests:
+ */
+/* opcodes -- MUST be distinct from OST/MDS opcodes */
+typedef enum {
+ LDLM_ENQUEUE = 101,
+ LDLM_CONVERT = 102,
+ LDLM_CANCEL = 103,
+ LDLM_BL_CALLBACK = 104,
+ LDLM_CP_CALLBACK = 105,
+ LDLM_GL_CALLBACK = 106,
+ LDLM_LAST_OPC
+} ldlm_cmd_t;
+#define LDLM_FIRST_OPC LDLM_ENQUEUE
+
+#define RES_NAME_SIZE 4
+struct ldlm_res_id {
+ __u64 name[RES_NAME_SIZE];
+};
+
+extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
+
+/* lock types */
+typedef enum {
+ LCK_MINMODE = 0,
+ LCK_EX = 1,
+ LCK_PW = 2,
+ LCK_PR = 4,
+ LCK_CW = 8,
+ LCK_CR = 16,
+ LCK_NL = 32,
+ LCK_GROUP = 64,
+ LCK_MAXMODE
+} ldlm_mode_t;
+
+typedef enum {
+ LDLM_PLAIN = 10,
+ LDLM_EXTENT = 11,
+ LDLM_FLOCK = 12,
+ LDLM_IBITS = 13,
+ LDLM_MAX_TYPE
+} ldlm_type_t;
+
+#define LDLM_MIN_TYPE LDLM_PLAIN
+
+struct ldlm_extent {
+ __u64 start;
+ __u64 end;
+ __u64 gid;
+};
+
+struct ldlm_inodebits {
+ __u64 bits;
+};
+
+struct ldlm_flock {
+ __u64 start;
+ __u64 end;
+ __u64 blocking_export; /* not actually used over the wire */
+ __u32 blocking_pid; /* not actually used over the wire */
+ __u32 pid;
+};
+
+/* it's important that the fields of the ldlm_extent structure match
+ * the first fields of the ldlm_flock structure because there is only
+ * one ldlm_swab routine to process the ldlm_policy_data_t union. if
+ * this ever changes we will need to swab the union differently based
+ * on the resource type. */
+
+typedef union {
+ struct ldlm_extent l_extent;
+ struct ldlm_flock l_flock;
+ struct ldlm_inodebits l_inodebits;
+} ldlm_policy_data_t;
+
+extern void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d);
+
+struct ldlm_intent {
+ __u64 opc;
+};
+
+extern void lustre_swab_ldlm_intent (struct ldlm_intent *i);
+
+struct ldlm_resource_desc {
+ ldlm_type_t lr_type;
+ __u32 lr_padding;
+ struct ldlm_res_id lr_name;
+};
+
+extern void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r);
+
+struct ldlm_lock_desc {
+ struct ldlm_resource_desc l_resource;
+ ldlm_mode_t l_req_mode;
+ ldlm_mode_t l_granted_mode;
+ ldlm_policy_data_t l_policy_data;
+};
+
+extern void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l);
+
+struct ldlm_request {
+ __u32 lock_flags;
+ __u32 lock_padding;
+ struct ldlm_lock_desc lock_desc;
+ struct lustre_handle lock_handle1;
+ struct lustre_handle lock_handle2;
+};
+
+extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
+
+struct ldlm_reply {
+ __u32 lock_flags;
+ __u32 lock_padding;
+ struct ldlm_lock_desc lock_desc;
+ struct lustre_handle lock_handle;
+ __u64 lock_policy_res1;
+ __u64 lock_policy_res2;
+};
+
+extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
+
+/*
+ * ptlbd, portal block device requests
+ */
+typedef enum {
+ PTLBD_QUERY = 200,
+ PTLBD_READ = 201,
+ PTLBD_WRITE = 202,
+ PTLBD_FLUSH = 203,
+ PTLBD_CONNECT = 204,
+ PTLBD_DISCONNECT = 205,
+ PTLBD_LAST_OPC
+} ptlbd_cmd_t;
+#define PTLBD_FIRST_OPC PTLBD_QUERY
+
+struct ptlbd_op {
+ __u16 op_cmd;
+ __u16 op_lun;
+ __u16 op_niob_cnt;
+ __u16 op__padding;
+ __u32 op_block_cnt;
+};
+
+extern void lustre_swab_ptlbd_op (struct ptlbd_op *op);
+
+struct ptlbd_niob {
+ __u64 n_xid;
+ __u64 n_block_nr;
+ __u32 n_offset;
+ __u32 n_length;
+};
+
+extern void lustre_swab_ptlbd_niob (struct ptlbd_niob *n);
+
+struct ptlbd_rsp {
+ __u16 r_status;
+ __u16 r_error_cnt;
+};
+
+extern void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r);
+
+/*
+ * Opcodes for management/monitoring node.
+ */
+typedef enum {
+ MGMT_CONNECT = 250,
+ MGMT_DISCONNECT,
+ MGMT_EXCEPTION, /* node died, etc. */
+ MGMT_LAST_OPC
+} mgmt_cmd_t;
+#define MGMT_FIRST_OPC MGMT_CONNECT
+
+/*
+ * Opcodes for multiple servers.
+ */
+
+typedef enum {
+ OBD_PING = 400,
+ OBD_LOG_CANCEL,
+ OBD_QC_CALLBACK,
+ OBD_LAST_OPC
+} obd_cmd_t;
+#define OBD_FIRST_OPC OBD_PING
+
+/* catalog of log objects */
+
+/* Identifier for a single log object */
+struct llog_logid {
+ __u64 lgl_oid;
+ __u64 lgl_ogr;
+ __u32 lgl_ogen;
+} __attribute__((packed));
+
+/* Records written to the CATALOGS list */
+#define CATLIST "CATALOGS"
+struct llog_catid {
+ struct llog_logid lci_logid;
+ __u32 lci_padding[3];
+} __attribute__((packed));
+
+/* Log data record types - there is no specific reason that these need to
+ * be related to the RPC opcodes, but no reason not to (may be handy later?)
+ */
+#define LLOG_OP_MAGIC 0x10600000
+#define LLOG_OP_MASK 0xfff00000
+
+typedef enum {
+ LLOG_PAD_MAGIC = LLOG_OP_MAGIC | 0,
+ OST_SZ_REC = LLOG_OP_MAGIC | (OST_SAN_WRITE << 8),
+ OST_RAID1_REC = LLOG_OP_MAGIC | ((OST_SAN_WRITE + 1) << 8),
+ MDS_UNLINK_REC = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_UNLINK,
+ MDS_SETATTR_REC = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_SETATTR,
+ OBD_CFG_REC = LLOG_OP_MAGIC | 0x20000,
+ PTL_CFG_REC = LLOG_OP_MAGIC | 0x30000, /* obsolete */
+ LLOG_GEN_REC = LLOG_OP_MAGIC | 0x40000,
+ LLOG_HDR_MAGIC = LLOG_OP_MAGIC | 0x45539,
+ LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b,
+} llog_op_type;
+
+/*
+ * for now, continue to support old pad records which have 0 for their
+ * type but still need to be swabbed for their length
+ */
+#define LLOG_REC_HDR_NEEDS_SWABBING(r) \
+ (((r)->lrh_type & __swab32(LLOG_OP_MASK)) == \
+ __swab32(LLOG_OP_MAGIC) || \
+ (((r)->lrh_type == 0) && ((r)->lrh_len > LLOG_CHUNK_SIZE)))
+
+/* Log record header - stored in little endian order.
+ * Each record must start with this struct, end with a llog_rec_tail,
+ * and be a multiple of 256 bits in size.
+ */
+struct llog_rec_hdr {
+ __u32 lrh_len;
+ __u32 lrh_index;
+ __u32 lrh_type;
+ __u32 padding;
+};
+
+struct llog_rec_tail {
+ __u32 lrt_len;
+ __u32 lrt_index;
+};
+
+struct llog_logid_rec {
+ struct llog_rec_hdr lid_hdr;
+ struct llog_logid lid_id;
+ __u32 padding[5];
+ struct llog_rec_tail lid_tail;
+} __attribute__((packed));
+
+struct llog_create_rec {
+ struct llog_rec_hdr lcr_hdr;
+ struct ll_fid lcr_fid;
+ obd_id lcr_oid;
+ obd_count lcr_ogen;
+ __u32 padding;
+ struct llog_rec_tail lcr_tail;
+} __attribute__((packed));
+
+struct llog_orphan_rec {
+ struct llog_rec_hdr lor_hdr;
+ obd_id lor_oid;
+ obd_count lor_ogen;
+ __u32 padding;
+ struct llog_rec_tail lor_tail;
+} __attribute__((packed));
+
+struct llog_unlink_rec {
+ struct llog_rec_hdr lur_hdr;
+ obd_id lur_oid;
+ obd_count lur_ogen;
+ __u32 padding;
+ struct llog_rec_tail lur_tail;
+} __attribute__((packed));
+
+struct llog_setattr_rec {
+ struct llog_rec_hdr lsr_hdr;
+ obd_id lsr_oid;
+ obd_count lsr_ogen;
+ __u32 lsr_uid;
+ __u32 lsr_gid;
+ __u32 padding;
+ struct llog_rec_tail lsr_tail;
+} __attribute__((packed));
+
+struct llog_size_change_rec {
+ struct llog_rec_hdr lsc_hdr;
+ struct ll_fid lsc_fid;
+ __u32 lsc_io_epoch;
+ __u32 padding;
+ struct llog_rec_tail lsc_tail;
+} __attribute__((packed));
+
+struct llog_gen {
+ __u64 mnt_cnt;
+ __u64 conn_cnt;
+} __attribute__((packed));
+
+struct llog_gen_rec {
+ struct llog_rec_hdr lgr_hdr;
+ struct llog_gen lgr_gen;
+ struct llog_rec_tail lgr_tail;
+};
+/* On-disk header structure of each log object, stored in little endian order */
+#define LLOG_CHUNK_SIZE 8192
+#define LLOG_HEADER_SIZE (96)
+#define LLOG_BITMAP_BYTES (LLOG_CHUNK_SIZE - LLOG_HEADER_SIZE)
+
+#define LLOG_MIN_REC_SIZE (24) /* round(llog_rec_hdr + llog_rec_tail) */
+
+/* flags for the logs */
+#define LLOG_F_ZAP_WHEN_EMPTY 0x1
+#define LLOG_F_IS_CAT 0x2
+#define LLOG_F_IS_PLAIN 0x4
+
+struct llog_log_hdr {
+ struct llog_rec_hdr llh_hdr;
+ __u64 llh_timestamp;
+ __u32 llh_count;
+ __u32 llh_bitmap_offset;
+ __u32 llh_size;
+ __u32 llh_flags;
+ __u32 llh_cat_idx;
+ /* for a catalog the first plain slot is next to it */
+ struct obd_uuid llh_tgtuuid;
+ __u32 llh_reserved[LLOG_HEADER_SIZE/sizeof(__u32) - 23];
+ __u32 llh_bitmap[LLOG_BITMAP_BYTES/sizeof(__u32)];
+ struct llog_rec_tail llh_tail;
+} __attribute__((packed));
+
+#define LLOG_BITMAP_SIZE(llh) ((llh->llh_hdr.lrh_len - \
+ llh->llh_bitmap_offset - \
+ sizeof(llh->llh_tail)) * 8)
+
+/* log cookies are used to reference a specific log file and a record therein */
+struct llog_cookie {
+ struct llog_logid lgc_lgl;
+ __u32 lgc_subsys;
+ __u32 lgc_index;
+ __u32 lgc_padding;
+} __attribute__((packed));
+
+/* llog protocol */
+enum llogd_rpc_ops {
+ LLOG_ORIGIN_HANDLE_CREATE = 501,
+ LLOG_ORIGIN_HANDLE_NEXT_BLOCK = 502,
+ LLOG_ORIGIN_HANDLE_READ_HEADER = 503,
+ LLOG_ORIGIN_HANDLE_WRITE_REC = 504,
+ LLOG_ORIGIN_HANDLE_CLOSE = 505,
+ LLOG_ORIGIN_CONNECT = 506,
+ LLOG_CATINFO = 507, /* for lfs catinfo */
+};
+
+struct llogd_body {
+ struct llog_logid lgd_logid;
+ __u32 lgd_ctxt_idx;
+ __u32 lgd_llh_flags;
+ __u32 lgd_index;
+ __u32 lgd_saved_index;
+ __u32 lgd_len;
+ __u64 lgd_cur_offset;
+} __attribute__((packed));
+
+struct llogd_conn_body {
+ struct llog_gen lgdc_gen;
+ struct llog_logid lgdc_logid;
+ __u32 lgdc_ctxt_idx;
+} __attribute__((packed));
+
+extern void lustre_swab_lov_user_md(struct lov_user_md *lum);
+extern void lustre_swab_lov_user_md_objects(struct lov_user_md *lum);
+
+/* llog_swab.c */
+extern void lustre_swab_llogd_body (struct llogd_body *d);
+extern void lustre_swab_llog_hdr (struct llog_log_hdr *h);
+extern void lustre_swab_llogd_conn_body (struct llogd_conn_body *d);
+extern void lustre_swab_llog_rec(struct llog_rec_hdr *rec,
+ struct llog_rec_tail *tail);
+
+struct lustre_cfg;
+extern void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg);
+
+/* qutoa */
+struct qunit_data {
+ __u32 qd_id; /* ID appiles to (uid, gid) */
+ __u32 qd_type; /* Quota type (USRQUOTA, GRPQUOTA) */
+ __u32 qd_count; /* acquire/release count (bytes for block quota) */
+ __u32 qd_isblk; /* Block quota or file quota */
+};
+extern void lustre_swab_qdata(struct qunit_data *d);
+
+typedef enum {
+ QUOTA_DQACQ = 601,
+ QUOTA_DQREL = 602,
+} quota_cmd_t;
+
+#endif
#ifndef __IMPORT_H
#define __IMPORT_H
-#include <linux/lustre_handles.h>
-#include <linux/lustre_idl.h>
+#include <lustre_handles.h>
+#include <lustre_idl.h>
enum lustre_imp_state {
LUSTRE_IMP_CLOSED = 1,
struct list_head oic_item;
struct ptlrpc_connection *oic_conn;
struct obd_uuid oic_uuid;
- unsigned long oic_last_attempt; /* in jiffies */
+ cfs_time_t oic_last_attempt; /* in cfs_time_t */
};
struct obd_import {
struct list_head imp_delayed_list;
struct obd_device *imp_obd;
- wait_queue_head_t imp_recovery_waitq;
+ cfs_waitq_t imp_recovery_waitq;
__u64 imp_last_replay_transno;
atomic_t imp_inflight;
atomic_t imp_replay_inflight;
__u64 imp_peer_committed_transno;
struct obd_uuid imp_target_uuid; /* XXX -> lustre_name */
struct lustre_handle imp_remote_handle;
- unsigned long imp_next_ping; /* jiffies */
+ cfs_time_t imp_next_ping; /* jiffies */
/* all available obd_import_conn linked here */
struct list_head imp_conn_list;
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Basic Lustre library routines.
+ *
+ */
+
+#ifndef _LUSTRE_LIB_H
+#define _LUSTRE_LIB_H
+
+#include <libcfs/kp30.h>
+#include <lustre_idl.h>
+#include <lustre_cfg.h>
+#if defined(__linux__)
+#include <linux/lustre_lib.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_lib.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_lib.h>
+#else
+#error Unsupported operating system.
+#endif
+
+/* target.c */
+struct ptlrpc_request;
+struct recovd_data;
+struct recovd_obd;
+struct obd_export;
+#include <lustre_ha.h>
+#include <lustre_net.h>
+#include <lvfs.h>
+
+int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler);
+int target_handle_disconnect(struct ptlrpc_request *req);
+void target_destroy_export(struct obd_export *exp);
+int target_handle_reconnect(struct lustre_handle *conn, struct obd_export *exp,
+ struct obd_uuid *cluuid);
+int target_handle_ping(struct ptlrpc_request *req);
+void target_committed_to_req(struct ptlrpc_request *req);
+
+#ifdef HAVE_QUOTA_SUPPORT
+/* quotacheck callback, dqacq/dqrel callback handler */
+int target_handle_qc_callback(struct ptlrpc_request *req);
+int target_handle_dqacq_callback(struct ptlrpc_request *req);
+#else
+#define target_handle_dqacq_callback(req) ldlm_callback_reply(req, -ENOTSUPP)
+#define target_handle_qc_callback(req) (0)
+#endif
+
+void target_cancel_recovery_timer(struct obd_device *obd);
+
+#define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2) /* *waves hands* */
+void target_start_recovery_timer(struct obd_device *obd, svc_handler_t handler);
+void target_abort_recovery(void *data);
+void target_cleanup_recovery(struct obd_device *obd);
+int target_queue_recovery_request(struct ptlrpc_request *req,
+ struct obd_device *obd);
+int target_queue_final_reply(struct ptlrpc_request *req, int rc);
+void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id);
+
+/* client.c */
+
+int client_sanobd_setup(struct obd_device *obddev, obd_count len, void *buf);
+struct client_obd *client_conn2cli(struct lustre_handle *conn);
+
+struct mdc_open_data;
+struct obd_client_handle {
+ struct lustre_handle och_fh;
+ struct llog_cookie och_cookie;
+ struct mdc_open_data *och_mod;
+ __u32 och_magic;
+};
+#define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed
+
+/* statfs_pack.c */
+void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
+void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
+
+/* l_lock.c */
+struct lustre_lock {
+ int l_depth;
+ cfs_task_t *l_owner;
+ struct semaphore l_sem;
+ spinlock_t l_spin;
+};
+
+void l_lock_init(struct lustre_lock *);
+void l_lock(struct lustre_lock *);
+void l_unlock(struct lustre_lock *);
+int l_has_lock(struct lustre_lock *);
+
+
+/*
+ * OBD IOCTLS
+ */
+#define OBD_IOCTL_VERSION 0x00010004
+
+struct obd_ioctl_data {
+ uint32_t ioc_len;
+ uint32_t ioc_version;
+
+ uint64_t ioc_cookie;
+ uint32_t ioc_conn1;
+ uint32_t ioc_conn2;
+
+ struct obdo ioc_obdo1;
+ struct obdo ioc_obdo2;
+
+ obd_size ioc_count;
+ obd_off ioc_offset;
+ uint32_t ioc_dev;
+ uint32_t ioc_command;
+
+ uint64_t ioc_nid;
+ uint32_t ioc_nal;
+ uint32_t ioc_type;
+
+ /* buffers the kernel will treat as user pointers */
+ uint32_t ioc_plen1;
+ char *ioc_pbuf1;
+ uint32_t ioc_plen2;
+ char *ioc_pbuf2;
+
+ /* inline buffers for various arguments */
+ uint32_t ioc_inllen1;
+ char *ioc_inlbuf1;
+ uint32_t ioc_inllen2;
+ char *ioc_inlbuf2;
+ uint32_t ioc_inllen3;
+ char *ioc_inlbuf3;
+ uint32_t ioc_inllen4;
+ char *ioc_inlbuf4;
+
+ char ioc_bulk[0];
+};
+
+struct obd_ioctl_hdr {
+ uint32_t ioc_len;
+ uint32_t ioc_version;
+};
+
+static inline int obd_ioctl_packlen(struct obd_ioctl_data *data)
+{
+ int len = size_round(sizeof(struct obd_ioctl_data));
+ len += size_round(data->ioc_inllen1);
+ len += size_round(data->ioc_inllen2);
+ len += size_round(data->ioc_inllen3);
+ len += size_round(data->ioc_inllen4);
+ return len;
+}
+
+
+static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
+{
+ if (data->ioc_len > (1<<30)) {
+ CERROR("OBD ioctl: ioc_len larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inllen1 > (1<<30)) {
+ CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inllen2 > (1<<30)) {
+ CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inllen3 > (1<<30)) {
+ CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inllen4 > (1<<30)) {
+ CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
+ CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
+ CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_inlbuf3 && !data->ioc_inllen3) {
+ CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_inlbuf4 && !data->ioc_inllen4) {
+ CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_pbuf1 && !data->ioc_plen1) {
+ CERROR("OBD ioctl: pbuf1 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_pbuf2 && !data->ioc_plen2) {
+ CERROR("OBD ioctl: pbuf2 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_plen1 && !data->ioc_pbuf1) {
+ CERROR("OBD ioctl: plen1 set but NULL pointer\n");
+ return 1;
+ }
+ if (data->ioc_plen2 && !data->ioc_pbuf2) {
+ CERROR("OBD ioctl: plen2 set but NULL pointer\n");
+ return 1;
+ }
+ if (obd_ioctl_packlen(data) > data->ioc_len) {
+ CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n",
+ obd_ioctl_packlen(data), data->ioc_len);
+ return 1;
+ }
+ return 0;
+}
+
+#ifndef __KERNEL__
+static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
+ int max)
+{
+ char *ptr;
+ struct obd_ioctl_data *overlay;
+ data->ioc_len = obd_ioctl_packlen(data);
+ data->ioc_version = OBD_IOCTL_VERSION;
+
+ if (*pbuf && data->ioc_len > max)
+ return 1;
+ if (*pbuf == NULL) {
+ *pbuf = malloc(data->ioc_len);
+ }
+ if (!*pbuf)
+ return 1;
+ overlay = (struct obd_ioctl_data *)*pbuf;
+ memcpy(*pbuf, data, sizeof(*data));
+
+ ptr = overlay->ioc_bulk;
+ if (data->ioc_inlbuf1)
+ LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
+ if (data->ioc_inlbuf2)
+ LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
+ if (data->ioc_inlbuf3)
+ LOGL(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
+ if (data->ioc_inlbuf4)
+ LOGL(data->ioc_inlbuf4, data->ioc_inllen4, ptr);
+ if (obd_ioctl_is_invalid(overlay))
+ return 1;
+
+ return 0;
+}
+
+static inline int obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf,
+ int max)
+{
+ char *ptr;
+ struct obd_ioctl_data *overlay;
+
+ if (!pbuf)
+ return 1;
+ overlay = (struct obd_ioctl_data *)pbuf;
+
+ /* Preserve the caller's buffer pointers */
+ overlay->ioc_inlbuf1 = data->ioc_inlbuf1;
+ overlay->ioc_inlbuf2 = data->ioc_inlbuf2;
+ overlay->ioc_inlbuf3 = data->ioc_inlbuf3;
+ overlay->ioc_inlbuf4 = data->ioc_inlbuf4;
+
+ memcpy(data, pbuf, sizeof(*data));
+
+ ptr = overlay->ioc_bulk;
+ if (data->ioc_inlbuf1)
+ LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
+ if (data->ioc_inlbuf2)
+ LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
+ if (data->ioc_inlbuf3)
+ LOGU(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
+ if (data->ioc_inlbuf4)
+ LOGU(data->ioc_inlbuf4, data->ioc_inllen4, ptr);
+
+ return 0;
+}
+#endif
+
+#include <obd_support.h>
+
+#ifdef __KERNEL__
+/* function defined in lustre/obdclass/<platform>/<platform>-module.c */
+int obd_ioctl_getdata(char **buf, int *len, void *arg);
+#else
+/* buffer MUST be at least the size of obd_ioctl_hdr */
+static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
+{
+ struct obd_ioctl_hdr hdr;
+ struct obd_ioctl_data *data;
+ int err;
+ int offset = 0;
+ ENTRY;
+
+ err = copy_from_user(&hdr, (void *)arg, sizeof(hdr));
+ if ( err )
+ RETURN(err);
+
+ if (hdr.ioc_version != OBD_IOCTL_VERSION) {
+ CERROR("Version mismatch kernel vs application\n");
+ RETURN(-EINVAL);
+ }
+
+ if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) {
+ CERROR("User buffer len %d exceeds %d max buffer\n",
+ hdr.ioc_len, OBD_MAX_IOCTL_BUFFER);
+ RETURN(-EINVAL);
+ }
+
+ if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) {
+ CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len);
+ RETURN(-EINVAL);
+ }
+
+ /* XXX allocate this more intelligently, using kmalloc when
+ * appropriate */
+ OBD_VMALLOC(*buf, hdr.ioc_len);
+ if (*buf == NULL) {
+ CERROR("Cannot allocate control buffer of len %d\n",
+ hdr.ioc_len);
+ RETURN(-EINVAL);
+ }
+ *len = hdr.ioc_len;
+ data = (struct obd_ioctl_data *)*buf;
+
+ err = copy_from_user(*buf, (void *)arg, hdr.ioc_len);
+ if ( err ) {
+ OBD_VFREE(*buf, hdr.ioc_len);
+ RETURN(err);
+ }
+
+ if (obd_ioctl_is_invalid(data)) {
+ CERROR("ioctl not correctly formatted\n");
+ OBD_VFREE(*buf, hdr.ioc_len);
+ RETURN(-EINVAL);
+ }
+
+ if (data->ioc_inllen1) {
+ data->ioc_inlbuf1 = &data->ioc_bulk[0];
+ offset += size_round(data->ioc_inllen1);
+ }
+
+ if (data->ioc_inllen2) {
+ data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset;
+ offset += size_round(data->ioc_inllen2);
+ }
+
+ if (data->ioc_inllen3) {
+ data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset;
+ offset += size_round(data->ioc_inllen3);
+ }
+
+ if (data->ioc_inllen4) {
+ data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset;
+ }
+
+ EXIT;
+ return 0;
+}
+#endif
+
+static inline void obd_ioctl_freedata(char *buf, int len)
+{
+ ENTRY;
+
+ OBD_VFREE(buf, len);
+ EXIT;
+ return;
+}
+
+#define OBD_IOC_CREATE _IOR ('f', 101, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_DESTROY _IOW ('f', 104, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PREALLOCATE _IOWR('f', 105, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_SETATTR _IOW ('f', 107, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_GETATTR _IOR ('f', 108, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_READ _IOWR('f', 109, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_WRITE _IOWR('f', 110, OBD_IOC_DATA_TYPE)
+
+
+#define OBD_IOC_STATFS _IOWR('f', 113, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_SYNC _IOW ('f', 114, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_READ2 _IOWR('f', 115, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_FORMAT _IOWR('f', 116, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PARTITION _IOWR('f', 117, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_COPY _IOWR('f', 120, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_MIGR _IOWR('f', 121, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PUNCH _IOWR('f', 122, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_MODULE_DEBUG _IOWR('f', 124, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_BRW_READ _IOWR('f', 125, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_BRW_WRITE _IOWR('f', 126, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_NAME2DEV _IOWR('f', 127, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_UUID2DEV _IOWR('f', 130, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_GETNAME _IOR ('f', 131, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_LOV_GET_CONFIG _IOWR('f', 132, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_CLIENT_RECOVER _IOW ('f', 133, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 139 )
+#define OBD_IOC_NO_TRANSNO _IOW ('f', 140, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_SET_READONLY _IOW ('f', 141, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_ABORT_RECOVERY _IOR ('f', 142, OBD_IOC_DATA_TYPE)
+
+#define OBD_GET_VERSION _IOWR ('f', 144, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_CLOSE_UUID _IOWR ('f', 147, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_LOV_SETSTRIPE _IOW ('f', 154, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LOV_GETSTRIPE _IOW ('f', 155, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LOV_SETEA _IOW ('f', 156, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_QUOTACHECK _IOW ('f', 160, int)
+#define OBD_IOC_POLL_QUOTACHECK _IOR ('f', 161, struct if_quotacheck *)
+#define OBD_IOC_QUOTACTL _IOWR('f', 162, struct if_quotactl *)
+
+#define OBD_IOC_MOUNTOPT _IOWR('f', 170, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_RECORD _IOWR('f', 180, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_ENDRECORD _IOWR('f', 181, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PARSE _IOWR('f', 182, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_DORECORD _IOWR('f', 183, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PROCESS_CFG _IOWR('f', 184, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_DUMP_LOG _IOWR('f', 185, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_CLEAR_LOG _IOWR('f', 186, OBD_IOC_DATA_TYPE)
+
+#define OBD_IOC_CATLOGLIST _IOWR('f', 190, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LLOG_INFO _IOWR('f', 191, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LLOG_PRINT _IOWR('f', 192, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LLOG_CANCEL _IOWR('f', 193, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LLOG_REMOVE _IOWR('f', 194, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LLOG_CHECK _IOWR('f', 195, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_LLOG_CATINFO _IOWR('f', 196, OBD_IOC_DATA_TYPE)
+
+#define ECHO_IOC_GET_STRIPE _IOWR('f', 200, OBD_IOC_DATA_TYPE)
+#define ECHO_IOC_SET_STRIPE _IOWR('f', 201, OBD_IOC_DATA_TYPE)
+#define ECHO_IOC_ENQUEUE _IOWR('f', 202, OBD_IOC_DATA_TYPE)
+#define ECHO_IOC_CANCEL _IOWR('f', 203, OBD_IOC_DATA_TYPE)
+
+/* XXX _IOWR('f', 250, long) has been defined in
+ * lnet/include/libcfs/kp30.h for debug, don't use it
+ */
+
+/* Until such time as we get_info the per-stripe maximum from the OST,
+ * we define this to be 2T - 4k, which is the ext3 maxbytes. */
+#define LUSTRE_STRIPE_MAXBYTES 0x1fffffff000ULL
+
+#define POISON_BULK 0
+
+static inline int ll_insecure_random_int(void)
+{
+ struct timeval t;
+ do_gettimeofday(&t);
+ return (int)(t.tv_usec);
+}
+
+/*
+ * l_wait_event is a flexible sleeping function, permitting simple caller
+ * configuration of interrupt and timeout sensitivity along with actions to
+ * be performed in the event of either exception.
+ *
+ * Common usage looks like this:
+ *
+ * struct l_wait_info lwi = LWI_TIMEOUT_INTR(timeout, timeout_handler,
+ * intr_handler, callback_data);
+ * rc = l_wait_event(waitq, condition, &lwi);
+ *
+ * (LWI_TIMEOUT and LWI_INTR macros are available for timeout- and
+ * interrupt-only variants, respectively.)
+ *
+ * If a timeout is specified, the timeout_handler will be invoked in the event
+ * that the timeout expires before the process is awakened. (Note that any
+ * waking of the process will restart the timeout, even if the condition is
+ * not satisfied and the process immediately returns to sleep. This might be
+ * considered a bug.) If the timeout_handler returns non-zero, l_wait_event
+ * will return -ETIMEDOUT and the caller will continue. If the handler returns
+ * zero instead, the process will go back to sleep until it is awakened by the
+ * waitq or some similar mechanism, or an interrupt occurs (if the caller has
+ * asked for interrupts to be detected). The timeout will only fire once, so
+ * callers should take care that a timeout_handler which returns zero will take
+ * future steps to awaken the process. N.B. that these steps must include
+ * making the provided condition become true.
+ *
+ * If the interrupt flag (lwi_signals) is non-zero, then the process will be
+ * interruptible, and will be awakened by any "killable" signal (SIGTERM,
+ * SIGKILL or SIGINT). If a timeout is also specified, then the process will
+ * only become interruptible _after_ the timeout has expired, though it can be
+ * awakened by a signal that was delivered before the timeout and is still
+ * pending when the timeout expires. If a timeout is not specified, the process
+ * will be interruptible at all times during l_wait_event.
+ */
+
+struct l_wait_info {
+ cfs_duration_t lwi_timeout;
+ int (*lwi_on_timeout)(void *);
+ long lwi_signals;
+ void (*lwi_on_signal)(void *);
+ void *lwi_cb_data;
+};
+
+#define LWI_TIMEOUT(time, cb, data) \
+((struct l_wait_info) { \
+ lwi_timeout: time, \
+ lwi_on_timeout: cb, \
+ lwi_cb_data: data \
+})
+
+#define LWI_INTR(cb, data) \
+((struct l_wait_info) { \
+ lwi_signals: 1, \
+ lwi_on_signal: cb, \
+ lwi_cb_data: data \
+})
+
+#define LWI_TIMEOUT_INTR(time, time_cb, sig_cb, data) \
+((struct l_wait_info) { \
+ lwi_timeout: time, \
+ lwi_on_timeout: time_cb, \
+ lwi_signals: 1, \
+ lwi_on_signal: sig_cb, \
+ lwi_cb_data: data \
+})
+
+#ifdef __KERNEL__
+
+#define __l_wait_event(wq, condition, info, ret, excl) \
+do { \
+ cfs_waitlink_t __wait; \
+ cfs_duration_t __timed_out = 0; \
+ unsigned long irqflags; \
+ cfs_sigset_t blocked; \
+ cfs_time_t timeout_remaining; \
+ \
+ cfs_waitlink_init(&__wait); \
+ if (excl) \
+ cfs_waitq_add_exclusive(&wq, &__wait); \
+ else \
+ cfs_waitq_add(&wq, &__wait); \
+ \
+ /* Block all signals (just the non-fatal ones if no timeout). */ \
+ if (info->lwi_signals && !info->lwi_timeout) \
+ blocked = l_w_e_set_sigs(LUSTRE_FATAL_SIGS); \
+ else \
+ blocked = l_w_e_set_sigs(0); \
+ \
+ timeout_remaining = info->lwi_timeout; \
+ \
+ for (;;) { \
+ set_current_state(TASK_INTERRUPTIBLE); \
+ if (condition) \
+ break; \
+ if (info->lwi_timeout && !__timed_out) { \
+ timeout_remaining = cfs_waitq_timedwait(&__wait, \
+ CFS_TASK_INTERRUPTIBLE,\
+ timeout_remaining); \
+ if (timeout_remaining == 0) { \
+ __timed_out = 1; \
+ if (!info->lwi_on_timeout || \
+ info->lwi_on_timeout(info->lwi_cb_data)) { \
+ ret = -ETIMEDOUT; \
+ break; \
+ } \
+ /* We'll take signals after a timeout. */ \
+ if (info->lwi_signals) \
+ (void)l_w_e_set_sigs(LUSTRE_FATAL_SIGS); \
+ } \
+ } else { \
+ cfs_waitq_wait(&__wait, CFS_TASK_INTERRUPTIBLE);; \
+ } \
+ if (condition) \
+ break; \
+ if (cfs_signal_pending(cfs_current())) { \
+ if (!info->lwi_timeout || __timed_out) { \
+ break; \
+ } else { \
+ /* We have to do this here because some signals */ \
+ /* are not blockable - ie from strace(1). */ \
+ /* In these cases we want to schedule_timeout() */ \
+ /* again, because we don't want that to return */ \
+ /* -EINTR when the RPC actually succeeded. */ \
+ /* the RECALC_SIGPENDING below will deliver the */ \
+ /* signal properly. */ \
+ cfs_sigmask_lock(cfs_current(), irqflags); \
+ cfs_clear_sigpending(cfs_current()); \
+ cfs_sigmask_unlock(cfs_current(), irqflags); \
+ } \
+ } \
+ } \
+ \
+ cfs_block_sigs(blocked); \
+ \
+ if ((!info->lwi_timeout || __timed_out) && \
+ cfs_signal_pending(cfs_current())) { \
+ if (info->lwi_on_signal) \
+ info->lwi_on_signal(info->lwi_cb_data); \
+ ret = -EINTR; \
+ } \
+ \
+ set_current_state(TASK_RUNNING); \
+ cfs_waitq_del(&wq, &__wait); \
+} while(0)
+
+#else /* !__KERNEL__ */
+#define __l_wait_event(wq, condition, info, ret, excl) \
+do { \
+ long timeout = info->lwi_timeout, elapse, last = 0; \
+ int __timed_out = 0; \
+ \
+ if (info->lwi_timeout == 0) \
+ timeout = 1000000000; \
+ else \
+ last = time(NULL); \
+ \
+ for (;;) { \
+ if (condition) \
+ break; \
+ if (liblustre_wait_event(timeout)) { \
+ if (timeout == 0 || info->lwi_timeout == 0) \
+ continue; \
+ elapse = time(NULL) - last; \
+ if (elapse) { \
+ last += elapse; \
+ timeout -= elapse; \
+ if (timeout < 0) \
+ timeout = 0; \
+ } \
+ continue; \
+ } \
+ if (info->lwi_timeout && !__timed_out) { \
+ __timed_out = 1; \
+ if (info->lwi_on_timeout == NULL || \
+ info->lwi_on_timeout(info->lwi_cb_data)) { \
+ ret = -ETIMEDOUT; \
+ break; \
+ } \
+ } \
+ } \
+} while (0)
+
+#endif /* __KERNEL__ */
+
+#define l_wait_event(wq, condition, info) \
+({ \
+ int __ret = 0; \
+ struct l_wait_info *__info = (info); \
+ if (!(condition)) \
+ __l_wait_event(wq, condition, __info, __ret, 0); \
+ __ret; \
+})
+
+#define l_wait_event_exclusive(wq, condition, info) \
+({ \
+ int __ret = 0; \
+ struct l_wait_info *__info = (info); \
+ if (!(condition)) \
+ __l_wait_event(wq, condition, __info, __ret, 1); \
+ __ret; \
+})
+
+#define LMD_MAGIC_R1 0xbdacbdac
+#define LMD_MAGIC 0xbdacbd02
+
+#define lmd_bad_magic(LMDP) \
+({ \
+ struct lustre_mount_data *_lmd__ = (LMDP); \
+ int _ret__ = 0; \
+ if (!_lmd__) { \
+ LCONSOLE_ERROR("Missing mount data: " \
+ "check that /sbin/mount.lustre is installed.\n");\
+ _ret__ = 1; \
+ } else if (_lmd__->lmd_magic == LMD_MAGIC_R1) { \
+ LCONSOLE_ERROR("You're using an old version of " \
+ "/sbin/mount.lustre. Please install version " \
+ "1.%d\n", LMD_MAGIC & 0xFF); \
+ _ret__ = 1; \
+ } else if (_lmd__->lmd_magic != LMD_MAGIC) { \
+ LCONSOLE_ERROR("Invalid mount data (%#x != %#x): " \
+ "check that /sbin/mount.lustre is installed\n", \
+ _lmd__->lmd_magic, LMD_MAGIC); \
+ _ret__ = 1; \
+ } \
+ _ret__; \
+})
+
+#ifdef __KERNEL__
+#define LIBLUSTRE_CLIENT (0)
+#else
+#define LIBLUSTRE_CLIENT (1)
+#endif
+
+#endif /* _LUSTRE_LIB_H */
+
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+
+#ifndef _LL_H
+#define _LL_H
+
+#if defined(__linux__)
+#include <linux/lustre_lite.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_lite.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_lite.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#include <obd_class.h>
+#include <lustre_net.h>
+#include <lustre_mds.h>
+#include <lustre_ha.h>
+
+#ifdef __KERNEL__
+
+/* careful, this is easy to screw up */
+#define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << CFS_PAGE_SHIFT)
+
+#endif
+
+#define LLAP_FROM_COOKIE(c) \
+ (LASSERT(((struct ll_async_page *)(c))->llap_magic == LLAP_MAGIC), \
+ (struct ll_async_page *)(c))
+
+#define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
+
+#include <lustre/lustre_user.h>
+
+
+struct lustre_rw_params {
+ int lrp_lock_mode;
+ ldlm_policy_data_t lrp_policy;
+ obd_flag lrp_brw_flags;
+ int lrp_ast_flags;
+};
+
+/*
+ * XXX nikita: this function lives in the header because it is used by both
+ * llite kernel module and liblustre library, and there is no (?) better place
+ * to put it in.
+ */
+static inline void lustre_build_lock_params(int cmd, unsigned long open_flags,
+ __u64 connect_flags,
+ loff_t pos, ssize_t len,
+ struct lustre_rw_params *params)
+{
+ params->lrp_lock_mode = (cmd == OBD_BRW_READ) ? LCK_PR : LCK_PW;
+ params->lrp_brw_flags = 0;
+
+ params->lrp_policy.l_extent.start = pos;
+ params->lrp_policy.l_extent.end = pos + len - 1;
+ /*
+ * for now O_APPEND always takes local locks.
+ */
+ if (cmd == OBD_BRW_WRITE && (open_flags & O_APPEND)) {
+ params->lrp_policy.l_extent.start = 0;
+ params->lrp_policy.l_extent.end = OBD_OBJECT_EOF;
+ } else if (LIBLUSTRE_CLIENT && (connect_flags & OBD_CONNECT_SRVLOCK)) {
+ /*
+ * liblustre: OST-side locking for all non-O_APPEND
+ * reads/writes.
+ */
+ params->lrp_lock_mode = LCK_NL;
+ params->lrp_brw_flags = OBD_BRW_SRVLOCK;
+ } else {
+ /*
+ * nothing special for the kernel. In the future llite may use
+ * OST-side locks for small writes into highly contended
+ * files.
+ */
+ }
+ params->lrp_ast_flags = (open_flags & O_NONBLOCK) ?
+ LDLM_FL_BLOCK_NOWAIT : 0;
+}
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001 Cluster File Systems, Inc. <info@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Generic infrastructure for managing a collection of logs.
+ *
+ * These logs are used for:
+ *
+ * - orphan recovery: OST adds record on create
+ * - mtime/size consistency: the OST adds a record on first write
+ * - open/unlinked objects: OST adds a record on destroy
+ *
+ * - mds unlink log: the MDS adds an entry upon delete
+ *
+ * - raid1 replication log between OST's
+ * - MDS replication logs
+ */
+
+#ifndef _LUSTRE_LOG_H
+#define _LUSTRE_LOG_H
+
+#if defined(__linux__)
+#include <linux/lustre_log.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_log.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_log.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#include <obd.h>
+#include <lustre_idl.h>
+
+#define LOG_NAME_LIMIT(logname, name) \
+ snprintf(logname, sizeof(logname), "LOGS/%s", name)
+#define LLOG_EEMPTY 4711
+
+struct plain_handle_data {
+ struct list_head phd_entry;
+ struct llog_handle *phd_cat_handle;
+ struct llog_cookie phd_cookie; /* cookie of this log in its cat */
+ int phd_last_idx;
+};
+
+struct cat_handle_data {
+ struct list_head chd_head;
+ struct llog_handle *chd_current_log; /* currently open log */
+};
+
+/* In-memory descriptor for a log object or log catalog */
+struct llog_handle {
+ struct rw_semaphore lgh_lock;
+ struct llog_logid lgh_id; /* id of this log */
+ struct llog_log_hdr *lgh_hdr;
+ struct file *lgh_file;
+ int lgh_last_idx;
+ struct llog_ctxt *lgh_ctxt;
+ union {
+ struct plain_handle_data phd;
+ struct cat_handle_data chd;
+ } u;
+};
+
+/* llog.c - general API */
+typedef int (*llog_cb_t)(struct llog_handle *, struct llog_rec_hdr *, void *);
+typedef int (*llog_fill_rec_cb_t)(struct llog_rec_hdr *rec, void *data);
+extern struct llog_handle *llog_alloc_handle(void);
+int llog_init_handle(struct llog_handle *handle, int flags,
+ struct obd_uuid *uuid);
+extern void llog_free_handle(struct llog_handle *handle);
+int llog_process(struct llog_handle *loghandle, llog_cb_t cb,
+ void *data, void *catdata);
+extern int llog_cancel_rec(struct llog_handle *loghandle, int index);
+extern int llog_close(struct llog_handle *cathandle);
+
+/* llog_cat.c - catalog api */
+struct llog_process_data {
+ void *lpd_data;
+ llog_cb_t lpd_cb;
+};
+
+struct llog_process_cat_data {
+ int first_idx;
+ int last_idx;
+ /* to process catalog across zero record */
+};
+
+int llog_cat_put(struct llog_handle *cathandle);
+int llog_cat_add_rec(struct llog_handle *cathandle, struct llog_rec_hdr *rec,
+ struct llog_cookie *reccookie, void *buf);
+int llog_cat_cancel_records(struct llog_handle *cathandle, int count,
+ struct llog_cookie *cookies);
+int llog_cat_process(struct llog_handle *cat_llh, llog_cb_t cb, void *data);
+int llog_cat_set_first_idx(struct llog_handle *cathandle, int index);
+
+/* llog_obd.c */
+int llog_setup(struct obd_device *obd, int index, struct obd_device *disk_obd,
+ int count, struct llog_logid *logid,struct llog_operations *op);
+int llog_cleanup(struct llog_ctxt *);
+int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp);
+int llog_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
+ struct lov_stripe_md *lsm, struct llog_cookie *logcookies,
+ int numcookies);
+int llog_cancel(struct llog_ctxt *, struct lov_stripe_md *lsm,
+ int count, struct llog_cookie *cookies, int flags);
+
+int llog_obd_origin_setup(struct obd_device *obd, int index,
+ struct obd_device *disk_obd, int count,
+ struct llog_logid *logid);
+int llog_obd_origin_cleanup(struct llog_ctxt *ctxt);
+int llog_obd_origin_add(struct llog_ctxt *ctxt,
+ struct llog_rec_hdr *rec, struct lov_stripe_md *lsm,
+ struct llog_cookie *logcookies, int numcookies);
+
+int llog_cat_initialize(struct obd_device *obd, int count);
+int obd_llog_init(struct obd_device *obd, struct obd_device *disk_obd,
+ int count, struct llog_catid *logid);
+
+int obd_llog_finish(struct obd_device *obd, int count);
+
+/* llog_ioctl.c */
+int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data);
+int llog_catalog_list(struct obd_device *obd, int count,
+ struct obd_ioctl_data *data);
+
+/* llog_net.c */
+int llog_initiator_connect(struct llog_ctxt *ctxt);
+int llog_receptor_accept(struct llog_ctxt *ctxt, struct obd_import *imp);
+int llog_origin_connect(struct llog_ctxt *ctxt, int count,
+ struct llog_logid *logid, struct llog_gen *gen,
+ struct obd_uuid *uuid);
+int llog_handle_connect(struct ptlrpc_request *req);
+
+/* recov_thread.c */
+int llog_obd_repl_cancel(struct llog_ctxt *ctxt,
+ struct lov_stripe_md *lsm, int count,
+ struct llog_cookie *cookies, int flags);
+int llog_obd_repl_sync(struct llog_ctxt *ctxt, struct obd_export *exp);
+int llog_repl_connect(struct llog_ctxt *ctxt, int count,
+ struct llog_logid *logid, struct llog_gen *gen,
+ struct obd_uuid *uuid);
+
+struct llog_operations {
+ int (*lop_write_rec)(struct llog_handle *loghandle,
+ struct llog_rec_hdr *rec,
+ struct llog_cookie *logcookies, int numcookies,
+ void *, int idx);
+ int (*lop_destroy)(struct llog_handle *handle);
+ int (*lop_next_block)(struct llog_handle *h, int *curr_idx,
+ int next_idx, __u64 *offset, void *buf, int len);
+ int (*lop_create)(struct llog_ctxt *ctxt, struct llog_handle **,
+ struct llog_logid *logid, char *name);
+ int (*lop_close)(struct llog_handle *handle);
+ int (*lop_read_header)(struct llog_handle *handle);
+
+ int (*lop_setup)(struct obd_device *obd, int ctxt_idx,
+ struct obd_device *disk_obd, int count,
+ struct llog_logid *logid);
+ int (*lop_sync)(struct llog_ctxt *ctxt, struct obd_export *exp);
+ int (*lop_cleanup)(struct llog_ctxt *ctxt);
+ int (*lop_add)(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
+ struct lov_stripe_md *lsm,
+ struct llog_cookie *logcookies, int numcookies);
+ int (*lop_cancel)(struct llog_ctxt *ctxt, struct lov_stripe_md *lsm,
+ int count, struct llog_cookie *cookies, int flags);
+ int (*lop_connect)(struct llog_ctxt *ctxt, int count,
+ struct llog_logid *logid, struct llog_gen *gen,
+ struct obd_uuid *uuid);
+ /* XXX add 2 more: commit callbacks and llog recovery functions */
+};
+
+/* llog_lvfs.c */
+extern struct llog_operations llog_lvfs_ops;
+int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
+ char *name, int count, struct llog_catid *idarray);
+
+struct llog_ctxt {
+ int loc_idx; /* my index the obd array of ctxt's */
+ struct llog_gen loc_gen;
+ struct obd_device *loc_obd; /* points back to the containing obd*/
+ struct obd_export *loc_exp;
+ struct obd_import *loc_imp; /* to use in RPC's: can be backward
+ pointing import */
+ struct llog_operations *loc_logops;
+ struct llog_handle *loc_handle;
+ struct llog_canceld_ctxt *loc_llcd;
+ struct semaphore loc_sem; /* protects loc_llcd and loc_imp */
+ void *llog_proc_cb;
+};
+
+static inline void llog_gen_init(struct llog_ctxt *ctxt)
+{
+ struct obd_device *obd = ctxt->loc_exp->exp_obd;
+
+ if (!strcmp(obd->obd_type->typ_name, "mds"))
+ ctxt->loc_gen.mnt_cnt = obd->u.mds.mds_mount_count;
+ else if (!strstr(obd->obd_type->typ_name, "filter"))
+ ctxt->loc_gen.mnt_cnt = obd->u.filter.fo_mount_count;
+ else
+ ctxt->loc_gen.mnt_cnt = 0;
+}
+
+static inline int llog_gen_lt(struct llog_gen a, struct llog_gen b)
+{
+ if (a.mnt_cnt < b.mnt_cnt)
+ return 1;
+ if (a.mnt_cnt > b.mnt_cnt)
+ return 0;
+ return(a.conn_cnt < b.conn_cnt ? 1 : 0);
+}
+
+#define LLOG_GEN_INC(gen) ((gen).conn_cnt) ++
+#define LLOG_PROC_BREAK 0x0001
+
+static inline int llog_obd2ops(struct llog_ctxt *ctxt,
+ struct llog_operations **lop)
+{
+ if (ctxt == NULL)
+ return -ENOTCONN;
+
+ *lop = ctxt->loc_logops;
+ if (*lop == NULL)
+ return -EOPNOTSUPP;
+
+ return 0;
+}
+
+static inline int llog_handle2ops(struct llog_handle *loghandle,
+ struct llog_operations **lop)
+{
+ if (loghandle == NULL)
+ return -EINVAL;
+
+ return llog_obd2ops(loghandle->lgh_ctxt, lop);
+}
+
+static inline int llog_data_len(int len)
+{
+ return size_round(len);
+}
+
+static inline struct llog_ctxt *llog_get_context(struct obd_device *obd,
+ int index)
+{
+ if (index < 0 || index >= LLOG_MAX_CTXTS)
+ return NULL;
+
+ return obd->obd_llog_ctxt[index];
+}
+
+static inline int llog_write_rec(struct llog_handle *handle,
+ struct llog_rec_hdr *rec,
+ struct llog_cookie *logcookies,
+ int numcookies, void *buf, int idx)
+{
+ struct llog_operations *lop;
+ int rc, buflen;
+ ENTRY;
+
+ rc = llog_handle2ops(handle, &lop);
+ if (rc)
+ RETURN(rc);
+ if (lop->lop_write_rec == NULL)
+ RETURN(-EOPNOTSUPP);
+
+ if (buf)
+ buflen = rec->lrh_len + sizeof(struct llog_rec_hdr)
+ + sizeof(struct llog_rec_tail);
+ else
+ buflen = rec->lrh_len;
+ LASSERT(size_round(buflen) == buflen);
+
+ rc = lop->lop_write_rec(handle, rec, logcookies, numcookies, buf, idx);
+ RETURN(rc);
+}
+
+static inline int llog_read_header(struct llog_handle *handle)
+{
+ struct llog_operations *lop;
+ int rc;
+ ENTRY;
+
+ rc = llog_handle2ops(handle, &lop);
+ if (rc)
+ RETURN(rc);
+ if (lop->lop_read_header == NULL)
+ RETURN(-EOPNOTSUPP);
+
+ rc = lop->lop_read_header(handle);
+ RETURN(rc);
+}
+
+static inline int llog_destroy(struct llog_handle *handle)
+{
+ struct llog_operations *lop;
+ int rc;
+ ENTRY;
+
+ rc = llog_handle2ops(handle, &lop);
+ if (rc)
+ RETURN(rc);
+ if (lop->lop_destroy == NULL)
+ RETURN(-EOPNOTSUPP);
+
+ rc = lop->lop_destroy(handle);
+ RETURN(rc);
+}
+
+#if 0
+static inline int llog_cancel(struct obd_export *exp,
+ struct lov_stripe_md *lsm, int count,
+ struct llog_cookie *cookies, int flags)
+{
+ struct llog_operations *lop;
+ int rc;
+ ENTRY;
+
+ rc = llog_handle2ops(loghandle, &lop);
+ if (rc)
+ RETURN(rc);
+ if (lop->lop_cancel == NULL)
+ RETURN(-EOPNOTSUPP);
+
+ rc = lop->lop_cancel(exp, lsm, count, cookies, flags);
+ RETURN(rc);
+}
+#endif
+
+static inline int llog_next_block(struct llog_handle *loghandle, int *cur_idx,
+ int next_idx, __u64 *cur_offset, void *buf,
+ int len)
+{
+ struct llog_operations *lop;
+ int rc;
+ ENTRY;
+
+ rc = llog_handle2ops(loghandle, &lop);
+ if (rc)
+ RETURN(rc);
+ if (lop->lop_next_block == NULL)
+ RETURN(-EOPNOTSUPP);
+
+ rc = lop->lop_next_block(loghandle, cur_idx, next_idx, cur_offset, buf,
+ len);
+ RETURN(rc);
+}
+
+static inline int llog_create(struct llog_ctxt *ctxt, struct llog_handle **res,
+ struct llog_logid *logid, char *name)
+{
+ struct llog_operations *lop;
+ int rc;
+ ENTRY;
+
+ rc = llog_obd2ops(ctxt, &lop);
+ if (rc)
+ RETURN(rc);
+ if (lop->lop_create == NULL)
+ RETURN(-EOPNOTSUPP);
+
+ rc = lop->lop_create(ctxt, res, logid, name);
+ RETURN(rc);
+}
+
+static inline int llog_connect(struct llog_ctxt *ctxt, int count,
+ struct llog_logid *logid, struct llog_gen *gen,
+ struct obd_uuid *uuid)
+{
+ struct llog_operations *lop;
+ int rc;
+ ENTRY;
+
+ rc = llog_obd2ops(ctxt, &lop);
+ if (rc)
+ RETURN(rc);
+ if (lop->lop_connect == NULL)
+ RETURN(-EOPNOTSUPP);
+
+ rc = lop->lop_connect(ctxt, count, logid, gen, uuid);
+ RETURN(rc);
+}
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * This file is part of Lustre, http://www.lustre.org
+ *
+ * MDS data structures.
+ * See also lustre_idl.h for wire formats of requests.
+ */
+
+#ifndef _LUSTRE_MDS_H
+#define _LUSTRE_MDS_H
+
+#include <lustre_handles.h>
+#include <libcfs/kp30.h>
+#include <lustre_idl.h>
+#include <lustre_lib.h>
+#include <lustre_dlm.h>
+#include <lustre_log.h>
+#include <lustre_export.h>
+
+#if defined(__linux__)
+#include <linux/lustre_mds.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_mds.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_mds.h>
+#else
+#error Unsupported operating system.
+#endif
+
+struct ldlm_lock_desc;
+struct mds_obd;
+struct ptlrpc_connection;
+struct ptlrpc_client;
+struct obd_export;
+struct ptlrpc_request;
+struct obd_device;
+struct ll_file_data;
+
+#define LUSTRE_MDS_NAME "mds"
+#define LUSTRE_MDT_NAME "mdt"
+#define LUSTRE_MDC_NAME "mdc"
+
+struct lustre_md {
+ struct mds_body *body;
+ struct lov_stripe_md *lsm;
+ struct posix_acl *posix_acl;
+};
+
+struct mdc_op_data {
+ struct ll_fid fid1;
+ struct ll_fid fid2;
+ __u64 mod_time;
+ const char *name;
+ int namelen;
+ __u32 create_mode;
+ __u32 suppgids[2];
+};
+
+struct mds_update_record {
+ __u32 ur_opcode;
+ struct ll_fid *ur_fid1;
+ struct ll_fid *ur_fid2;
+ int ur_namelen;
+ char *ur_name;
+ int ur_tgtlen;
+ char *ur_tgt;
+ int ur_eadatalen;
+ void *ur_eadata;
+ int ur_cookielen;
+ struct llog_cookie *ur_logcookies;
+ struct iattr ur_iattr;
+ struct lvfs_ucred ur_uc;
+ __u64 ur_rdev;
+ __u64 ur_time;
+ __u32 ur_mode;
+ __u32 ur_flags;
+ struct lvfs_grp_hash_entry *ur_grp_entry;
+};
+
+#define MDS_LR_SERVER_SIZE 512
+
+#define MDS_LR_CLIENT_START 8192
+#define MDS_LR_CLIENT_SIZE 128
+#if MDS_LR_CLIENT_START < MDS_LR_SERVER_SIZE
+#error "Can't have MDS_LR_CLIENT_START < MDS_LR_SERVER_SIZE"
+#endif
+
+#define MDS_CLIENT_SLOTS 17
+
+#define MDS_ROCOMPAT_LOVOBJID 0x00000001
+#define MDS_ROCOMPAT_SUPP (MDS_ROCOMPAT_LOVOBJID)
+
+#define MDS_INCOMPAT_SUPP (0)
+
+/* Data stored per server at the head of the last_rcvd file. In le32 order.
+ * Try to keep this the same as fsd_server_data so we might one day merge. */
+struct mds_server_data {
+ __u8 msd_uuid[40]; /* server UUID */
+ __u64 msd_last_transno; /* last completed transaction ID */
+ __u64 msd_mount_count; /* MDS incarnation number */
+ __u64 msd_unused;
+ __u32 msd_feature_compat; /* compatible feature flags */
+ __u32 msd_feature_rocompat;/* read-only compatible feature flags */
+ __u32 msd_feature_incompat;/* incompatible feature flags */
+ __u32 msd_server_size; /* size of server data area */
+ __u32 msd_client_start; /* start of per-client data area */
+ __u16 msd_client_size; /* size of per-client data area */
+ __u16 msd_subdir_count; /* number of subdirectories for objects */
+ __u64 msd_catalog_oid; /* recovery catalog object id */
+ __u32 msd_catalog_ogen; /* recovery catalog inode generation */
+ __u8 msd_peeruuid[40]; /* UUID of LOV/OSC associated with MDS */
+ __u8 msd_padding[MDS_LR_SERVER_SIZE - 140];
+};
+
+/* Data stored per client in the last_rcvd file. In le32 order. */
+struct mds_client_data {
+ __u8 mcd_uuid[40]; /* client UUID */
+ __u64 mcd_last_transno; /* last completed transaction ID */
+ __u64 mcd_last_xid; /* xid for the last transaction */
+ __u32 mcd_last_result; /* result from last RPC */
+ __u32 mcd_last_data; /* per-op data (disposition for open &c.) */
+ __u8 mcd_padding[MDS_LR_CLIENT_SIZE - 64];
+};
+
+/* file data for open files on MDS */
+struct mds_file_data {
+ struct portals_handle mfd_handle; /* must be first */
+ atomic_t mfd_refcount;
+ struct list_head mfd_list; /* protected by med_open_lock */
+ __u64 mfd_xid;
+ int mfd_mode;
+ struct dentry *mfd_dentry;
+};
+
+/* ACL */
+#define LUSTRE_POSIX_ACL_MAX_ENTRIES (32)
+#define LUSTRE_POSIX_ACL_MAX_SIZE \
+ (xattr_acl_size(LUSTRE_POSIX_ACL_MAX_ENTRIES))
+
+/* mds/mds_reint.c */
+int mds_reint_rec(struct mds_update_record *r, int offset,
+ struct ptlrpc_request *req, struct lustre_handle *);
+
+/* mds/mds_lov.c */
+
+/* mdc/mdc_locks.c */
+int it_disposition(struct lookup_intent *it, int flag);
+void it_set_disposition(struct lookup_intent *it, int flag);
+int it_open_error(int phase, struct lookup_intent *it);
+void mdc_set_lock_data(__u64 *lockh, void *data);
+int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid,
+ ldlm_iterator_t it, void *data);
+int mdc_intent_lock(struct obd_export *exp,
+ struct mdc_op_data *,
+ void *lmm, int lmmsize,
+ struct lookup_intent *, int,
+ struct ptlrpc_request **reqp,
+ ldlm_blocking_callback cb_blocking, int extra_lock_flags);
+int mdc_enqueue(struct obd_export *exp,
+ int lock_type,
+ struct lookup_intent *it,
+ int lock_mode,
+ struct mdc_op_data *data,
+ struct lustre_handle *lockh,
+ void *lmm,
+ int lmmlen,
+ ldlm_completion_callback cb_completion,
+ ldlm_blocking_callback cb_blocking,
+ void *cb_data, int extra_lock_flags);
+
+/* mdc/mdc_request.c */
+int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp);
+int mdc_req2lustre_md(struct ptlrpc_request *req, int offset,
+ struct obd_export *exp, struct lustre_md *md);
+void mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md);
+int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid);
+int mdc_getattr(struct obd_export *exp, struct ll_fid *fid,
+ obd_valid valid, unsigned int ea_size,
+ struct ptlrpc_request **request);
+int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
+ char *filename, int namelen, unsigned long valid,
+ unsigned int ea_size, struct ptlrpc_request **request);
+int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data,
+ struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len,
+ struct ptlrpc_request **request);
+int mdc_setxattr(struct obd_export *exp, struct ll_fid *fid,
+ obd_valid valid, const char *xattr_name,
+ const char *input, int input_size,
+ int output_size, int flags,
+ struct ptlrpc_request **request);
+int mdc_getxattr(struct obd_export *exp, struct ll_fid *fid,
+ obd_valid valid, const char *xattr_name,
+ const char *input, int input_size,
+ int output_size, struct ptlrpc_request **request);
+int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags,
+ struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh,
+ struct ptlrpc_request **);
+struct obd_client_handle;
+void mdc_set_open_replay_data(struct obd_client_handle *och,
+ struct ptlrpc_request *open_req);
+void mdc_clear_open_replay_data(struct obd_client_handle *och);
+int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *,
+ struct ptlrpc_request **);
+int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset,
+ struct page *, struct ptlrpc_request **);
+int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
+ const void *data, int datalen, int mode, __u32 uid, __u32 gid,
+ __u32 cap_effective, __u64 rdev,struct ptlrpc_request **request);
+int mdc_unlink(struct obd_export *exp, struct mdc_op_data *data,
+ struct ptlrpc_request **request);
+int mdc_link(struct obd_export *exp, struct mdc_op_data *data,
+ struct ptlrpc_request **);
+int mdc_rename(struct obd_export *exp, struct mdc_op_data *data,
+ const char *old, int oldlen, const char *new, int newlen,
+ struct ptlrpc_request **request);
+int mdc_sync(struct obd_export *exp, struct ll_fid *fid,
+ struct ptlrpc_request **);
+int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl);
+
+/* Store the generation of a newly-created inode in |req| for replay. */
+void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
+ int repoff);
+int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data);
+int mdc_done_writing(struct obd_export *exp, struct obdo *);
+
+static inline void mdc_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen,
+ int type)
+{
+ fid->id = ino;
+ fid->generation = gen;
+ fid->f_type = type;
+}
+
+/* ioctls for trying requests */
+#define IOC_REQUEST_TYPE 'f'
+#define IOC_REQUEST_MIN_NR 30
+
+#define IOC_REQUEST_GETATTR _IOWR('f', 30, long)
+#define IOC_REQUEST_READPAGE _IOWR('f', 31, long)
+#define IOC_REQUEST_SETATTR _IOWR('f', 32, long)
+#define IOC_REQUEST_CREATE _IOWR('f', 33, long)
+#define IOC_REQUEST_OPEN _IOWR('f', 34, long)
+#define IOC_REQUEST_CLOSE _IOWR('f', 35, long)
+#define IOC_REQUEST_MAX_NR 35
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _LUSTRE_NET_H
+#define _LUSTRE_NET_H
+
+#if defined(__linux__)
+#include <linux/lustre_net.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_net.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_net.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#include <libcfs/kp30.h>
+// #include <obd.h>
+#include <lnet/lnet.h>
+#include <lustre_idl.h>
+#include <lustre_ha.h>
+#include <lustre_import.h>
+#include <lprocfs_status.h>
+
+/* MD flags we _always_ use */
+#define PTLRPC_MD_OPTIONS 0
+
+/* Define maxima for bulk I/O
+ * CAVEAT EMPTOR, with multinet (i.e. routers forwarding between networks)
+ * these limits are system wide and not interface-local. */
+#define PTLRPC_MAX_BRW_SIZE LNET_MTU
+#define PTLRPC_MAX_BRW_PAGES (PTLRPC_MAX_BRW_SIZE/CFS_PAGE_SIZE)
+
+/* When PAGE_SIZE is a constant, we can check our arithmetic here with cpp! */
+#ifdef __KERNEL__
+# if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0)
+# error "PTLRPC_MAX_BRW_PAGES isn't a power of two"
+# endif
+# if (PTLRPC_MAX_BRW_SIZE != (PTLRPC_MAX_BRW_PAGES * CFS_PAGE_SIZE))
+# error "PTLRPC_MAX_BRW_SIZE isn't PTLRPC_MAX_BRW_PAGES * CFS_PAGE_SIZE"
+# endif
+# if (PTLRPC_MAX_BRW_SIZE > LNET_MTU)
+# error "PTLRPC_MAX_BRW_SIZE too big"
+# endif
+# if (PTLRPC_MAX_BRW_PAGES > LNET_MAX_IOV)
+# error "PTLRPC_MAX_BRW_PAGES too big"
+# endif
+#endif /* __KERNEL__ */
+
+/* Size over which to OBD_VMALLOC() rather than OBD_ALLOC() service request
+ * buffers */
+#define SVC_BUF_VMALLOC_THRESHOLD (2 * PAGE_SIZE)
+
+/* The following constants determine how memory is used to buffer incoming
+ * service requests.
+ *
+ * ?_NBUFS # buffers to allocate when growing the pool
+ * ?_BUFSIZE # bytes in a single request buffer
+ * ?_MAXREQSIZE # maximum request service will receive
+ *
+ * When fewer than ?_NBUFS/2 buffers are posted for receive, another chunk
+ * of ?_NBUFS is added to the pool.
+ *
+ * Messages larger than ?_MAXREQSIZE are dropped. Request buffers are
+ * considered full when less than ?_MAXREQSIZE is left in them.
+ */
+
+#define LDLM_NUM_THREADS min((int)(smp_num_cpus * smp_num_cpus * 8), 64)
+#define LDLM_NBUFS 64
+#define LDLM_BUFSIZE (8 * 1024)
+#define LDLM_MAXREQSIZE (5 * 1024)
+#define LDLM_MAXREPSIZE (1024)
+
+#define MDT_MAX_THREADS 32UL
+#define MDT_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
+ MDT_MAX_THREADS), 2UL)
+#define MDS_NBUFS (64 * smp_num_cpus)
+#define MDS_BUFSIZE (8 * 1024)
+/* Assume file name length = FNAME_MAX = 256 (true for ext3).
+ * path name length = PATH_MAX = 4096
+ * LOV MD size max = EA_MAX = 4000
+ * symlink: FNAME_MAX + PATH_MAX <- largest
+ * link: FNAME_MAX + PATH_MAX (mds_rec_link < mds_rec_create)
+ * rename: FNAME_MAX + FNAME_MAX
+ * open: FNAME_MAX + EA_MAX
+ *
+ * MDS_MAXREQSIZE ~= 4736 bytes =
+ * lustre_msg + ldlm_request + mds_body + mds_rec_create + FNAME_MAX + PATH_MAX
+ *
+ * Realistic size is about 512 bytes (20 character name + 128 char symlink),
+ * except in the open case where there are a large number of OSTs in a LOV.
+ */
+#define MDS_MAXREQSIZE (5 * 1024)
+#define MDS_MAXREPSIZE (9 * 1024)
+
+#define OST_MAX_THREADS 36UL
+#define OST_NUM_THREADS max(min_t(unsigned long, num_physpages / 8192, \
+ OST_MAX_THREADS), 2UL)
+#define OST_NBUFS (64 * smp_num_cpus)
+#define OST_BUFSIZE (8 * 1024)
+/* OST_MAXREQSIZE ~= 4768 bytes =
+ * lustre_msg + obdo + 16 * obd_ioobj + 256 * niobuf_remote
+ *
+ * - single object with 16 pages is 512 bytes
+ * - OST_MAXREQSIZE must be at least 1 page of cookies plus some spillover
+ */
+#define OST_MAXREQSIZE (5 * 1024)
+#define OST_MAXREPSIZE (9 * 1024)
+
+#define PTLBD_NUM_THREADS 4
+#define PTLBD_NBUFS 64
+#define PTLBD_BUFSIZE (32 * 1024)
+#define PTLBD_MAXREQSIZE 1024
+
+struct ptlrpc_connection {
+ struct list_head c_link;
+ lnet_nid_t c_self;
+ lnet_process_id_t c_peer;
+ struct obd_uuid c_remote_uuid;
+ atomic_t c_refcount;
+};
+
+struct ptlrpc_client {
+ __u32 cli_request_portal;
+ __u32 cli_reply_portal;
+ char *cli_name;
+};
+
+/* state flags of requests */
+/* XXX only ones left are those used by the bulk descs as well! */
+#define PTL_RPC_FL_INTR (1 << 0) /* reply wait was interrupted by user */
+#define PTL_RPC_FL_TIMEOUT (1 << 7) /* request timed out waiting for reply */
+
+#define REQ_MAX_ACK_LOCKS 8
+
+#define SWAB_PARANOIA 1
+#if SWAB_PARANOIA
+/* unpacking: assert idx not unpacked already */
+#define LASSERT_REQSWAB(rq, idx) \
+do { \
+ LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8); \
+ LASSERT (((rq)->rq_req_swab_mask & (1 << (idx))) == 0); \
+ (rq)->rq_req_swab_mask |= (1 << (idx)); \
+} while (0)
+
+#define LASSERT_REPSWAB(rq, idx) \
+do { \
+ LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8); \
+ LASSERT (((rq)->rq_rep_swab_mask & (1 << (idx))) == 0); \
+ (rq)->rq_rep_swab_mask |= (1 << (idx)); \
+} while (0)
+
+/* just looking: assert idx already unpacked */
+#define LASSERT_REQSWABBED(rq, idx) \
+LASSERT ((idx) < sizeof ((rq)->rq_req_swab_mask) * 8 && \
+ ((rq)->rq_req_swab_mask & (1 << (idx))) != 0)
+
+#define LASSERT_REPSWABBED(rq, idx) \
+LASSERT ((idx) < sizeof ((rq)->rq_rep_swab_mask) * 8 && \
+ ((rq)->rq_rep_swab_mask & (1 << (idx))) != 0)
+#else
+#define LASSERT_REQSWAB(rq, idx)
+#define LASSERT_REPSWAB(rq, idx)
+#define LASSERT_REQSWABBED(rq, idx)
+#define LASSERT_REPSWABBED(rq, idx)
+#endif
+
+union ptlrpc_async_args {
+ /* Scratchpad for passing args to completion interpreter. Users
+ * cast to the struct of their choosing, and LASSERT that this is
+ * big enough. For _tons_ of context, OBD_ALLOC a struct and store
+ * a pointer to it here. The pointer_arg ensures this struct is at
+ * least big enough for that. */
+ void *pointer_arg[9];
+ __u64 space[4];
+};
+
+struct ptlrpc_request_set;
+typedef int (*set_interpreter_func)(struct ptlrpc_request_set *, void *, int);
+
+struct ptlrpc_request_set {
+ int set_remaining; /* # uncompleted requests */
+ cfs_waitq_t set_waitq;
+ cfs_waitq_t *set_wakeup_ptr;
+ struct list_head set_requests;
+ set_interpreter_func set_interpret; /* completion callback */
+ void *set_arg; /* completion context */
+ /* locked so that any old caller can communicate requests to
+ * the set holder who can then fold them into the lock-free set */
+ spinlock_t set_new_req_lock;
+ struct list_head set_new_requests;
+};
+
+struct ptlrpc_bulk_desc;
+
+/*
+ * ptlrpc callback & work item stuff
+ */
+struct ptlrpc_cb_id {
+ void (*cbid_fn)(lnet_event_t *ev); /* specific callback fn */
+ void *cbid_arg; /* additional arg */
+};
+
+#define RS_MAX_LOCKS 4
+#define RS_DEBUG 1
+
+struct ptlrpc_reply_state {
+ struct ptlrpc_cb_id rs_cb_id;
+ struct list_head rs_list;
+ struct list_head rs_exp_list;
+ struct list_head rs_obd_list;
+#if RS_DEBUG
+ struct list_head rs_debug_list;
+#endif
+ /* updates to following flag serialised by srv_request_lock */
+ unsigned int rs_difficult:1; /* ACK/commit stuff */
+ unsigned int rs_scheduled:1; /* being handled? */
+ unsigned int rs_scheduled_ever:1;/* any schedule attempts? */
+ unsigned int rs_handled:1; /* been handled yet? */
+ unsigned int rs_on_net:1; /* reply_out_callback pending? */
+ unsigned int rs_prealloc:1; /* rs from prealloc list */
+
+ int rs_size;
+ __u64 rs_transno;
+ __u64 rs_xid;
+ struct obd_export *rs_export;
+ struct ptlrpc_service *rs_service;
+ lnet_handle_md_t rs_md_h;
+ atomic_t rs_refcount;
+
+ /* locks awaiting client reply ACK */
+ int rs_nlocks;
+ struct lustre_handle rs_locks[RS_MAX_LOCKS];
+ ldlm_mode_t rs_modes[RS_MAX_LOCKS];
+ /* last member: variable sized reply message */
+ struct lustre_msg rs_msg;
+};
+
+struct ptlrpc_thread;
+
+enum rq_phase {
+ RQ_PHASE_NEW = 0xebc0de00,
+ RQ_PHASE_RPC = 0xebc0de01,
+ RQ_PHASE_BULK = 0xebc0de02,
+ RQ_PHASE_INTERPRET = 0xebc0de03,
+ RQ_PHASE_COMPLETE = 0xebc0de04,
+};
+
+struct ptlrpc_request_pool {
+ spinlock_t prp_lock;
+ struct list_head prp_req_list; /* list of ptlrpc_request structs */
+ int prp_rq_size;
+ void (*prp_populate)(struct ptlrpc_request_pool *, int);
+};
+
+struct ptlrpc_request {
+ int rq_type; /* one of PTL_RPC_MSG_* */
+ struct list_head rq_list;
+ struct list_head rq_history_list; /* server-side history */
+ __u64 rq_history_seq; /* history sequence # */
+ int rq_status;
+ spinlock_t rq_lock;
+ /* client-side flags */
+ unsigned int rq_intr:1, rq_replied:1, rq_err:1,
+ rq_timedout:1, rq_resend:1, rq_restart:1, rq_replay:1,
+ rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
+ rq_no_delay:1, rq_net_err:1;
+ enum rq_phase rq_phase; /* one of RQ_PHASE_* */
+ atomic_t rq_refcount; /* client-side refcount for SENT race */
+
+ struct ptlrpc_thread *rq_svc_thread; /* initial thread servicing req */
+
+ int rq_request_portal; /* XXX FIXME bug 249 */
+ int rq_reply_portal; /* XXX FIXME bug 249 */
+
+ int rq_nob_received; /* client-side # reply bytes actually received */
+
+ int rq_reqlen;
+ struct lustre_msg *rq_reqmsg;
+
+ int rq_timeout; /* seconds */
+ int rq_replen;
+ struct lustre_msg *rq_repmsg;
+ __u64 rq_transno;
+ __u64 rq_xid;
+ struct list_head rq_replay_list;
+
+#if SWAB_PARANOIA
+ __u32 rq_req_swab_mask;
+ __u32 rq_rep_swab_mask;
+#endif
+
+ int rq_import_generation;
+ enum lustre_imp_state rq_send_state;
+
+ /* client+server request */
+ lnet_handle_md_t rq_req_md_h;
+ struct ptlrpc_cb_id rq_req_cbid;
+
+ /* server-side... */
+ struct timeval rq_arrival_time; /* request arrival time */
+ struct ptlrpc_reply_state *rq_reply_state; /* separated reply state */
+ struct ptlrpc_request_buffer_desc *rq_rqbd; /* incoming request buffer*/
+#if CRAY_XT3
+# error "Need to get the uid from the event?"
+ __u32 rq_uid; /* peer uid, used in MDS only */
+#endif
+
+ /* client-only incoming reply */
+ lnet_handle_md_t rq_reply_md_h;
+ cfs_waitq_t rq_reply_waitq;
+ struct ptlrpc_cb_id rq_reply_cbid;
+
+ lnet_nid_t rq_self;
+ lnet_process_id_t rq_peer;
+ struct obd_export *rq_export;
+ struct obd_import *rq_import;
+
+ void (*rq_replay_cb)(struct ptlrpc_request *);
+ void (*rq_commit_cb)(struct ptlrpc_request *);
+ void *rq_cb_data;
+
+ struct ptlrpc_bulk_desc *rq_bulk; /* client side bulk */
+ time_t rq_sent; /* when request sent, seconds */
+
+ /* Multi-rpc bits */
+ struct list_head rq_set_chain;
+ struct ptlrpc_request_set *rq_set;
+ void *rq_interpret_reply; /* Async completion handler */
+ union ptlrpc_async_args rq_async_args; /* Async completion context */
+ void *rq_ptlrpcd_data;
+ struct ptlrpc_request_pool *rq_pool; /* Pool if request from
+ preallocated list */
+};
+
+static inline const char *
+ptlrpc_rqphase2str(struct ptlrpc_request *req)
+{
+ switch (req->rq_phase) {
+ case RQ_PHASE_NEW:
+ return "New";
+ case RQ_PHASE_RPC:
+ return "Rpc";
+ case RQ_PHASE_BULK:
+ return "Bulk";
+ case RQ_PHASE_INTERPRET:
+ return "Interpret";
+ case RQ_PHASE_COMPLETE:
+ return "Complete";
+ default:
+ return "?Phase?";
+ }
+}
+
+/* Spare the preprocessor, spoil the bugs. */
+#define FLAG(field, str) (field ? str : "")
+
+#define DEBUG_REQ_FLAGS(req) \
+ ptlrpc_rqphase2str(req), \
+ FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"), \
+ FLAG(req->rq_err, "E"), \
+ FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \
+ FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"), \
+ FLAG(req->rq_no_resend, "N"), \
+ FLAG(req->rq_waiting, "W")
+
+#define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s"
+
+#define __DEBUG_REQ(CDEB_TYPE, level, req, fmt, args...) \
+CDEB_TYPE(level, "@@@ " fmt \
+ " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d lens %d/%d ref %d fl " \
+ REQ_FLAGS_FMT"/%x/%x rc %d/%d\n" , ## args, req, req->rq_xid, \
+ req->rq_transno, \
+ req->rq_reqmsg ? req->rq_reqmsg->opc : -1, \
+ req->rq_import ? (char *)req->rq_import->imp_target_uuid.uuid : "<?>", \
+ req->rq_import ? \
+ (char *)req->rq_import->imp_connection->c_remote_uuid.uuid : "<?>", \
+ (req->rq_import && req->rq_import->imp_client) ? \
+ req->rq_import->imp_client->cli_request_portal : -1, \
+ req->rq_reqlen, req->rq_replen, \
+ atomic_read(&req->rq_refcount), \
+ DEBUG_REQ_FLAGS(req), \
+ req->rq_reqmsg ? req->rq_reqmsg->flags : 0, \
+ req->rq_repmsg ? req->rq_repmsg->flags : 0, \
+ req->rq_status, req->rq_repmsg ? req->rq_repmsg->status : 0)
+
+/* for most callers (level is a constant) this is resolved at compile time */
+#define DEBUG_REQ(level, req, fmt, args...) \
+do { \
+ if ((level) & (D_ERROR | D_WARNING)) \
+ __DEBUG_REQ(CDEBUG_LIMIT, level, req, fmt, ## args); \
+ else \
+ __DEBUG_REQ(CDEBUG, level, req, fmt, ## args); \
+} while (0)
+
+struct ptlrpc_bulk_page {
+ struct list_head bp_link;
+ int bp_buflen;
+ int bp_pageoffset; /* offset within a page */
+ struct page *bp_page;
+};
+
+#define BULK_GET_SOURCE 0
+#define BULK_PUT_SINK 1
+#define BULK_GET_SINK 2
+#define BULK_PUT_SOURCE 3
+
+struct ptlrpc_bulk_desc {
+ unsigned int bd_success:1; /* completed successfully */
+ unsigned int bd_network_rw:1; /* accessible to the network */
+ unsigned int bd_type:2; /* {put,get}{source,sink} */
+ unsigned int bd_registered:1; /* client side */
+ spinlock_t bd_lock; /* serialise with callback */
+ int bd_import_generation;
+ struct obd_export *bd_export;
+ struct obd_import *bd_import;
+ __u32 bd_portal;
+ struct ptlrpc_request *bd_req; /* associated request */
+ cfs_waitq_t bd_waitq; /* server side only WQ */
+ int bd_iov_count; /* # entries in bd_iov */
+ int bd_max_iov; /* allocated size of bd_iov */
+ int bd_nob; /* # bytes covered */
+ int bd_nob_transferred; /* # bytes GOT/PUT */
+
+ __u64 bd_last_xid;
+
+ struct ptlrpc_cb_id bd_cbid; /* network callback info */
+ lnet_handle_md_t bd_md_h; /* associated MD */
+
+#if defined(__KERNEL__)
+ lnet_kiov_t bd_iov[0];
+#else
+ lnet_md_iovec_t bd_iov[0];
+#endif
+};
+
+struct ptlrpc_thread {
+
+ struct list_head t_link; /* active threads for service, from svc->srv_threads */
+
+ void *t_data; /* thread-private data (preallocated memory) */
+ __u32 t_flags;
+
+ unsigned int t_id; /* service thread index, from ptlrpc_start_threads */
+ cfs_waitq_t t_ctl_waitq;
+};
+
+struct ptlrpc_request_buffer_desc {
+ struct list_head rqbd_list;
+ struct list_head rqbd_reqs;
+ struct ptlrpc_service *rqbd_service;
+ lnet_handle_md_t rqbd_md_h;
+ int rqbd_refcount;
+ char *rqbd_buffer;
+ struct ptlrpc_cb_id rqbd_cbid;
+ struct ptlrpc_request rqbd_req;
+};
+
+typedef int (*svc_handler_t)(struct ptlrpc_request *req);
+typedef void (*svcreq_printfn_t)(void *, struct ptlrpc_request *);
+
+struct ptlrpc_service {
+ struct list_head srv_list; /* chain thru all services */
+ int srv_max_req_size; /* biggest request to receive */
+ int srv_max_reply_size; /* biggest reply to send */
+ int srv_buf_size; /* size of individual buffers */
+ int srv_nbuf_per_group; /* # buffers to allocate in 1 group */
+ int srv_nbufs; /* total # req buffer descs allocated */
+ int srv_nthreads; /* # running threads */
+ int srv_n_difficult_replies; /* # 'difficult' replies */
+ int srv_n_active_reqs; /* # reqs being served */
+ cfs_duration_t srv_rqbd_timeout; /* timeout before re-posting reqs, in tick */
+ int srv_watchdog_timeout; /* soft watchdog timeout, in ms */
+ int srv_num_threads; /* # threads to start/started */
+ unsigned srv_cpu_affinity:1; /* bind threads to CPUs */
+
+ __u32 srv_req_portal;
+ __u32 srv_rep_portal;
+
+ int srv_n_queued_reqs; /* # reqs waiting to be served */
+ struct list_head srv_request_queue; /* reqs waiting for service */
+
+ struct list_head srv_request_history; /* request history */
+ __u64 srv_request_seq; /* next request sequence # */
+ __u64 srv_request_max_cull_seq; /* highest seq culled from history */
+ svcreq_printfn_t srv_request_history_print_fn; /* service-specific print fn */
+
+ struct list_head srv_idle_rqbds; /* request buffers to be reposted */
+ struct list_head srv_active_rqbds; /* req buffers receiving */
+ struct list_head srv_history_rqbds; /* request buffer history */
+ int srv_nrqbd_receiving; /* # posted request buffers */
+ int srv_n_history_rqbds; /* # request buffers in history */
+ int srv_max_history_rqbds; /* max # request buffers in history */
+
+ atomic_t srv_outstanding_replies;
+ struct list_head srv_active_replies; /* all the active replies */
+ struct list_head srv_reply_queue; /* replies waiting for service */
+
+ cfs_waitq_t srv_waitq; /* all threads sleep on this */
+
+ struct list_head srv_threads;
+ struct obd_device *srv_obddev;
+ svc_handler_t srv_handler;
+
+ char *srv_name; /* only statically allocated strings here; we don't clean them */
+
+ spinlock_t srv_lock;
+
+ cfs_proc_dir_entry_t *srv_procroot;
+ struct lprocfs_stats *srv_stats;
+
+ /* List of free reply_states */
+ struct list_head srv_free_rs_list;
+ /* waitq to run, when adding stuff to srv_free_rs_list */
+ cfs_waitq_t srv_free_rs_waitq;
+
+ /*
+ * if non-NULL called during thread creation (ptlrpc_start_thread())
+ * to initialize service specific per-thread state.
+ */
+ int (*srv_init)(struct ptlrpc_thread *thread);
+ /*
+ * if non-NULL called during thread shutdown (ptlrpc_main()) to
+ * destruct state created by ->srv_init().
+ */
+ void (*srv_done)(struct ptlrpc_thread *thread);
+
+ //struct ptlrpc_srv_ni srv_interfaces[0];
+};
+
+/* ptlrpc/events.c */
+extern lnet_handle_eq_t ptlrpc_eq_h;
+extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
+ lnet_process_id_t *peer, lnet_nid_t *self);
+extern void request_out_callback (lnet_event_t *ev);
+extern void reply_in_callback(lnet_event_t *ev);
+extern void client_bulk_callback (lnet_event_t *ev);
+extern void request_in_callback(lnet_event_t *ev);
+extern void reply_out_callback(lnet_event_t *ev);
+extern void server_bulk_callback (lnet_event_t *ev);
+
+/* ptlrpc/connection.c */
+void ptlrpc_dump_connections(void);
+void ptlrpc_readdress_connection(struct ptlrpc_connection *, struct obd_uuid *);
+struct ptlrpc_connection *ptlrpc_get_connection(lnet_process_id_t peer,
+ lnet_nid_t self, struct obd_uuid *uuid);
+int ptlrpc_put_connection(struct ptlrpc_connection *c);
+struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
+void ptlrpc_init_connection(void);
+void ptlrpc_cleanup_connection(void);
+extern lnet_pid_t ptl_get_pid(void);
+
+/* ptlrpc/niobuf.c */
+int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
+void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
+int ptlrpc_register_bulk(struct ptlrpc_request *req);
+void ptlrpc_unregister_bulk (struct ptlrpc_request *req);
+
+static inline int ptlrpc_bulk_active (struct ptlrpc_bulk_desc *desc)
+{
+ unsigned long flags;
+ int rc;
+
+ spin_lock_irqsave (&desc->bd_lock, flags);
+ rc = desc->bd_network_rw;
+ spin_unlock_irqrestore (&desc->bd_lock, flags);
+ return (rc);
+}
+
+int ptlrpc_send_reply(struct ptlrpc_request *req, int);
+int ptlrpc_reply(struct ptlrpc_request *req);
+int ptlrpc_error(struct ptlrpc_request *req);
+void ptlrpc_resend_req(struct ptlrpc_request *request);
+int ptl_send_rpc(struct ptlrpc_request *request);
+int ptl_send_rpc_nowait(struct ptlrpc_request *request);
+int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd);
+
+/* ptlrpc/client.c */
+void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
+ struct ptlrpc_client *);
+void ptlrpc_cleanup_client(struct obd_import *imp);
+struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
+
+static inline int
+ptlrpc_client_receiving_reply (struct ptlrpc_request *req)
+{
+ unsigned long flags;
+ int rc;
+
+ spin_lock_irqsave(&req->rq_lock, flags);
+ rc = req->rq_receiving_reply;
+ spin_unlock_irqrestore(&req->rq_lock, flags);
+ return (rc);
+}
+
+static inline int
+ptlrpc_client_replied (struct ptlrpc_request *req)
+{
+ unsigned long flags;
+ int rc;
+
+ spin_lock_irqsave(&req->rq_lock, flags);
+ rc = req->rq_replied;
+ spin_unlock_irqrestore(&req->rq_lock, flags);
+ return (rc);
+}
+
+static inline void
+ptlrpc_wake_client_req (struct ptlrpc_request *req)
+{
+ if (req->rq_set == NULL)
+ cfs_waitq_signal(&req->rq_reply_waitq);
+ else
+ cfs_waitq_signal(&req->rq_set->set_waitq);
+}
+
+int ptlrpc_queue_wait(struct ptlrpc_request *req);
+int ptlrpc_replay_req(struct ptlrpc_request *req);
+void ptlrpc_unregister_reply(struct ptlrpc_request *req);
+void ptlrpc_restart_req(struct ptlrpc_request *req);
+void ptlrpc_abort_inflight(struct obd_import *imp);
+
+struct ptlrpc_request_set *ptlrpc_prep_set(void);
+int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
+int ptlrpc_check_set(struct ptlrpc_request_set *set);
+int ptlrpc_set_wait(struct ptlrpc_request_set *);
+int ptlrpc_expired_set(void *data);
+void ptlrpc_interrupted_set(void *data);
+void ptlrpc_mark_interrupted(struct ptlrpc_request *req);
+void ptlrpc_set_destroy(struct ptlrpc_request_set *);
+void ptlrpc_set_add_req(struct ptlrpc_request_set *, struct ptlrpc_request *);
+void ptlrpc_set_add_new_req(struct ptlrpc_request_set *,
+ struct ptlrpc_request *);
+
+void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool);
+void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
+struct ptlrpc_request_pool *ptlrpc_init_rq_pool(int, int,
+ void (*populate_pool)(struct ptlrpc_request_pool *, int));
+struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, int opcode,
+ int count, int *lengths, char **bufs);
+struct ptlrpc_request *ptlrpc_prep_req_pool(struct obd_import *imp, int opcode,
+ int count, int *lengths,
+ char **bufs,
+ struct ptlrpc_request_pool *pool);
+void ptlrpc_free_req(struct ptlrpc_request *request);
+void ptlrpc_req_finished(struct ptlrpc_request *request);
+void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
+struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
+struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
+ int npages, int type, int portal);
+struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
+ int npages, int type, int portal);
+void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
+void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
+ cfs_page_t *page, int pageoffset, int len);
+void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
+ struct obd_import *imp);
+__u64 ptlrpc_next_xid(void);
+__u64 ptlrpc_sample_next_xid(void);
+__u64 ptlrpc_req_xid(struct ptlrpc_request *request);
+
+/* ptlrpc/service.c */
+void ptlrpc_save_lock (struct ptlrpc_request *req,
+ struct lustre_handle *lock, int mode);
+void ptlrpc_commit_replies (struct obd_device *obd);
+void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
+struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
+ int max_reply_size,
+ int req_portal, int rep_portal,
+ int watchdog_timeout, /* in ms */
+ svc_handler_t, char *name,
+ cfs_proc_dir_entry_t *proc_entry,
+ svcreq_printfn_t, int num_threads);
+void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
+
+int ptlrpc_start_threads(struct obd_device *dev, struct ptlrpc_service *svc,
+ char *base_name);
+int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc,
+ char *name, int id);
+int ptlrpc_unregister_service(struct ptlrpc_service *service);
+int liblustre_check_services (void *arg);
+void ptlrpc_daemonize(void);
+int ptlrpc_service_health_check(struct ptlrpc_service *);
+
+
+struct ptlrpc_svc_data {
+ char *name;
+ struct ptlrpc_service *svc;
+ struct ptlrpc_thread *thread;
+ struct obd_device *dev;
+};
+
+/* ptlrpc/import.c */
+int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
+int ptlrpc_init_import(struct obd_import *imp);
+int ptlrpc_disconnect_import(struct obd_import *imp);
+int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
+
+/* ptlrpc/pack_generic.c */
+int lustre_msg_swabbed(struct lustre_msg *msg);
+int lustre_pack_request(struct ptlrpc_request *, int count, int *lens,
+ char **bufs);
+int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
+ char **bufs);
+void lustre_shrink_reply(struct ptlrpc_request *req,
+ int segment, unsigned int newlen, int move_data);
+void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
+int lustre_msg_size(int count, int *lengths);
+int lustre_unpack_msg(struct lustre_msg *m, int len);
+void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
+int lustre_msg_buflen(struct lustre_msg *m, int n);
+char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
+void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
+void *lustre_swab_reqbuf (struct ptlrpc_request *req, int n, int minlen,
+ void *swabber);
+void *lustre_swab_repbuf (struct ptlrpc_request *req, int n, int minlen,
+ void *swabber);
+
+static inline void
+ptlrpc_rs_addref(struct ptlrpc_reply_state *rs)
+{
+ LASSERT(atomic_read(&rs->rs_refcount) > 0);
+ atomic_inc(&rs->rs_refcount);
+}
+
+static inline void
+ptlrpc_rs_decref(struct ptlrpc_reply_state *rs)
+{
+ LASSERT(atomic_read(&rs->rs_refcount) > 0);
+ if (atomic_dec_and_test(&rs->rs_refcount))
+ lustre_free_reply_state(rs);
+}
+
+/* ldlm/ldlm_lib.c */
+int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
+int client_obd_cleanup(struct obd_device * obddev);
+int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
+ struct obd_uuid *cluuid, struct obd_connect_data *);
+int client_disconnect_export(struct obd_export *exp);
+int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
+ int priority);
+int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid);
+int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
+
+/* ptlrpc/pinger.c */
+int ptlrpc_pinger_add_import(struct obd_import *imp);
+int ptlrpc_pinger_del_import(struct obd_import *imp);
+
+/* ptlrpc/ptlrpcd.c */
+void ptlrpcd_wake(struct ptlrpc_request *req);
+void ptlrpcd_add_req(struct ptlrpc_request *req);
+int ptlrpcd_addref(void);
+void ptlrpcd_decref(void);
+
+/* ptlrpc/lproc_ptlrpc.c */
+#ifdef LPROCFS
+void ptlrpc_lprocfs_register_obd(struct obd_device *obd);
+void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd);
+#else
+static inline void ptlrpc_lprocfs_register_obd(struct obd_device *obd) {}
+static inline void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) {}
+#endif
+
+/* ptlrpc/llog_server.c */
+int llog_origin_handle_create(struct ptlrpc_request *req);
+int llog_origin_handle_next_block(struct ptlrpc_request *req);
+int llog_origin_handle_read_header(struct ptlrpc_request *req);
+int llog_origin_handle_close(struct ptlrpc_request *req);
+int llog_origin_handle_cancel(struct ptlrpc_request *req);
+int llog_catinfo(struct ptlrpc_request *req);
+
+/* ptlrpc/llog_client.c */
+extern struct llog_operations llog_client_ops;
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+#ifndef _LUSTRE_QUOTA_H
+#define _LUSTRE_QUOTA_H
+
+#if defined(__linux__)
+#include <linux/lustre_quota.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_quota.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_quota.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#include <lustre_idl.h>
+#include <lustre_net.h>
+#include <lvfs.h>
+
+struct obd_device;
+struct client_obd;
+
+#ifndef NR_DQHASH
+#define NR_DQHASH 45
+#endif
+
+#ifdef HAVE_QUOTA_SUPPORT
+
+#ifdef __KERNEL__
+
+/* structures to access admin quotafile */
+struct lustre_mem_dqinfo {
+ unsigned int dqi_bgrace;
+ unsigned int dqi_igrace;
+ unsigned long dqi_flags;
+ unsigned int dqi_blocks;
+ unsigned int dqi_free_blk;
+ unsigned int dqi_free_entry;
+};
+
+struct lustre_quota_info {
+ struct file *qi_files[MAXQUOTAS];
+ struct lustre_mem_dqinfo qi_info[MAXQUOTAS];
+};
+
+#define DQ_STATUS_AVAIL 0x0 /* Available dquot */
+#define DQ_STATUS_SET 0x01 /* Sombody is setting dquot */
+#define DQ_STATUS_RECOVERY 0x02 /* dquot is in recovery */
+
+struct lustre_dquot {
+ /* Hash list in memory, protect by dquot_hash_lock */
+ struct list_head dq_hash;
+ /* Protect the data in lustre_dquot */
+ struct semaphore dq_sem;
+ /* Use count */
+ int dq_refcnt;
+ /* Pointer of quota info it belongs to */
+ struct lustre_quota_info *dq_info;
+
+ loff_t dq_off; /* Offset of dquot on disk */
+ unsigned int dq_id; /* ID this applies to (uid, gid) */
+ int dq_type; /* Type fo quota (USRQUOTA, GRPQUOUTA) */
+ unsigned short dq_status; /* See DQ_STATUS_ */
+ unsigned long dq_flags; /* See DQ_ in quota.h */
+ struct mem_dqblk dq_dqb; /* Diskquota usage */
+};
+
+struct dquot_id {
+ struct list_head di_link;
+ __u32 di_id;
+};
+
+#define QFILE_CHK 1
+#define QFILE_RD_INFO 2
+#define QFILE_WR_INFO 3
+#define QFILE_INIT_INFO 4
+#define QFILE_GET_QIDS 5
+#define QFILE_RD_DQUOT 6
+#define QFILE_WR_DQUOT 7
+
+/* admin quotafile operations */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+int lustre_check_quota_file(struct lustre_quota_info *lqi, int type);
+int lustre_read_quota_info(struct lustre_quota_info *lqi, int type);
+int lustre_write_quota_info(struct lustre_quota_info *lqi, int type);
+int lustre_read_dquot(struct lustre_dquot *dquot);
+int lustre_commit_dquot(struct lustre_dquot *dquot);
+int lustre_init_quota_info(struct lustre_quota_info *lqi, int type);
+int lustre_get_qids(struct lustre_quota_info *lqi, int type,
+ struct list_head *list);
+#else
+
+#ifndef DQ_FAKE_B
+#define DQ_FAKE_B 6
+#endif
+
+static inline int lustre_check_quota_file(struct lustre_quota_info *lqi,
+ int type)
+{
+ return 0;
+}
+static inline int lustre_read_quota_info(struct lustre_quota_info *lqi,
+ int type)
+{
+ return 0;
+}
+static inline int lustre_write_quota_info(struct lustre_quota_info *lqi,
+ int type)
+{
+ return 0;
+}
+static inline int lustre_read_dquot(struct lustre_dquot *dquot)
+{
+ return 0;
+}
+static inline int lustre_commit_dquot(struct lustre_dquot *dquot)
+{
+ return 0;
+}
+static inline int lustre_init_quota_info(struct lustre_quota_info *lqi,
+ int type)
+{
+ return 0;
+}
+#endif /* KERNEL_VERSION(2,5,0) */
+
+#define LL_DQUOT_OFF(sb) DQUOT_OFF(sb)
+
+typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd,
+ int opc);
+struct lustre_quota_ctxt {
+ struct super_block *lqc_sb; /* superblock this applies to */
+ struct obd_import *lqc_import; /* import used to send dqacq/dqrel RPC */
+ dqacq_handler_t lqc_handler; /* dqacq/dqrel RPC handler, only for quota master */
+ unsigned long lqc_recovery:1; /* Doing recovery */
+ unsigned long lqc_iunit_sz; /* Unit size of file quota */
+ unsigned long lqc_itune_sz; /* Trigger dqacq when available file quota less than
+ * this value, trigger dqrel when available file quota
+ * more than this value + 1 iunit */
+ unsigned long lqc_bunit_sz; /* Unit size of block quota */
+ unsigned long lqc_btune_sz; /* See comment of lqc_itune_sz */
+};
+
+#else
+
+struct lustre_quota_info {
+};
+
+struct lustre_quota_ctxt {
+};
+
+#endif /* !__KERNEL__ */
+
+#else
+
+#define LL_DQUOT_OFF(sb) do {} while(0)
+
+struct lustre_quota_info {
+};
+
+struct lustre_quota_ctxt {
+};
+
+#endif /* !HAVE_QUOTA_SUPPORT */
+
+/* If the (quota limit < qunit * slave count), the slave which can't
+ * acquire qunit should set it's local limit as MIN_QLIMIT */
+#define MIN_QLIMIT 1
+
+struct quotacheck_thread_args {
+ struct obd_export *qta_exp; /* obd export */
+ struct obd_quotactl qta_oqctl; /* obd_quotactl args */
+ struct super_block *qta_sb; /* obd super block */
+ atomic_t *qta_sem; /* obt_quotachecking */
+};
+
+typedef struct {
+ int (*quota_init) (void);
+ int (*quota_exit) (void);
+ int (*quota_setup) (struct obd_device *, struct lustre_cfg *);
+ int (*quota_cleanup) (struct obd_device *);
+ /* For quota master, close admin quota files */
+ int (*quota_fs_cleanup) (struct obd_device *);
+ int (*quota_ctl) (struct obd_export *, struct obd_quotactl *);
+ int (*quota_check) (struct obd_export *, struct obd_quotactl *);
+ int (*quota_recovery) (struct obd_device *);
+
+ /* For quota master/slave, adjust quota limit after fs operation */
+ int (*quota_adjust) (struct obd_device *, unsigned int[],
+ unsigned int[], int, int);
+
+ /* For quota slave, set import, trigger quota recovery */
+ int (*quota_setinfo) (struct obd_export *, struct obd_device *);
+
+ /* For quota slave, set proper thread resoure capability */
+ int (*quota_enforce) (struct obd_device *, unsigned int);
+
+ /* For quota slave, check whether specified uid/gid is over quota */
+ int (*quota_getflag) (struct obd_device *, struct obdo *);
+
+ /* For quota slave, acquire/release quota from master if needed */
+ int (*quota_acquire) (struct obd_device *, unsigned int, unsigned int);
+
+ /* For quota client, poll if the quota check done */
+ int (*quota_poll_check) (struct obd_export *, struct if_quotacheck *);
+
+ /* For quota client, check whether specified uid/gid is over quota */
+ int (*quota_chkdq) (struct client_obd *, unsigned int, unsigned int);
+
+ /* For quota client, set over quota flag for specifed uid/gid */
+ int (*quota_setdq) (struct client_obd *, unsigned int, unsigned int,
+ obd_flag, obd_flag);
+} quota_interface_t;
+
+#define Q_COPY(out, in, member) (out)->member = (in)->member
+
+#define QUOTA_OP(interface, op) interface->quota_ ## op
+
+#define QUOTA_CHECK_OP(interface, op) \
+do { \
+ if (!interface) \
+ RETURN(0); \
+ if (!QUOTA_OP(interface, op)) { \
+ CERROR("no quota operation: " #op "\n"); \
+ RETURN(-EOPNOTSUPP); \
+ } \
+} while(0)
+
+static inline int lquota_init(quota_interface_t *interface)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, init);
+ rc = QUOTA_OP(interface, init)();
+ RETURN(rc);
+}
+
+static inline int lquota_exit(quota_interface_t *interface)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, exit);
+ rc = QUOTA_OP(interface, exit)();
+ RETURN(rc);
+}
+
+static inline int lquota_setup(quota_interface_t *interface,
+ struct obd_device *obd,
+ struct lustre_cfg *lcfg)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, setup);
+ rc = QUOTA_OP(interface, setup)(obd, lcfg);
+ RETURN(rc);
+}
+
+static inline int lquota_cleanup(quota_interface_t *interface,
+ struct obd_device *obd)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, cleanup);
+ rc = QUOTA_OP(interface, cleanup)(obd);
+ RETURN(rc);
+}
+
+static inline int lquota_fs_cleanup(quota_interface_t *interface,
+ struct obd_device *obd)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, fs_cleanup);
+ rc = QUOTA_OP(interface, fs_cleanup)(obd);
+ RETURN(rc);
+}
+
+static inline int lquota_recovery(quota_interface_t *interface,
+ struct obd_device *obd)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, recovery);
+ rc = QUOTA_OP(interface, recovery)(obd);
+ RETURN(rc);
+}
+
+static inline int lquota_adjust(quota_interface_t *interface,
+ struct obd_device *obd,
+ unsigned int qcids[],
+ unsigned int qpids[],
+ int rc, int opc)
+{
+ int ret;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, adjust);
+ ret = QUOTA_OP(interface, adjust)(obd, qcids, qpids, rc, opc);
+ RETURN(ret);
+}
+
+static inline int lquota_chkdq(quota_interface_t *interface,
+ struct client_obd *cli,
+ unsigned int uid, unsigned int gid)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, chkdq);
+ rc = QUOTA_OP(interface, chkdq)(cli, uid, gid);
+ RETURN(rc);
+}
+
+static inline int lquota_setdq(quota_interface_t *interface,
+ struct client_obd *cli,
+ unsigned int uid, unsigned int gid,
+ obd_flag valid, obd_flag flags)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, setdq);
+ rc = QUOTA_OP(interface, setdq)(cli, uid, gid, valid, flags);
+ RETURN(rc);
+}
+
+static inline int lquota_poll_check(quota_interface_t *interface,
+ struct obd_export *exp,
+ struct if_quotacheck *qchk)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, poll_check);
+ rc = QUOTA_OP(interface, poll_check)(exp, qchk);
+ RETURN(rc);
+}
+
+
+static inline int lquota_setinfo(quota_interface_t *interface,
+ struct obd_export *exp,
+ struct obd_device *obd)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, setinfo);
+ rc = QUOTA_OP(interface, setinfo)(exp, obd);
+ RETURN(rc);
+}
+
+static inline int lquota_enforce(quota_interface_t *interface,
+ struct obd_device *obd,
+ unsigned int ignore)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, enforce);
+ rc = QUOTA_OP(interface, enforce)(obd, ignore);
+ RETURN(rc);
+}
+
+static inline int lquota_getflag(quota_interface_t *interface,
+ struct obd_device *obd, struct obdo *oa)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, getflag);
+ rc = QUOTA_OP(interface, getflag)(obd, oa);
+ RETURN(rc);
+}
+
+static inline int lquota_acquire(quota_interface_t *interface,
+ struct obd_device *obd,
+ unsigned int uid, unsigned int gid)
+{
+ int rc;
+ ENTRY;
+
+ QUOTA_CHECK_OP(interface, acquire);
+ rc = QUOTA_OP(interface, acquire)(obd, uid, gid);
+ RETURN(rc);
+}
+
+#ifndef __KERNEL__
+extern quota_interface_t osc_quota_interface;
+extern quota_interface_t mdc_quota_interface;
+extern quota_interface_t lov_quota_interface;
+#endif
+
+#endif /* _LUSTRE_QUOTA_H */
struct group_info *ue_group_info;
atomic_t ue_refcount;
int ue_flags;
- wait_queue_head_t ue_waitq;
+ cfs_waitq_t ue_waitq;
unsigned long ue_acquire_expire;
unsigned long ue_expire;
};
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * lustre VFS/process permission interface
+ */
+
+#ifndef __LVFS_H__
+#define __LVFS_H__
+
+#define LL_FID_NAMELEN (16 + 1 + 8 + 1)
+
+#include <libcfs/kp30.h>
+#if defined(__linux__)
+#include <linux/lvfs.h>
+#elif defined(__APPLE__)
+#include <darwin/lvfs.h>
+#elif defined(__WINNT__)
+#include <winnt/lvfs.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#include <lustre_ucache.h>
+
+
+#ifdef LIBLUSTRE
+#include <lvfs_user_fs.h>
+#endif
+
+/* lvfs_common.c */
+struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *, __u64, __u32, __u64 ,void *data);
+
+void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
+ struct lvfs_ucred *cred);
+void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
+ struct lvfs_ucred *cred);
+
+
+static inline int ll_fid2str(char *str, __u64 id, __u32 generation)
+{
+ return sprintf(str, "%llx:%08x", (unsigned long long)id, generation);
+}
+
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+
+#ifndef __OBD_H
+#define __OBD_H
+
+#if defined(__linux__)
+#include <linux/obd.h>
+#elif defined(__APPLE__)
+#include <darwin/obd.h>
+#elif defined(__WINNT__)
+#include <winnt/obd.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#define IOC_OSC_TYPE 'h'
+#define IOC_OSC_MIN_NR 20
+#define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
+#define IOC_OSC_MAX_NR 50
+
+#define IOC_MDC_TYPE 'i'
+#define IOC_MDC_MIN_NR 20
+#define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
+/* Moved to lustre_user.h
+#define IOC_MDC_GETSTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *) */
+#define IOC_MDC_MAX_NR 50
+
+#include <lustre_lib.h>
+#include <lustre_idl.h>
+#include <lustre_export.h>
+#include <lustre_quota.h>
+
+/* this is really local to the OSC */
+struct loi_oap_pages {
+ struct list_head lop_pending;
+ int lop_num_pending;
+ struct list_head lop_urgent;
+ struct list_head lop_pending_group;
+};
+
+struct osc_async_rc {
+ int ar_rc;
+ int ar_force_sync;
+ int ar_min_xid;
+};
+
+struct lov_oinfo { /* per-stripe data structure */
+ __u64 loi_id; /* object ID on the target OST */
+ __u64 loi_gr; /* object group on the target OST */
+ int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
+ int loi_ost_gen; /* generation of this loi_ost_idx */
+
+ /* used by the osc to keep track of what objects to build into rpcs */
+ struct loi_oap_pages loi_read_lop;
+ struct loi_oap_pages loi_write_lop;
+ /* _cli_ is poorly named, it should be _ready_ */
+ struct list_head loi_cli_item;
+ struct list_head loi_write_item;
+ struct list_head loi_read_item;
+
+ unsigned loi_kms_valid:1;
+ __u64 loi_kms; /* known minimum size */
+ __u64 loi_rss; /* recently seen size */
+ __u64 loi_mtime; /* recently seen mtime */
+ __u64 loi_blocks; /* recently seen blocks */
+
+ struct osc_async_rc loi_ar;
+};
+
+static inline void loi_init(struct lov_oinfo *loi)
+{
+ CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
+ CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
+ CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
+ CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
+ CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
+ CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
+ CFS_INIT_LIST_HEAD(&loi->loi_cli_item);
+ CFS_INIT_LIST_HEAD(&loi->loi_write_item);
+ CFS_INIT_LIST_HEAD(&loi->loi_read_item);
+}
+
+struct lov_stripe_md {
+ spinlock_t lsm_lock;
+ void *lsm_lock_owner; /* debugging */
+
+ /* Public members. */
+ __u64 lsm_object_id; /* lov object id */
+ __u64 lsm_object_gr; /* lov object id */
+ __u64 lsm_maxbytes; /* maximum possible file size */
+ unsigned long lsm_xfersize; /* optimal transfer size */
+
+ /* LOV-private members start here -- only for use in lov/. */
+ __u32 lsm_magic;
+ __u32 lsm_stripe_size; /* size of the stripe */
+ __u32 lsm_pattern; /* striping pattern (RAID0, RAID1) */
+ unsigned lsm_stripe_count; /* number of objects being striped over */
+ struct lov_oinfo lsm_oinfo[0];
+};
+
+/* compare all fields except for semaphore */
+static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
+ struct lov_stripe_md *m2)
+{
+ return memcmp(&m1->lsm_object_id, &m2->lsm_object_id,
+ (char *)&m2->lsm_oinfo[0] - (char *)&m2->lsm_object_id);
+}
+
+void lov_stripe_lock(struct lov_stripe_md *md);
+void lov_stripe_unlock(struct lov_stripe_md *md);
+
+struct obd_type {
+ struct list_head typ_chain;
+ struct obd_ops *typ_ops;
+ cfs_proc_dir_entry_t *typ_procroot;
+ char *typ_name;
+ int typ_refcnt;
+};
+
+struct brw_page {
+ obd_off off;
+ cfs_page_t *pg;
+ int count;
+ obd_flag flag;
+};
+
+enum async_flags {
+ ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
+ page is added to an rpc */
+ ASYNC_URGENT = 0x2,
+ ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
+ to give the caller a chance to update
+ or cancel the size of the io */
+ ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
+ the page is accounted for in the
+ obd_io_group given to
+ obd_queue_group_io */
+};
+
+struct obd_async_page_ops {
+ int (*ap_make_ready)(void *data, int cmd);
+ int (*ap_refresh_count)(void *data, int cmd);
+ void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
+ void (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
+};
+
+/* the `oig' is passed down from a caller of obd rw methods. the callee
+ * records enough state such that the caller can sleep on the oig and
+ * be woken when all the callees have finished their work */
+struct obd_io_group {
+ spinlock_t oig_lock;
+ atomic_t oig_refcount;
+ int oig_pending;
+ int oig_rc;
+ struct list_head oig_occ_list;
+ cfs_waitq_t oig_waitq;
+};
+
+/* the oig callback context lets the callee of obd rw methods register
+ * for callbacks from the caller. */
+struct oig_callback_context {
+ struct list_head occ_oig_item;
+ /* called when the caller has received a signal while sleeping.
+ * callees of this method are encouraged to abort their state
+ * in the oig. This may be called multiple times. */
+ void (*occ_interrupted)(struct oig_callback_context *occ);
+ unsigned int interrupted:1;
+};
+
+/* if we find more consumers this could be generalized */
+#define OBD_HIST_MAX 32
+struct obd_histogram {
+ spinlock_t oh_lock;
+ unsigned long oh_buckets[OBD_HIST_MAX];
+};
+
+/* Individual type definitions */
+
+struct ost_server_data;
+
+/* hold common fields for "target" device */
+struct obd_device_target {
+ struct super_block *obt_sb;
+ atomic_t obt_quotachecking;
+ struct lustre_quota_ctxt obt_qctxt;
+};
+
+#define FILTER_GROUP_LLOG 1
+#define FILTER_GROUP_ECHO 2
+
+struct filter_ext {
+ __u64 fe_start;
+ __u64 fe_end;
+};
+
+struct filter_obd {
+ /* NB this field MUST be first */
+ struct obd_device_target fo_obt;
+ const char *fo_fstype;
+ struct vfsmount *fo_vfsmnt;
+ cfs_dentry_t *fo_dentry_O;
+ cfs_dentry_t **fo_dentry_O_groups;
+ cfs_dentry_t **fo_dentry_O_sub;
+ spinlock_t fo_objidlock; /* protect fo_lastobjid
+ * increment */
+
+ spinlock_t fo_translock; /* protect fsd_last_rcvd
+ * increment */
+
+ struct file *fo_rcvd_filp;
+ struct filter_server_data *fo_fsd;
+ unsigned long *fo_last_rcvd_slots;
+ __u64 fo_mount_count;
+
+ int fo_destroy_in_progress;
+
+ struct file_operations *fo_fop;
+ struct inode_operations *fo_iop;
+ struct address_space_operations *fo_aops;
+
+ struct list_head fo_export_list;
+ int fo_subdir_count;
+
+ obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
+ obd_size fo_tot_granted; /* all values in bytes */
+ obd_size fo_tot_pending;
+
+ obd_size fo_readcache_max_filesize;
+
+ struct obd_import *fo_mdc_imp;
+ struct obd_uuid fo_mdc_uuid;
+ struct lustre_handle fo_mdc_conn;
+#if 0
+ struct ptlrpc_client fo_mdc_client;
+#endif
+ struct file **fo_last_objid_files;
+ __u64 *fo_last_objids; /* last created objid for groups */
+
+ struct semaphore fo_alloc_lock;
+
+ spinlock_t fo_stats_lock;
+ int fo_r_in_flight; /* protected by fo_stats_lock */
+ int fo_w_in_flight; /* protected by fo_stats_lock */
+
+ /*
+ * per-filter pool of kiobuf's allocated by filter_common_setup() and
+ * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
+ * which ->fo_iobuf_count were allocated.
+ *
+ * This pool contains kiobuf used by
+ * filter_{prep,commit}rw_{read,write}() and is shared by all OST
+ * threads.
+ *
+ * Locking: none, each OST thread uses only one element, determined by
+ * its "ordinal number", ->t_id.
+ *
+ * This is (void *) array, because 2.4 and 2.6 use different iobuf
+ * structures.
+ */
+ void **fo_iobuf_pool;
+ int fo_iobuf_count;
+
+ struct obd_histogram fo_r_pages;
+ struct obd_histogram fo_w_pages;
+ struct obd_histogram fo_read_rpc_hist;
+ struct obd_histogram fo_write_rpc_hist;
+ struct obd_histogram fo_r_io_time;
+ struct obd_histogram fo_w_io_time;
+ struct obd_histogram fo_r_discont_pages;
+ struct obd_histogram fo_w_discont_pages;
+ struct obd_histogram fo_r_discont_blocks;
+ struct obd_histogram fo_w_discont_blocks;
+ struct obd_histogram fo_r_disk_iosize;
+ struct obd_histogram fo_w_disk_iosize;
+
+ struct lustre_quota_ctxt fo_quota_ctxt;
+ spinlock_t fo_quotacheck_lock;
+ atomic_t fo_quotachecking;
+
+ /* objids black list stuff. See for detailed comment in
+ * filter_clear_orphans() */
+ struct filter_ext *fo_blacklist;
+ spinlock_t fo_blacklist_lock;
+};
+
+struct mds_server_data;
+
+#define OSC_MAX_RIF_DEFAULT 8
+#define OSC_MAX_RIF_MAX 64
+#define OSC_MAX_DIRTY_DEFAULT 32
+#define OSC_MAX_DIRTY_MB_MAX 512 /* totally arbitrary */
+
+struct mdc_rpc_lock;
+struct client_obd {
+ struct obd_import *cl_import;
+ struct semaphore cl_sem;
+ int cl_conn_count;
+ /* max_mds_easize is purely a performance thing so we don't have to
+ * call obd_size_diskmd() all the time. */
+ int cl_default_mds_easize;
+ int cl_max_mds_easize;
+ int cl_max_mds_cookiesize;
+ kdev_t cl_sandev;
+
+ //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
+ void *cl_llcd_offset;
+
+ /* the grant values are protected by loi_list_lock below */
+ long cl_dirty; /* all _dirty_ in bytes */
+ long cl_dirty_max; /* allowed w/o rpc */
+ long cl_avail_grant; /* bytes of credit for ost */
+ long cl_lost_grant; /* lost credits (trunc) */
+ struct list_head cl_cache_waiters; /* waiting for cache/grant */
+
+ /* keep track of objects that have lois that contain pages which
+ * have been queued for async brw. this lock also protects the
+ * lists of osc_client_pages that hang off of the loi */
+ /*
+ * ->cl_loi_list_lock protects consistency of
+ * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
+ * ->ap_completion() call-backs are executed under this lock. As we
+ * cannot guarantee that these call-backs never block on all platforms
+ * (as a matter of fact they do block on Mac OS X), type of
+ * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
+ * and blocking mutex on Mac OS X. (Alternative is to make this lock
+ * blocking everywhere, but we don't want to slow down fast-path of
+ * our main platform.)
+ *
+ * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
+ * with client_obd_list_{un,}lock() and
+ * client_obd_list_lock_{init,done}() functions.
+ */
+ client_obd_lock_t cl_loi_list_lock;
+ struct list_head cl_loi_ready_list;
+ struct list_head cl_loi_write_list;
+ struct list_head cl_loi_read_list;
+ int cl_r_in_flight;
+ int cl_w_in_flight;
+ /* just a sum of the loi/lop pending numbers to be exported by /proc */
+ int cl_pending_w_pages;
+ int cl_pending_r_pages;
+ int cl_max_pages_per_rpc;
+ int cl_max_rpcs_in_flight;
+ struct obd_histogram cl_read_rpc_hist;
+ struct obd_histogram cl_write_rpc_hist;
+ struct obd_histogram cl_read_page_hist;
+ struct obd_histogram cl_write_page_hist;
+ struct obd_histogram cl_read_offset_hist;
+ struct obd_histogram cl_write_offset_hist;
+
+ struct mdc_rpc_lock *cl_rpc_lock;
+ struct mdc_rpc_lock *cl_setattr_lock;
+ struct osc_creator cl_oscc;
+
+ /* Flags section */
+ unsigned int cl_checksum:1; /* debug checksums */
+
+ /* also protected by the poorly named _loi_list_lock lock above */
+ struct osc_async_rc cl_ar;
+
+ /* used by quotacheck */
+ int cl_qchk_stat; /* quotacheck stat of the peer */
+ struct ptlrpc_request_pool *cl_rq_pool; /* emergency pool of requests */
+};
+
+#define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */
+
+struct mds_obd {
+ /* NB this field MUST be first */
+ struct obd_device_target mds_obt;
+ struct ptlrpc_service *mds_service;
+ struct ptlrpc_service *mds_setattr_service;
+ struct ptlrpc_service *mds_readpage_service;
+ struct vfsmount *mds_vfsmnt;
+ cfs_dentry_t *mds_fid_de;
+ int mds_max_mdsize;
+ int mds_max_cookiesize;
+ struct file *mds_rcvd_filp;
+ spinlock_t mds_transno_lock;
+ __u64 mds_last_transno;
+ __u64 mds_mount_count;
+ __u64 mds_io_epoch;
+ struct semaphore mds_epoch_sem;
+ struct ll_fid mds_rootfid;
+ struct mds_server_data *mds_server_data;
+ cfs_dentry_t *mds_pending_dir;
+ cfs_dentry_t *mds_logs_dir;
+ cfs_dentry_t *mds_objects_dir;
+ struct llog_handle *mds_cfg_llh;
+// struct llog_handle *mds_catalog;
+ struct obd_device *mds_osc_obd; /* XXX lov_obd */
+ struct obd_uuid mds_lov_uuid;
+ char *mds_profile;
+ struct obd_export *mds_osc_exp; /* XXX lov_exp */
+ int mds_has_lov_desc;
+ struct lov_desc mds_lov_desc;
+ obd_id *mds_lov_objids;
+ int mds_lov_nextid_set;
+ struct file *mds_lov_objid_filp;
+ unsigned long *mds_client_bitmap;
+ struct semaphore mds_orphan_recovery_sem;
+ struct upcall_cache *mds_group_hash;
+
+ struct lustre_quota_info mds_quota_info;
+ struct semaphore mds_qonoff_sem;
+ struct semaphore mds_health_sem;
+ unsigned long mds_lov_objids_valid:1,
+ mds_fl_user_xattr:1,
+ mds_fl_acl:1;
+};
+
+struct echo_obd {
+ struct obdo eo_oa;
+ spinlock_t eo_lock;
+ __u64 eo_lastino;
+ struct lustre_handle eo_nl_lock;
+ atomic_t eo_prep;
+};
+
+/*
+ * this struct does double-duty acting as either a client or
+ * server instance .. maybe not wise.
+ */
+struct ptlbd_obd {
+ /* server's */
+ struct ptlrpc_service *ptlbd_service;
+ struct file *filp;
+ /* client's */
+ struct ptlrpc_client bd_client;
+ struct obd_import *bd_import;
+ struct obd_uuid bd_server_uuid;
+ struct obd_export *bd_exp;
+ int refcount; /* XXX sigh */
+};
+
+struct recovd_obd {
+ spinlock_t recovd_lock;
+ struct list_head recovd_managed_items; /* items managed */
+ struct list_head recovd_troubled_items; /* items in recovery */
+
+ cfs_waitq_t recovd_recovery_waitq;
+ cfs_waitq_t recovd_ctl_waitq;
+ cfs_waitq_t recovd_waitq;
+ cfs_task_t *recovd_thread;
+ __u32 recovd_state;
+};
+
+struct ost_obd {
+ struct ptlrpc_service *ost_service;
+ struct ptlrpc_service *ost_create_service;
+ struct semaphore ost_health_sem;
+};
+
+struct echo_client_obd {
+ struct obd_export *ec_exp; /* the local connection to osc/lov */
+ spinlock_t ec_lock;
+ struct list_head ec_objects;
+ int ec_nstripes;
+ __u64 ec_unique;
+};
+
+struct cache_obd {
+ struct obd_export *cobd_target_exp;/* local connection to target obd */
+ struct obd_export *cobd_cache_exp; /* local connection to cache obd */
+};
+
+struct lov_tgt_desc {
+ struct obd_uuid uuid;
+ __u32 ltd_gen;
+ struct obd_export *ltd_exp;
+ int active; /* is this target up for requests */
+ int index; /* index of target array in lov_obd */
+ struct list_head qos_bavail_list; /* link entry to lov_obd */
+};
+
+struct lov_obd {
+ spinlock_t lov_lock;
+ struct lov_desc desc;
+ int bufsize;
+ int refcount;
+ unsigned int lo_catalog_loaded:1;
+ struct list_head qos_bavail_list; /* tgts list, sorted by available space, protected by lov_lock */
+ struct lov_tgt_desc *tgts;
+};
+
+struct niobuf_local {
+ __u64 offset;
+ __u32 len;
+ __u32 flags;
+ cfs_page_t *page;
+ cfs_dentry_t *dentry;
+ int lnb_grant_used;
+ int rc;
+};
+
+
+/* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
+#define N_LOCAL_TEMP_PAGE 0x10000000
+
+struct obd_trans_info {
+ __u64 oti_transno;
+ __u64 *oti_objid;
+ /* Only used on the server side for tracking acks. */
+ struct oti_req_ack_lock {
+ struct lustre_handle lock;
+ __u32 mode;
+ } oti_ack_locks[4];
+ void *oti_handle;
+ struct llog_cookie oti_onecookie;
+ struct llog_cookie *oti_logcookies;
+ int oti_numcookies;
+
+ /* initial thread handling transaction */
+ struct ptlrpc_thread *oti_thread;
+};
+
+static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
+{
+ if (!oti)
+ return;
+
+ if (num_cookies == 1)
+ oti->oti_logcookies = &oti->oti_onecookie;
+ else
+ OBD_ALLOC(oti->oti_logcookies,
+ num_cookies * sizeof(oti->oti_onecookie));
+
+ oti->oti_numcookies = num_cookies;
+}
+
+static inline void oti_free_cookies(struct obd_trans_info *oti)
+{
+ if (!oti || !oti->oti_logcookies)
+ return;
+
+ if (oti->oti_logcookies == &oti->oti_onecookie)
+ LASSERT(oti->oti_numcookies == 1);
+ else
+ OBD_FREE(oti->oti_logcookies,
+ oti->oti_numcookies * sizeof(oti->oti_onecookie));
+ oti->oti_logcookies = NULL;
+ oti->oti_numcookies = 0;
+}
+
+/* llog contexts */
+enum llog_ctxt_id {
+ LLOG_CONFIG_ORIG_CTXT = 0,
+ LLOG_CONFIG_REPL_CTXT = 1,
+ LLOG_MDS_OST_ORIG_CTXT = 2,
+ LLOG_MDS_OST_REPL_CTXT = 3,
+ LLOG_SIZE_ORIG_CTXT = 4,
+ LLOG_SIZE_REPL_CTXT = 5,
+ LLOG_MD_ORIG_CTXT = 6,
+ LLOG_MD_REPL_CTXT = 7,
+ LLOG_RD1_ORIG_CTXT = 8,
+ LLOG_RD1_REPL_CTXT = 9,
+ LLOG_TEST_ORIG_CTXT = 10,
+ LLOG_TEST_REPL_CTXT = 11,
+ LLOG_MAX_CTXTS
+};
+
+
+/* corresponds to one of the obd's */
+struct obd_device {
+ struct obd_type *obd_type;
+
+ /* common and UUID name of this device */
+ char *obd_name;
+ struct obd_uuid obd_uuid;
+
+ int obd_minor;
+ unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
+ obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
+ obd_no_recov:1, obd_stopping:1, obd_starting:1,
+ obd_force:1, obd_fail:1, obd_async_recov:1;
+ atomic_t obd_refcount;
+ cfs_waitq_t obd_refcount_waitq;
+ cfs_proc_dir_entry_t *obd_proc_entry;
+ struct list_head obd_exports;
+ int obd_num_exports;
+ struct ldlm_namespace *obd_namespace;
+ struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
+ /* a spinlock is OK for what we do now, may need a semaphore later */
+ spinlock_t obd_dev_lock;
+ __u64 obd_last_committed;
+ struct fsfilt_operations *obd_fsops;
+ spinlock_t obd_osfs_lock;
+ struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
+ cfs_time_t obd_osfs_age;
+ struct lvfs_run_ctxt obd_lvfs_ctxt;
+ struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
+ struct obd_device *obd_observer;
+ struct obd_export *obd_self_export;
+ /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
+ struct list_head obd_exports_timed;
+ time_t obd_eviction_timer; /* for ping evictor */
+
+ /* XXX encapsulate all this recovery data into one struct */
+ svc_handler_t obd_recovery_handler;
+ int obd_max_recoverable_clients;
+ int obd_connected_clients;
+ int obd_recoverable_clients;
+ spinlock_t obd_processing_task_lock;
+ pid_t obd_processing_task;
+ __u64 obd_next_recovery_transno;
+ int obd_replayed_requests;
+ int obd_requests_queued_for_recovery;
+ cfs_waitq_t obd_next_transno_waitq;
+ struct list_head obd_uncommitted_replies;
+ spinlock_t obd_uncommitted_replies_lock;
+ cfs_timer_t obd_recovery_timer;
+ struct list_head obd_recovery_queue;
+ struct list_head obd_delayed_reply_queue;
+ time_t obd_recovery_start;
+ time_t obd_recovery_end;
+
+ union {
+ struct obd_device_target obt;
+ struct filter_obd filter;
+ struct mds_obd mds;
+ struct client_obd cli;
+ struct ost_obd ost;
+ struct echo_client_obd echo_client;
+ struct echo_obd echo;
+ struct recovd_obd recovd;
+ struct lov_obd lov;
+ struct cache_obd cobd;
+ struct ptlbd_obd ptlbd;
+ } u;
+ /* Fields used by LProcFS */
+ unsigned int obd_cntr_base;
+ struct lprocfs_stats *obd_stats;
+ cfs_proc_dir_entry_t *obd_svc_procroot;
+ struct lprocfs_stats *obd_svc_stats;
+};
+
+#define OBD_OPT_FORCE 0x0001
+#define OBD_OPT_FAILOVER 0x0002
+
+#define OBD_LLOG_FL_SENDNOW 0x0001
+
+struct obd_ops {
+ struct module *o_owner;
+ int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
+ void *karg, void *uarg);
+ int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
+ __u32 *vallen, void *val);
+ int (*o_set_info)(struct obd_export *, __u32 keylen, void *key,
+ __u32 vallen, void *val);
+ int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
+ int (*o_detach)(struct obd_device *dev);
+ int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
+ int (*o_precleanup)(struct obd_device *dev, int cleanup_stage);
+ int (*o_cleanup)(struct obd_device *dev);
+ int (*o_process_config)(struct obd_device *dev, obd_count len,
+ void *data);
+ int (*o_postrecov)(struct obd_device *dev);
+ int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
+ int priority);
+ int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
+ /* connect to the target device with given connection
+ * data. @ocd->ocd_connect_flags is modified to reflect flags actually
+ * granted by the target, which are guaranteed to be a subset of flags
+ * asked for. If @ocd == NULL, use default parameters. */
+ int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
+ struct obd_uuid *cluuid, struct obd_connect_data *ocd);
+ int (*o_disconnect)(struct obd_export *exp);
+
+ int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
+ cfs_time_t max_age);
+ int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
+ struct lov_stripe_md *mem_src);
+ int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
+ struct lov_mds_md *disk_src, int disk_len);
+ int (*o_preallocate)(struct lustre_handle *, obd_count *req,
+ obd_id *ids);
+ int (*o_create)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md **ea, struct obd_trans_info *oti);
+ int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, struct obd_trans_info *oti);
+ int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, struct obd_trans_info *oti);
+ int (*o_setattr_async)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, struct obd_trans_info *oti);
+ int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea);
+ int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea,
+ struct ptlrpc_request_set *set);
+ int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, obd_count oa_bufs,
+ struct brw_page *pgarr, struct obd_trans_info *oti);
+ int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, obd_count oa_bufs,
+ struct brw_page *pgarr, struct ptlrpc_request_set *,
+ struct obd_trans_info *oti);
+ int (*o_prep_async_page)(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ cfs_page_t *page, obd_off offset,
+ struct obd_async_page_ops *ops, void *data,
+ void **res);
+ int (*o_queue_async_io)(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi, void *cookie,
+ int cmd, obd_off off, int count,
+ obd_flag brw_flags, obd_flag async_flags);
+ int (*o_queue_group_io)(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct obd_io_group *oig,
+ void *cookie, int cmd, obd_off off, int count,
+ obd_flag brw_flags, obd_flag async_flags);
+ int (*o_trigger_group_io)(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct obd_io_group *oig);
+ int (*o_set_async_flags)(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi, void *cookie,
+ obd_flag async_flags);
+ int (*o_teardown_async_page)(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi, void *cookie);
+ int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
+ obd_off size, int shrink);
+ int (*o_punch)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, obd_size start,
+ obd_size end, struct obd_trans_info *oti);
+ int (*o_sync)(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, obd_size start, obd_size end);
+ int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
+ struct lov_stripe_md *src, obd_size start,
+ obd_size end, struct obd_trans_info *oti);
+ int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
+ struct lustre_handle *srconn, struct lov_stripe_md *src,
+ obd_size start, obd_size end, struct obd_trans_info *);
+ int (*o_iterate)(struct lustre_handle *conn,
+ int (*)(obd_id, obd_gr, void *),
+ obd_id *startid, obd_gr group, void *data);
+ int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
+ int objcount, struct obd_ioobj *obj,
+ int niocount, struct niobuf_remote *remote,
+ struct niobuf_local *local, struct obd_trans_info *oti);
+ int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
+ int objcount, struct obd_ioobj *obj,
+ int niocount, struct niobuf_local *local,
+ struct obd_trans_info *oti, int rc);
+ int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
+ __u32 type, ldlm_policy_data_t *, __u32 mode,
+ int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
+ void *data, __u32 lvb_len, void *lvb_swabber,
+ struct lustre_handle *lockh);
+ int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
+ ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
+ struct lustre_handle *lockh);
+ int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
+ ldlm_iterator_t it, void *data);
+ int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
+ __u32 mode, struct lustre_handle *);
+ int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
+ int flags, void *opaque);
+ int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
+ int join);
+ int (*o_san_preprw)(int cmd, struct obd_export *exp,
+ struct obdo *oa, int objcount,
+ struct obd_ioobj *obj, int niocount,
+ struct niobuf_remote *remote);
+ int (*o_init_export)(struct obd_export *exp);
+ int (*o_destroy_export)(struct obd_export *exp);
+
+ /* llog related obd_methods */
+ int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
+ int count, struct llog_catid *logid);
+ int (*o_llog_finish)(struct obd_device *obd, int count);
+
+ /* metadata-only methods */
+ int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
+ struct obd_client_handle *, int flag);
+ int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
+
+ int (*o_import_event)(struct obd_device *, struct obd_import *,
+ enum obd_import_event);
+
+ int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
+ int active);
+
+ int (*o_health_check)(struct obd_device *);
+
+ /* quota methods */
+ int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
+ int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
+
+ /*
+ * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
+ * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
+ * Also, add a wrapper function in include/linux/obd_class.h.
+ *
+ * Also note that if you add it to the END, you also have to change
+ * the num_stats calculation.
+ *
+ */
+};
+
+
+static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
+ int error)
+{
+ if (error) {
+ CERROR("%s: transno "LPD64" commit error: %d\n",
+ obd->obd_name, transno, error);
+ return;
+ }
+ CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
+ obd->obd_name, transno);
+ if (transno > obd->obd_last_committed) {
+ obd->obd_last_committed = transno;
+ ptlrpc_commit_replies (obd);
+ }
+}
+
+static inline void init_obd_quota_ops(quota_interface_t *interface,
+ struct obd_ops *obd_ops)
+{
+ if (!interface)
+ return;
+
+ LASSERT(obd_ops);
+ obd_ops->o_quotacheck = QUOTA_OP(interface, check);
+ obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
+}
+
+#endif /* __OBD_H */
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001-2003 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __CLASS_OBD_H
+#define __CLASS_OBD_H
+
+#include <obd_support.h>
+#include <lustre_import.h>
+#include <lustre_net.h>
+#include <obd.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
+#include <lprocfs_status.h>
+
+#if defined(__linux__)
+#include <linux/obd_class.h>
+#elif defined(__APPLE__)
+#include <darwin/obd_class.h>
+#elif defined(__WINNT__)
+#include <winnt/obd_class.h>
+#else
+#error Unsupported operating system.
+#endif
+
+/* OBD Device Declarations */
+#define MAX_OBD_DEVICES 520
+extern struct obd_device obd_dev[MAX_OBD_DEVICES];
+extern spinlock_t obd_dev_lock;
+
+/* OBD Operations Declarations */
+extern struct obd_device *class_conn2obd(struct lustre_handle *);
+extern struct obd_device *class_exp2obd(struct obd_export *);
+
+/* genops.c */
+struct obd_export *class_conn2export(struct lustre_handle *);
+int class_register_type(struct obd_ops *ops, struct lprocfs_vars *, char *nm);
+int class_unregister_type(char *nm);
+
+struct obd_device *class_newdev(struct obd_type *type, char *name);
+void class_release_dev(struct obd_device *obd);
+
+int class_name2dev(char *name);
+struct obd_device *class_name2obd(char *name);
+int class_uuid2dev(struct obd_uuid *uuid);
+struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
+struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
+ char * typ_name,
+ struct obd_uuid *grp_uuid);
+struct obd_device * class_find_client_notype(struct obd_uuid *tgt_uuid,
+ struct obd_uuid *grp_uuid);
+struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
+ int *next);
+
+int oig_init(struct obd_io_group **oig);
+void oig_add_one(struct obd_io_group *oig,
+ struct oig_callback_context *occ);
+void oig_complete_one(struct obd_io_group *oig,
+ struct oig_callback_context *occ, int rc);
+void oig_release(struct obd_io_group *oig);
+int oig_wait(struct obd_io_group *oig);
+/* ping evictor */
+#ifdef __KERNEL__
+void ping_evictor_start(void);
+void ping_evictor_stop(void);
+#else
+#define ping_evictor_start() do {} while (0)
+#define ping_evictor_stop() do {} while (0)
+#endif
+
+
+char *obd_export_nid2str(struct obd_export *exp);
+
+int obd_export_evict_by_nid(struct obd_device *obd, char *nid);
+int obd_export_evict_by_uuid(struct obd_device *obd, char *uuid);
+
+/* config.c */
+int class_process_config(struct lustre_cfg *lcfg);
+int class_attach(struct lustre_cfg *lcfg);
+int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
+int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
+int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
+void class_decref(struct obd_device *obd);
+
+/* Passed as data param to class_config_parse_llog */
+struct config_llog_instance {
+ char * cfg_instance;
+ struct obd_uuid cfg_uuid;
+};
+int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
+ struct config_llog_instance *cfg);
+int class_config_dump_llog(struct llog_ctxt *ctxt, char *name,
+ struct config_llog_instance *cfg);
+
+struct lustre_profile {
+ struct list_head lp_list;
+ char * lp_profile;
+ char * lp_osc;
+ char * lp_mdc;
+};
+
+struct lustre_profile *class_get_profile(char * prof);
+void class_del_profile(char *prof);
+
+#define class_export_get(exp) \
+({ \
+ struct obd_export *exp_ = exp; \
+ atomic_inc(&exp_->exp_refcount); \
+ CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp_, \
+ atomic_read(&exp_->exp_refcount)); \
+ exp_; \
+})
+
+#define class_export_put(exp) \
+do { \
+ LASSERT((exp) != NULL); \
+ CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", (exp), \
+ atomic_read(&(exp)->exp_refcount) - 1); \
+ LASSERT(atomic_read(&(exp)->exp_refcount) > 0); \
+ LASSERT(atomic_read(&(exp)->exp_refcount) < 0x5a5a5a); \
+ __class_export_put(exp); \
+} while (0)
+void __class_export_put(struct obd_export *);
+struct obd_export *class_new_export(struct obd_device *obddev);
+void class_unlink_export(struct obd_export *exp);
+void class_update_export_timer(struct obd_export *exp, time_t extra_delay);
+
+struct obd_import *class_import_get(struct obd_import *);
+void class_import_put(struct obd_import *);
+struct obd_import *class_new_import(void);
+void class_destroy_import(struct obd_import *exp);
+
+struct obd_type *class_get_type(char *name);
+void class_put_type(struct obd_type *type);
+int class_connect(struct lustre_handle *conn, struct obd_device *obd,
+ struct obd_uuid *cluuid);
+int class_disconnect(struct obd_export *exp);
+void class_fail_export(struct obd_export *exp);
+void class_disconnect_exports(struct obd_device *obddev);
+void class_disconnect_stale_exports(struct obd_device *obddev);
+void class_manual_cleanup(struct obd_device *obd);
+
+/* obdo.c */
+void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid);
+int obdo_cmp_md(struct obdo *dst, struct obdo *src, obd_flag compare);
+void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj);
+
+
+#define OBT(dev) (dev)->obd_type
+#define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op
+#define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op
+
+/* Ensure obd_setup: used for cleanup which must be called
+ while obd is stopping */
+#define OBD_CHECK_DEV(obd) \
+do { \
+ if (!(obd)) { \
+ CERROR("NULL device\n"); \
+ RETURN(-ENODEV); \
+ } \
+} while (0)
+
+/* ensure obd_setup and !obd_stopping */
+#define OBD_CHECK_DEV_ACTIVE(obd) \
+do { \
+ OBD_CHECK_DEV(obd); \
+ if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
+ CERROR("Device %d not setup\n", \
+ (obd)->obd_minor); \
+ RETURN(-ENODEV); \
+ } \
+} while (0)
+
+
+#ifdef LPROCFS
+#define OBD_COUNTER_OFFSET(op) \
+ ((offsetof(struct obd_ops, o_ ## op) - \
+ offsetof(struct obd_ops, o_iocontrol)) \
+ / sizeof(((struct obd_ops *)(0))->o_iocontrol))
+
+#define OBD_COUNTER_INCREMENT(obd, op) \
+ if ((obd)->obd_stats != NULL) { \
+ unsigned int coffset; \
+ coffset = (unsigned int)(obd)->obd_cntr_base + \
+ OBD_COUNTER_OFFSET(op); \
+ LASSERT(coffset < obd->obd_stats->ls_num); \
+ lprocfs_counter_incr(obd->obd_stats, coffset); \
+ }
+#else
+#define OBD_COUNTER_OFFSET(op)
+#define OBD_COUNTER_INCREMENT(obd, op)
+#endif
+
+#define OBD_CHECK_OP(obd, op, err) \
+do { \
+ if (!OBT(obd) || !OBP((obd), op)) {\
+ if (err) \
+ CERROR("obd_" #op ": dev %d no operation\n", \
+ obd->obd_minor); \
+ RETURN(err); \
+ } \
+} while (0)
+
+#define EXP_CHECK_OP(exp, op) \
+do { \
+ if ((exp) == NULL) { \
+ CERROR("obd_" #op ": NULL export\n"); \
+ RETURN(-ENODEV); \
+ } \
+ if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \
+ CERROR("obd_" #op ": cleaned up obd\n"); \
+ RETURN(-EOPNOTSUPP); \
+ } \
+ if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \
+ CERROR("obd_" #op ": dev %d no operation\n", \
+ (exp)->exp_obd->obd_minor); \
+ RETURN(-EOPNOTSUPP); \
+ } \
+} while (0)
+
+#define CTXT_CHECK_OP(ctxt, op, err) \
+do { \
+ if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \
+ if (err) \
+ CERROR("lop_" #op ": dev %d no operation\n", \
+ ctxt->loc_obd->obd_minor); \
+ RETURN(err); \
+ } \
+} while (0)
+
+static inline int obd_get_info(struct obd_export *exp, __u32 keylen,
+ void *key, __u32 *vallen, void *val)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, get_info);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, get_info);
+
+ rc = OBP(exp->exp_obd, get_info)(exp, keylen, key, vallen, val);
+ RETURN(rc);
+}
+
+static inline int obd_set_info(struct obd_export *exp, obd_count keylen,
+ void *key, obd_count vallen, void *val)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, set_info);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, set_info);
+
+ rc = OBP(exp->exp_obd, set_info)(exp, keylen, key, vallen, val);
+ RETURN(rc);
+}
+
+static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(obd, setup, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, setup);
+
+ rc = OBP(obd, setup)(obd, datalen, data);
+ RETURN(rc);
+}
+
+static inline int obd_precleanup(struct obd_device *obd, int cleanup_stage)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(obd, precleanup, 0);
+ OBD_COUNTER_INCREMENT(obd, precleanup);
+
+ rc = OBP(obd, precleanup)(obd, cleanup_stage);
+ RETURN(rc);
+}
+
+static inline int obd_cleanup(struct obd_device *obd)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_DEV(obd);
+ OBD_CHECK_OP(obd, cleanup, 0);
+ OBD_COUNTER_INCREMENT(obd, cleanup);
+
+ rc = OBP(obd, cleanup)(obd);
+ RETURN(rc);
+}
+
+static inline int
+obd_process_config(struct obd_device *obd, int datalen, void *data)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(obd, process_config, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, process_config);
+
+ rc = OBP(obd, process_config)(obd, datalen, data);
+ RETURN(rc);
+}
+
+/* Pack an in-memory MD struct for storage on disk.
+ * Returns +ve size of packed MD (0 for free), or -ve error.
+ *
+ * If @disk_tgt == NULL, MD size is returned (max size if @mem_src == NULL).
+ * If @*disk_tgt != NULL and @mem_src == NULL, @*disk_tgt will be freed.
+ * If @*disk_tgt == NULL, it will be allocated
+ */
+static inline int obd_packmd(struct obd_export *exp,
+ struct lov_mds_md **disk_tgt,
+ struct lov_stripe_md *mem_src)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, packmd);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, packmd);
+
+ rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src);
+ RETURN(rc);
+}
+
+static inline int obd_size_diskmd(struct obd_export *exp,
+ struct lov_stripe_md *mem_src)
+{
+ return obd_packmd(exp, NULL, mem_src);
+}
+
+/* helper functions */
+static inline int obd_alloc_diskmd(struct obd_export *exp,
+ struct lov_mds_md **disk_tgt)
+{
+ LASSERT(disk_tgt);
+ LASSERT(*disk_tgt == NULL);
+ return obd_packmd(exp, disk_tgt, NULL);
+}
+
+static inline int obd_free_diskmd(struct obd_export *exp,
+ struct lov_mds_md **disk_tgt)
+{
+ LASSERT(disk_tgt);
+ LASSERT(*disk_tgt);
+ return obd_packmd(exp, disk_tgt, NULL);
+}
+
+/* Unpack an MD struct from disk to in-memory format.
+ * Returns +ve size of unpacked MD (0 for free), or -ve error.
+ *
+ * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL).
+ * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed.
+ * If @*mem_tgt == NULL, it will be allocated
+ */
+static inline int obd_unpackmd(struct obd_export *exp,
+ struct lov_stripe_md **mem_tgt,
+ struct lov_mds_md *disk_src,
+ int disk_len)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, unpackmd);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, unpackmd);
+
+ rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len);
+ RETURN(rc);
+}
+
+/* helper functions */
+static inline int obd_alloc_memmd(struct obd_export *exp,
+ struct lov_stripe_md **mem_tgt)
+{
+ LASSERT(mem_tgt);
+ LASSERT(*mem_tgt == NULL);
+ return obd_unpackmd(exp, mem_tgt, NULL, 0);
+}
+
+static inline int obd_free_memmd(struct obd_export *exp,
+ struct lov_stripe_md **mem_tgt)
+{
+ LASSERT(mem_tgt);
+ LASSERT(*mem_tgt);
+ return obd_unpackmd(exp, mem_tgt, NULL, 0);
+}
+
+static inline int obd_create(struct obd_export *exp, struct obdo *obdo,
+ struct lov_stripe_md **ea,
+ struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, create);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, create);
+
+ rc = OBP(exp->exp_obd, create)(exp, obdo, ea, oti);
+ RETURN(rc);
+}
+
+static inline int obd_destroy(struct obd_export *exp, struct obdo *obdo,
+ struct lov_stripe_md *ea,
+ struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, destroy);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, destroy);
+
+ rc = OBP(exp->exp_obd, destroy)(exp, obdo, ea, oti);
+ RETURN(rc);
+}
+
+static inline int obd_getattr(struct obd_export *exp, struct obdo *obdo,
+ struct lov_stripe_md *ea)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, getattr);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, getattr);
+
+ rc = OBP(exp->exp_obd, getattr)(exp, obdo, ea);
+ RETURN(rc);
+}
+
+static inline int obd_getattr_async(struct obd_export *exp,
+ struct obdo *obdo, struct lov_stripe_md *ea,
+ struct ptlrpc_request_set *set)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, getattr);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, getattr);
+
+ rc = OBP(exp->exp_obd, getattr_async)(exp, obdo, ea, set);
+ RETURN(rc);
+}
+
+static inline int obd_setattr(struct obd_export *exp, struct obdo *obdo,
+ struct lov_stripe_md *ea,
+ struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, setattr);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, setattr);
+
+ rc = OBP(exp->exp_obd, setattr)(exp, obdo, ea, oti);
+ RETURN(rc);
+}
+
+static inline int obd_setattr_async(struct obd_export *exp,
+ struct obdo *obdo,
+ struct lov_stripe_md *ea,
+ struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, setattr_async);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, setattr_async);
+
+ rc = OBP(exp->exp_obd, setattr_async)(exp, obdo, ea, oti);
+ RETURN(rc);
+}
+
+static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
+ int priority)
+{
+ struct obd_device *obd = imp->imp_obd;
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_DEV_ACTIVE(obd);
+ OBD_CHECK_OP(obd, add_conn, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, add_conn);
+
+ rc = OBP(obd, add_conn)(imp, uuid, priority);
+ RETURN(rc);
+}
+
+static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
+{
+ struct obd_device *obd = imp->imp_obd;
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_DEV_ACTIVE(obd);
+ OBD_CHECK_OP(obd, del_conn, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, del_conn);
+
+ rc = OBP(obd, del_conn)(imp, uuid);
+ RETURN(rc);
+}
+
+static inline int obd_connect(struct lustre_handle *conn, struct obd_device *obd,
+ struct obd_uuid *cluuid,
+ struct obd_connect_data *d)
+{
+ int rc;
+ __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */
+ ENTRY;
+
+ OBD_CHECK_DEV_ACTIVE(obd);
+ OBD_CHECK_OP(obd, connect, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, connect);
+
+ rc = OBP(obd, connect)(conn, obd, cluuid, d);
+ /* check that only subset is granted */
+ LASSERT(ergo(d != NULL,
+ (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
+ RETURN(rc);
+}
+
+static inline int obd_disconnect(struct obd_export *exp)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, disconnect);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, disconnect);
+
+ rc = OBP(exp->exp_obd, disconnect)(exp);
+ RETURN(rc);
+}
+
+static inline int obd_init_export(struct obd_export *exp)
+{
+ int rc = 0;
+
+ ENTRY;
+ if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
+ OBP((exp)->exp_obd, init_export))
+ rc = OBP(exp->exp_obd, init_export)(exp);
+ RETURN(rc);
+}
+
+static inline int obd_destroy_export(struct obd_export *exp)
+{
+ ENTRY;
+ if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
+ OBP((exp)->exp_obd, destroy_export))
+ OBP(exp->exp_obd, destroy_export)(exp);
+ RETURN(0);
+}
+
+static inline struct dentry *
+obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
+{
+ LASSERT(exp->exp_obd);
+
+ return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr,
+ exp->exp_obd);
+}
+
+#ifndef time_before
+#define time_before(t1, t2) ((long)t2 - (long)t1 > 0)
+#endif
+
+/* @max_age is the oldest time in jiffies that we accept using a cached data.
+ * If the cache is older than @max_age we will get a new value from the
+ * target. Use a value of "jiffies + HZ" to guarantee freshness. */
+static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
+ unsigned long max_age)
+{
+ int rc = 0;
+ ENTRY;
+
+ if (obd == NULL)
+ RETURN(-EINVAL);
+
+ OBD_CHECK_OP(obd, statfs, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(obd, statfs);
+
+ CDEBUG(D_SUPER, "osfs %lu, max_age %lu\n", obd->obd_osfs_age, max_age);
+ if (time_before(obd->obd_osfs_age, max_age)) {
+ rc = OBP(obd, statfs)(obd, osfs, max_age);
+ if (rc == 0) {
+ spin_lock(&obd->obd_osfs_lock);
+ memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
+ obd->obd_osfs_age = cfs_time_current();
+ spin_unlock(&obd->obd_osfs_lock);
+ }
+ } else {
+ CDEBUG(D_SUPER, "using cached obd_statfs data\n");
+ spin_lock(&obd->obd_osfs_lock);
+ memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
+ spin_unlock(&obd->obd_osfs_lock);
+ }
+ RETURN(rc);
+}
+
+static inline int obd_sync(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, obd_size start,
+ obd_size end)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, sync, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, sync);
+
+ rc = OBP(exp->exp_obd, sync)(exp, oa, ea, start, end);
+ RETURN(rc);
+}
+
+static inline int obd_punch(struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, obd_size start,
+ obd_size end, struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, punch);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, punch);
+
+ rc = OBP(exp->exp_obd, punch)(exp, oa, ea, start, end, oti);
+ RETURN(rc);
+}
+
+static inline int obd_brw(int cmd, struct obd_export *exp, struct obdo *oa,
+ struct lov_stripe_md *ea, obd_count oa_bufs,
+ struct brw_page *pg, struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, brw);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, brw);
+
+ if (!(cmd & (OBD_BRW_RWMASK | OBD_BRW_CHECK))) {
+ CERROR("obd_brw: cmd must be OBD_BRW_READ, OBD_BRW_WRITE, "
+ "or OBD_BRW_CHECK\n");
+ LBUG();
+ }
+
+ rc = OBP(exp->exp_obd, brw)(cmd, exp, oa, ea, oa_bufs, pg, oti);
+ RETURN(rc);
+}
+
+static inline int obd_brw_async(int cmd, struct obd_export *exp,
+ struct obdo *oa, struct lov_stripe_md *ea,
+ obd_count oa_bufs, struct brw_page *pg,
+ struct ptlrpc_request_set *set,
+ struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, brw_async);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, brw_async);
+
+ if (!(cmd & OBD_BRW_RWMASK)) {
+ CERROR("obd_brw: cmd must be OBD_BRW_READ or OBD_BRW_WRITE\n");
+ LBUG();
+ }
+
+ rc = OBP(exp->exp_obd, brw_async)(cmd, exp, oa, ea, oa_bufs, pg, set,
+ oti);
+ RETURN(rc);
+}
+
+static inline int obd_prep_async_page(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct page *page, obd_off offset,
+ struct obd_async_page_ops *ops,
+ void *data, void **res)
+{
+ int ret;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, prep_async_page, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, prep_async_page);
+
+ ret = OBP(exp->exp_obd, prep_async_page)(exp, lsm, loi, page, offset,
+ ops, data, res);
+ RETURN(ret);
+}
+
+static inline int obd_queue_async_io(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi, void *cookie,
+ int cmd, obd_off off, int count,
+ obd_flag brw_flags, obd_flag async_flags)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, queue_async_io, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, queue_async_io);
+ LASSERT(cmd & OBD_BRW_RWMASK);
+
+ rc = OBP(exp->exp_obd, queue_async_io)(exp, lsm, loi, cookie, cmd, off,
+ count, brw_flags, async_flags);
+ RETURN(rc);
+}
+
+static inline int obd_set_async_flags(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi, void *cookie,
+ obd_flag async_flags)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, set_async_flags, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, set_async_flags);
+
+ rc = OBP(exp->exp_obd, set_async_flags)(exp, lsm, loi, cookie,
+ async_flags);
+ RETURN(rc);
+}
+
+static inline int obd_queue_group_io(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct obd_io_group *oig,
+ void *cookie, int cmd, obd_off off,
+ int count, obd_flag brw_flags,
+ obd_flag async_flags)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, queue_group_io, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, queue_group_io);
+ LASSERT(cmd & OBD_BRW_RWMASK);
+
+ rc = OBP(exp->exp_obd, queue_group_io)(exp, lsm, loi, oig, cookie,
+ cmd, off, count, brw_flags,
+ async_flags);
+ RETURN(rc);
+}
+
+static inline int obd_trigger_group_io(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct obd_io_group *oig)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, trigger_group_io, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, trigger_group_io);
+
+ rc = OBP(exp->exp_obd, trigger_group_io)(exp, lsm, loi, oig);
+ RETURN(rc);
+}
+
+static inline int obd_teardown_async_page(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi, void *cookie)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, teardown_async_page, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, teardown_async_page);
+
+ rc = OBP(exp->exp_obd, teardown_async_page)(exp, lsm, loi, cookie);
+ RETURN(rc);
+}
+
+static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
+ int objcount, struct obd_ioobj *obj,
+ int niocount, struct niobuf_remote *remote,
+ struct niobuf_local *local,
+ struct obd_trans_info *oti)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, preprw, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, preprw);
+
+ rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, niocount,
+ remote, local, oti);
+ RETURN(rc);
+}
+
+static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
+ int objcount, struct obd_ioobj *obj,
+ int niocount, struct niobuf_local *local,
+ struct obd_trans_info *oti, int rc)
+{
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, commitrw, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, commitrw);
+
+ rc = OBP(exp->exp_obd, commitrw)(cmd, exp, oa, objcount, obj, niocount,
+ local, oti, rc);
+ RETURN(rc);
+}
+
+/* b1_4_bug5047 has changes to make this an obd_merge_lvb() method */
+__u64 lov_merge_size(struct lov_stripe_md *lsm, int kms_only);
+__u64 lov_merge_blocks(struct lov_stripe_md *lsm);
+__u64 lov_merge_mtime(struct lov_stripe_md *lsm, __u64 current_time);
+
+static inline int obd_adjust_kms(struct obd_export *exp,
+ struct lov_stripe_md *lsm, obd_off size,
+ int shrink)
+{
+ int rc;
+ ENTRY;
+
+ OBD_CHECK_OP(exp->exp_obd, adjust_kms, -EOPNOTSUPP);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, adjust_kms);
+
+ rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink);
+ RETURN(rc);
+}
+
+static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
+ int len, void *karg, void *uarg)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, iocontrol);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, iocontrol);
+
+ rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
+ RETURN(rc);
+}
+
+static inline int obd_enqueue(struct obd_export *exp, struct lov_stripe_md *ea,
+ __u32 type, ldlm_policy_data_t *policy,
+ __u32 mode, int *flags, void *bl_cb, void *cp_cb,
+ void *gl_cb, void *data, __u32 lvb_len,
+ void *lvb_swabber, struct lustre_handle *lockh)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, enqueue);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, enqueue);
+
+ rc = OBP(exp->exp_obd, enqueue)(exp, ea, type, policy, mode, flags,
+ bl_cb, cp_cb, gl_cb, data, lvb_len,
+ lvb_swabber, lockh);
+ RETURN(rc);
+}
+
+static inline int obd_match(struct obd_export *exp, struct lov_stripe_md *ea,
+ __u32 type, ldlm_policy_data_t *policy, __u32 mode,
+ int *flags, void *data, struct lustre_handle *lockh)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, match);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, match);
+
+ rc = OBP(exp->exp_obd, match)(exp, ea, type, policy, mode, flags, data,
+ lockh);
+ RETURN(rc);
+}
+
+static inline int obd_change_cbdata(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ ldlm_iterator_t it, void *data)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, change_cbdata);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata);
+
+ rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data);
+ RETURN(rc);
+}
+
+static inline int obd_cancel(struct obd_export *exp,
+ struct lov_stripe_md *ea, __u32 mode,
+ struct lustre_handle *lockh)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, cancel);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, cancel);
+
+ rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh);
+ RETURN(rc);
+}
+
+static inline int obd_cancel_unused(struct obd_export *exp,
+ struct lov_stripe_md *ea, int flags,
+ void *opaque)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, cancel_unused);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, cancel_unused);
+
+ rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque);
+ RETURN(rc);
+}
+
+static inline int obd_join_lru(struct obd_export *exp,
+ struct lov_stripe_md *ea, int join)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, join_lru);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, join_lru);
+
+ rc = OBP(exp->exp_obd, join_lru)(exp, ea, join);
+ RETURN(rc);
+}
+
+static inline int obd_san_preprw(int cmd, struct obd_export *exp,
+ struct obdo *oa,
+ int objcount, struct obd_ioobj *obj,
+ int niocount, struct niobuf_remote *remote)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, preprw);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, preprw);
+
+ rc = OBP(exp->exp_obd, san_preprw)(cmd, exp, oa, objcount, obj,
+ niocount, remote);
+ class_export_put(exp);
+ RETURN(rc);
+}
+
+static inline int obd_pin(struct obd_export *exp, obd_id ino, __u32 gen,
+ int type, struct obd_client_handle *handle, int flag)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, pin);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, pin);
+
+ rc = OBP(exp->exp_obd, pin)(exp, ino, gen, type, handle, flag);
+ RETURN(rc);
+}
+
+static inline int obd_unpin(struct obd_export *exp,
+ struct obd_client_handle *handle, int flag)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, unpin);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, unpin);
+
+ rc = OBP(exp->exp_obd, unpin)(exp, handle, flag);
+ RETURN(rc);
+}
+
+
+static inline void obd_import_event(struct obd_device *obd,
+ struct obd_import *imp,
+ enum obd_import_event event)
+{
+ ENTRY;
+ if (!obd) {
+ CERROR("NULL device\n");
+ EXIT;
+ return;
+ }
+ if (obd->obd_set_up && OBP(obd, import_event)) {
+ OBD_COUNTER_INCREMENT(obd, import_event);
+ OBP(obd, import_event)(obd, imp, event);
+ }
+ EXIT;
+}
+
+static inline int obd_notify(struct obd_device *obd,
+ struct obd_device *watched,
+ int active)
+{
+ ENTRY;
+ OBD_CHECK_DEV(obd);
+ if (!obd->obd_set_up) {
+ CERROR("obd %s not set up\n", obd->obd_name);
+ RETURN(-EINVAL);
+ }
+
+ if (!OBP(obd, notify)) {
+ CERROR("obd %s has no notify handler\n", obd->obd_name);
+ RETURN(-ENOSYS);
+ }
+
+ OBD_COUNTER_INCREMENT(obd, notify);
+ RETURN(OBP(obd, notify)(obd, watched, active));
+}
+
+static inline int obd_quotacheck(struct obd_export *exp,
+ struct obd_quotactl *oqctl)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, quotacheck);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, quotacheck);
+
+ rc = OBP(exp->exp_obd, quotacheck)(exp, oqctl);
+ RETURN(rc);
+}
+
+static inline int obd_quotactl(struct obd_export *exp,
+ struct obd_quotactl *oqctl)
+{
+ int rc;
+ ENTRY;
+
+ EXP_CHECK_OP(exp, quotactl);
+ OBD_COUNTER_INCREMENT(exp->exp_obd, quotactl);
+
+ rc = OBP(exp->exp_obd, quotactl)(exp, oqctl);
+ RETURN(rc);
+}
+
+static inline int obd_health_check(struct obd_device *obd)
+{
+ /* returns: 0 on healthy
+ * >0 on unhealthy + reason code/flag
+ * however the only suppored reason == 1 right now
+ * We'll need to define some better reasons
+ * or flags in the future.
+ * <0 on error
+ */
+ int rc;
+ ENTRY;
+
+ /* don't use EXP_CHECK_OP, because NULL method is normal here */
+ if (obd == NULL || !OBT(obd)) {
+ CERROR("cleaned up obd\n");
+ RETURN(-EOPNOTSUPP);
+ }
+ if (!obd->obd_set_up || obd->obd_stopping)
+ RETURN(0);
+ if (!OBP(obd, health_check))
+ RETURN(0);
+
+ rc = OBP(obd, health_check)(obd);
+ RETURN(rc);
+}
+
+static inline int obd_register_observer(struct obd_device *obd,
+ struct obd_device *observer)
+{
+ ENTRY;
+ OBD_CHECK_DEV(obd);
+ if (obd->obd_observer && observer)
+ RETURN(-EALREADY);
+ obd->obd_observer = observer;
+ RETURN(0);
+}
+
+/* OBD Metadata Support */
+
+extern int obd_init_caches(void);
+extern void obd_cleanup_caches(void);
+
+/* support routines */
+extern cfs_mem_cache_t *obdo_cachep;
+static inline struct obdo *obdo_alloc(void)
+{
+ struct obdo *oa;
+
+ OBD_SLAB_ALLOC(oa, obdo_cachep, CFS_ALLOC_STD, sizeof(*oa));
+
+ return oa;
+}
+
+static inline void obdo_free(struct obdo *oa)
+{
+ OBD_SLAB_FREE(oa, obdo_cachep, sizeof(*oa));
+}
+
+/* I'm as embarrassed about this as you are.
+ *
+ * <shaver> // XXX do not look into _superhack with remaining eye
+ * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
+extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
+extern void (*ptlrpc_abort_inflight_superhack)(struct obd_import *imp);
+
+/* sysctl.c */
+extern void obd_sysctl_init (void);
+extern void obd_sysctl_clean (void);
+
+/* uuid.c */
+typedef __u8 class_uuid_t[16];
+//int class_uuid_parse(struct obd_uuid in, class_uuid_t out);
+void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out);
+
+/* lustre_peer.c */
+int lustre_uuid_to_peer(char *uuid, lnet_nid_t *peer_nid, int index);
+int class_add_uuid(char *uuid, __u64 nid);
+int class_del_uuid (char *uuid);
+void class_init_uuidlist(void);
+void class_exit_uuidlist(void);
+
+#endif /* __LINUX_OBD_CLASS_H */
#define IOC_LOV_MAX_NR 50
#define QOS_DEFAULT_THRESHOLD 10 /* MB */
-#define QOS_DEFAULT_MAXAGE 5 /* Seconds */
+#define QOS_DEFAULT_MAXAGE 5 /* Seconds */
#endif
#ifndef _LUSTRE_OST_H
#define _LUSTRE_OST_H
-#include <linux/obd_class.h>
+#include <obd_class.h>
#define LUSTRE_FILTER_NAME "obdfilter"
#define LUSTRE_OST_NAME "ost"
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _OBD_SUPPORT
+#define _OBD_SUPPORT
+
+#include <libcfs/kp30.h>
+
+/* global variables */
+extern atomic_t obd_memory;
+extern int obd_memmax;
+extern unsigned int obd_fail_loc;
+extern unsigned int obd_dump_on_timeout;
+extern unsigned int obd_timeout; /* seconds */
+#define PING_INTERVAL max(obd_timeout / 4, 1U)
+#define STATFS_INTERVAL max(obd_timeout / 20, 1U)
+extern unsigned int ldlm_timeout;
+extern unsigned int obd_health_check_timeout;
+extern char obd_lustre_upcall[128];
+extern unsigned int obd_sync_filter;
+extern cfs_waitq_t obd_race_waitq;
+
+#define OBD_FAIL_MDS 0x100
+#define OBD_FAIL_MDS_HANDLE_UNPACK 0x101
+#define OBD_FAIL_MDS_GETATTR_NET 0x102
+#define OBD_FAIL_MDS_GETATTR_PACK 0x103
+#define OBD_FAIL_MDS_READPAGE_NET 0x104
+#define OBD_FAIL_MDS_READPAGE_PACK 0x105
+#define OBD_FAIL_MDS_SENDPAGE 0x106
+#define OBD_FAIL_MDS_REINT_NET 0x107
+#define OBD_FAIL_MDS_REINT_UNPACK 0x108
+#define OBD_FAIL_MDS_REINT_SETATTR 0x109
+#define OBD_FAIL_MDS_REINT_SETATTR_WRITE 0x10a
+#define OBD_FAIL_MDS_REINT_CREATE 0x10b
+#define OBD_FAIL_MDS_REINT_CREATE_WRITE 0x10c
+#define OBD_FAIL_MDS_REINT_UNLINK 0x10d
+#define OBD_FAIL_MDS_REINT_UNLINK_WRITE 0x10e
+#define OBD_FAIL_MDS_REINT_LINK 0x10f
+#define OBD_FAIL_MDS_REINT_LINK_WRITE 0x110
+#define OBD_FAIL_MDS_REINT_RENAME 0x111
+#define OBD_FAIL_MDS_REINT_RENAME_WRITE 0x112
+#define OBD_FAIL_MDS_OPEN_NET 0x113
+#define OBD_FAIL_MDS_OPEN_PACK 0x114
+#define OBD_FAIL_MDS_CLOSE_NET 0x115
+#define OBD_FAIL_MDS_CLOSE_PACK 0x116
+#define OBD_FAIL_MDS_CONNECT_NET 0x117
+#define OBD_FAIL_MDS_CONNECT_PACK 0x118
+#define OBD_FAIL_MDS_REINT_NET_REP 0x119
+#define OBD_FAIL_MDS_DISCONNECT_NET 0x11a
+#define OBD_FAIL_MDS_GETSTATUS_NET 0x11b
+#define OBD_FAIL_MDS_GETSTATUS_PACK 0x11c
+#define OBD_FAIL_MDS_STATFS_PACK 0x11d
+#define OBD_FAIL_MDS_STATFS_NET 0x11e
+#define OBD_FAIL_MDS_GETATTR_NAME_NET 0x11f
+#define OBD_FAIL_MDS_PIN_NET 0x120
+#define OBD_FAIL_MDS_UNPIN_NET 0x121
+#define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
+#define OBD_FAIL_MDS_ALL_REQUEST_NET 0x123
+#define OBD_FAIL_MDS_SYNC_NET 0x124
+#define OBD_FAIL_MDS_SYNC_PACK 0x125
+#define OBD_FAIL_MDS_DONE_WRITING_NET 0x126
+#define OBD_FAIL_MDS_DONE_WRITING_PACK 0x127
+#define OBD_FAIL_MDS_ALLOC_OBDO 0x128
+#define OBD_FAIL_MDS_PAUSE_OPEN 0x129
+#define OBD_FAIL_MDS_STATFS_LCW_SLEEP 0x12a
+#define OBD_FAIL_MDS_OPEN_CREATE 0x12b
+#define OBD_FAIL_MDS_OST_SETATTR 0x12c
+#define OBD_FAIL_MDS_QUOTACHECK_NET 0x12d
+#define OBD_FAIL_MDS_QUOTACTL_NET 0x12e
+#define OBD_FAIL_MDS_CLIENT_ADD 0x12f
+#define OBD_FAIL_MDS_GETXATTR_NET 0x130
+#define OBD_FAIL_MDS_GETXATTR_PACK 0x131
+#define OBD_FAIL_MDS_SETXATTR_NET 0x132
+#define OBD_FAIL_MDS_SETXATTR 0x133
+#define OBD_FAIL_MDS_SETXATTR_WRITE 0x134
+
+#define OBD_FAIL_OST 0x200
+#define OBD_FAIL_OST_CONNECT_NET 0x201
+#define OBD_FAIL_OST_DISCONNECT_NET 0x202
+#define OBD_FAIL_OST_GET_INFO_NET 0x203
+#define OBD_FAIL_OST_CREATE_NET 0x204
+#define OBD_FAIL_OST_DESTROY_NET 0x205
+#define OBD_FAIL_OST_GETATTR_NET 0x206
+#define OBD_FAIL_OST_SETATTR_NET 0x207
+#define OBD_FAIL_OST_OPEN_NET 0x208
+#define OBD_FAIL_OST_CLOSE_NET 0x209
+#define OBD_FAIL_OST_BRW_NET 0x20a
+#define OBD_FAIL_OST_PUNCH_NET 0x20b
+#define OBD_FAIL_OST_STATFS_NET 0x20c
+#define OBD_FAIL_OST_HANDLE_UNPACK 0x20d
+#define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
+#define OBD_FAIL_OST_BRW_READ_BULK 0x20f
+#define OBD_FAIL_OST_SYNC_NET 0x210
+#define OBD_FAIL_OST_ALL_REPLY_NET 0x211
+#define OBD_FAIL_OST_ALL_REQUESTS_NET 0x212
+#define OBD_FAIL_OST_LDLM_REPLY_NET 0x213
+#define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
+#define OBD_FAIL_OST_ENOSPC 0x215
+#define OBD_FAIL_OST_EROFS 0x216
+#define OBD_FAIL_OST_ENOENT 0x217
+#define OBD_FAIL_OST_QUOTACHECK_NET 0x218
+#define OBD_FAIL_OST_QUOTACTL_NET 0x219
+
+#define OBD_FAIL_LDLM 0x300
+#define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301
+#define OBD_FAIL_LDLM_ENQUEUE 0x302
+#define OBD_FAIL_LDLM_CONVERT 0x303
+#define OBD_FAIL_LDLM_CANCEL 0x304
+#define OBD_FAIL_LDLM_BL_CALLBACK 0x305
+#define OBD_FAIL_LDLM_CP_CALLBACK 0x306
+#define OBD_FAIL_LDLM_GL_CALLBACK 0x307
+#define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
+#define OBD_FAIL_LDLM_ENQUEUE_INTENT_ERR 0x309
+#define OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
+#define OBD_FAIL_LDLM_ENQUEUE_BLOCKED 0x30b
+#define OBD_FAIL_LDLM_REPLY 0x30c
+#define OBD_FAIL_LDLM_RECOV_CLIENTS 0x30d
+#define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
+
+#define OBD_FAIL_OSC 0x400
+#define OBD_FAIL_OSC_BRW_READ_BULK 0x401
+#define OBD_FAIL_OSC_BRW_WRITE_BULK 0x402
+#define OBD_FAIL_OSC_LOCK_BL_AST 0x403
+#define OBD_FAIL_OSC_LOCK_CP_AST 0x404
+#define OBD_FAIL_OSC_MATCH 0x405
+#define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
+#define OBD_FAIL_OSC_SHUTDOWN 0x407
+
+#define OBD_FAIL_PTLRPC 0x500
+#define OBD_FAIL_PTLRPC_ACK 0x501
+#define OBD_FAIL_PTLRPC_RQBD 0x502
+#define OBD_FAIL_PTLRPC_BULK_GET_NET 0x503
+#define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504
+#define OBD_FAIL_PTLRPC_DROP_RPC 0x505
+
+#define OBD_FAIL_OBD_PING_NET 0x600
+#define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
+#define OBD_FAIL_OBD_LOGD_NET 0x602
+#define OBD_FAIL_OBD_QC_CALLBACK_NET 0x603
+#define OBD_FAIL_OBD_DQACQ 0x604
+
+#define OBD_FAIL_TGT_REPLY_NET 0x700
+#define OBD_FAIL_TGT_CONN_RACE 0x701
+
+#define OBD_FAIL_MDC_REVALIDATE_PAUSE 0x800
+
+#define OBD_FAIL_OST_CROW_EIO 0x801
+#define OBD_FAIL_OST_CLEAR_ORPHANS_RACE 0x802
+
+/* preparation for a more advanced failure testbed (not functional yet) */
+#define OBD_FAIL_MASK_SYS 0x0000FF00
+#define OBD_FAIL_MASK_LOC (0x000000FF | OBD_FAIL_MASK_SYS)
+#define OBD_FAIL_ONCE 0x80000000
+#define OBD_FAILED 0x40000000
+#define OBD_FAIL_MDS_ALL_NET 0x01000000
+#define OBD_FAIL_OST_ALL_NET 0x02000000
+
+#define OBD_FAIL_CHECK(id) (((obd_fail_loc & OBD_FAIL_MASK_LOC) == \
+ ((id) & OBD_FAIL_MASK_LOC)) && \
+ ((obd_fail_loc & (OBD_FAILED | OBD_FAIL_ONCE))!= \
+ (OBD_FAILED | OBD_FAIL_ONCE)))
+
+#define OBD_FAIL_CHECK_ONCE(id) \
+({ int _ret_ = 0; \
+ if (OBD_FAIL_CHECK(id)) { \
+ CERROR("*** obd_fail_loc=%x ***\n", id); \
+ obd_fail_loc |= OBD_FAILED; \
+ if ((id) & OBD_FAIL_ONCE) \
+ obd_fail_loc |= OBD_FAIL_ONCE; \
+ _ret_ = 1; \
+ } \
+ _ret_; \
+})
+
+#define OBD_FAIL_RETURN(id, ret) \
+do { \
+ if (OBD_FAIL_CHECK_ONCE(id)) { \
+ RETURN(ret); \
+ } \
+} while(0)
+
+#define OBD_FAIL_TIMEOUT(id, secs) \
+do { \
+ if (OBD_FAIL_CHECK_ONCE(id)) { \
+ CERROR("obd_fail_timeout id %x sleeping for %d secs\n", \
+ (id), (secs)); \
+ set_current_state(TASK_UNINTERRUPTIBLE); \
+ cfs_schedule_timeout(CFS_TASK_UNINT, \
+ cfs_time_seconds(secs)); \
+ set_current_state(TASK_RUNNING); \
+ CERROR("obd_fail_timeout id %x awake\n", (id)); \
+ } \
+} while(0)
+
+#ifdef __KERNEL__
+/* The idea here is to synchronise two threads to force a race. The
+ * first thread that calls this with a matching fail_loc is put to
+ * sleep. The next thread that calls with the same fail_loc wakes up
+ * the first and continues. */
+#define OBD_RACE(id) \
+do { \
+ if (OBD_FAIL_CHECK_ONCE(id)) { \
+ CERROR("obd_race id %x sleeping\n", (id)); \
+ OBD_SLEEP_ON(&obd_race_waitq); \
+ CERROR("obd_fail_race id %x awake\n", (id)); \
+ } else if ((obd_fail_loc & OBD_FAIL_MASK_LOC) == \
+ ((id) & OBD_FAIL_MASK_LOC)) { \
+ cfs_waitq_signal(&obd_race_waitq); \
+ } \
+} while(0)
+#else
+/* sigh. an expedient fix until OBD_RACE is fixed up */
+#define OBD_RACE(foo) do {} while(0)
+#endif
+
+#define fixme() CDEBUG(D_OTHER, "FIXME\n");
+
+extern atomic_t libcfs_kmemory;
+
+#if defined(LUSTRE_UTILS) /* this version is for utils only */
+#define OBD_ALLOC_GFP(ptr, size, gfp_mask) \
+do { \
+ (ptr) = cfs_alloc(size, (gfp_mask)); \
+ if ((ptr) == NULL) { \
+ CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
+ (int)(size), __FILE__, __LINE__); \
+ } else { \
+ memset(ptr, 0, size); \
+ CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p\n", \
+ (int)(size), ptr); \
+ } \
+} while (0)
+#else /* this version is for the kernel and liblustre */
+#define OBD_ALLOC_GFP(ptr, size, gfp_mask) \
+do { \
+ (ptr) = cfs_alloc(size, (gfp_mask)); \
+ if ((ptr) == NULL) { \
+ CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
+ (int)(size), __FILE__, __LINE__); \
+ CERROR("%d total bytes allocated by Lustre, %d by Portals\n", \
+ atomic_read(&obd_memory), atomic_read(&libcfs_kmemory));\
+ } else { \
+ memset(ptr, 0, size); \
+ atomic_add(size, &obd_memory); \
+ if (atomic_read(&obd_memory) > obd_memmax) \
+ obd_memmax = atomic_read(&obd_memory); \
+ CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d)\n", \
+ (int)(size), ptr, atomic_read(&obd_memory)); \
+ } \
+} while (0)
+#endif
+
+#ifndef OBD_ALLOC_MASK
+# define OBD_ALLOC_MASK CFS_ALLOC_IO
+#endif
+
+#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, OBD_ALLOC_MASK)
+#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, CFS_ALLOC_STD)
+#define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof *(ptr))
+#define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof *(ptr))
+
+#ifdef __arch_um__
+# define OBD_VMALLOC(ptr, size) OBD_ALLOC(ptr, size)
+#else
+# define OBD_VMALLOC(ptr, size) \
+do { \
+ (ptr) = cfs_alloc_large(size); \
+ if ((ptr) == NULL) { \
+ CERROR("vmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
+ (int)(size), __FILE__, __LINE__); \
+ CERROR("%d total bytes allocated by Lustre, %d by Portals\n", \
+ atomic_read(&obd_memory), atomic_read(&libcfs_kmemory));\
+ } else { \
+ memset(ptr, 0, size); \
+ atomic_add(size, &obd_memory); \
+ if (atomic_read(&obd_memory) > obd_memmax) \
+ obd_memmax = atomic_read(&obd_memory); \
+ CDEBUG(D_MALLOC, "vmalloced '" #ptr "': %d at %p (tot %d)\n", \
+ (int)(size), ptr, atomic_read(&obd_memory)); \
+ } \
+} while (0)
+#endif
+
+#ifdef CONFIG_DEBUG_SLAB
+#define POISON(ptr, c, s) do {} while (0)
+#else
+#define POISON(ptr, c, s) memset(ptr, c, s)
+#endif
+
+#if POISON_BULK
+#define POISON_PAGE(page, val) do { memset(kmap(page), val, PAGE_SIZE); \
+ kunmap(page); } while (0)
+#else
+#define POISON_PAGE(page, val) do { } while (0)
+#endif
+
+#ifdef __KERNEL__
+#define OBD_FREE(ptr, size) \
+do { \
+ LASSERT(ptr); \
+ atomic_sub(size, &obd_memory); \
+ CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n", \
+ (int)(size), ptr, atomic_read(&obd_memory)); \
+ POISON(ptr, 0x5a, size); \
+ cfs_free(ptr); \
+ (ptr) = (void *)0xdeadbeef; \
+} while (0)
+#else
+#define OBD_FREE(ptr, size) ((void)(size), free((ptr)))
+#endif
+
+#ifdef __arch_um__
+# define OBD_VFREE(ptr, size) OBD_FREE(ptr, size)
+#else
+# define OBD_VFREE(ptr, size) \
+do { \
+ LASSERT(ptr); \
+ atomic_sub(size, &obd_memory); \
+ CDEBUG(D_MALLOC, "vfreed '" #ptr "': %d at %p (tot %d).\n", \
+ (int)(size), ptr, atomic_read(&obd_memory)); \
+ POISON(ptr, 0x5a, size); \
+ cfs_free_large(ptr); \
+ (ptr) = (void *)0xdeadbeef; \
+} while (0)
+#endif
+
+/* we memset() the slab object to 0 when allocation succeeds, so DO NOT
+ * HAVE A CTOR THAT DOES ANYTHING. its work will be cleared here. we'd
+ * love to assert on that, but slab.c keeps kmem_cache_s all to itself. */
+#define OBD_SLAB_ALLOC(ptr, slab, type, size) \
+do { \
+ LASSERT(!in_interrupt()); \
+ (ptr) = cfs_mem_cache_alloc(slab, (type)); \
+ if ((ptr) == NULL) { \
+ CERROR("slab-alloc of '"#ptr"' (%d bytes) failed at %s:%d\n", \
+ (int)(size), __FILE__, __LINE__); \
+ CERROR("%d total bytes allocated by Lustre, %d by Portals\n", \
+ atomic_read(&obd_memory), atomic_read(&libcfs_kmemory));\
+ } else { \
+ memset(ptr, 0, size); \
+ atomic_add(size, &obd_memory); \
+ if (atomic_read(&obd_memory) > obd_memmax) \
+ obd_memmax = atomic_read(&obd_memory); \
+ CDEBUG(D_MALLOC, "slab-alloced '"#ptr"': %d at %p (tot %d)\n",\
+ (int)(size), ptr, atomic_read(&obd_memory)); \
+ } \
+} while (0)
+
+#define OBD_FREE_PTR(ptr) OBD_FREE(ptr, sizeof *(ptr))
+
+#define OBD_SLAB_FREE(ptr, slab, size) \
+do { \
+ LASSERT(ptr); \
+ CDEBUG(D_MALLOC, "slab-freed '" #ptr "': %d at %p (tot %d).\n", \
+ (int)(size), ptr, atomic_read(&obd_memory)); \
+ atomic_sub(size, &obd_memory); \
+ POISON(ptr, 0x5a, size); \
+ cfs_mem_cache_free(slab, ptr); \
+ (ptr) = (void *)0xdeadbeef; \
+} while (0)
+
+#define KEY_IS(str) \
+ (keylen == strlen(str) && memcmp(key, str, keylen) == 0)
+
+#if defined(__linux__)
+#include <linux/obd_support.h>
+#elif defined(__APPLE__)
+#include <darwin/obd_support.h>
+#elif defined(__WINNT__)
+#include <winnt/obd_support.h>
+#else
+#error Unsupported operating system.
+#endif
+
+#endif
#include <asm/byteorder.h>
#include <asm/uaccess.h>
-#include <linux/lustre_quota.h>
+#include <lustre_quota.h>
#include "lustre_quota_fmt.h"
typedef char *dqbuf_t;
#include <linux/kernel.h>
#include <linux/random.h>
-#include <linux/lustre_quota.h>
-#include <linux/obd_class.h>
+#include <lustre_quota.h>
+#include <obd_class.h>
#include "lustre_quota_fmt.h"
#define DEBUG_SUBSYSTEM S_LDLM
#ifdef __KERNEL__
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/unistd.h>
-#include <linux/version.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <asm/uaccess.h>
-#include <asm/segment.h>
-#include <linux/mm.h>
-#include <linux/pagemap.h>
-#include <linux/smp_lock.h>
+#include <libcfs/libcfs.h>
#else
#include <liblustre.h>
#endif
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_lib.h>
+#include <lustre_dlm.h>
+#include <lustre_lib.h>
/* invariants:
- only the owner of the lock changes l_owner/l_depth
int owner = 0;
spin_lock(&lock->l_spin);
- if (lock->l_owner == current)
+ if (lock->l_owner == cfs_current())
owner = 1;
spin_unlock(&lock->l_spin);
} else {
down(&lock->l_sem);
spin_lock(&lock->l_spin);
- lock->l_owner = current;
+ lock->l_owner = cfs_current();
lock->l_depth = 0;
spin_unlock(&lock->l_spin);
}
void l_unlock(struct lustre_lock *lock)
{
- LASSERTF(lock->l_owner == current, "lock %p, current %p\n",
- lock->l_owner, current);
+ LASSERTF(lock->l_owner == cfs_current(), "lock %p, current %p\n",
+ lock->l_owner, cfs_current());
LASSERTF(lock->l_depth >= 0, "depth %d\n", lock->l_depth);
spin_lock(&lock->l_spin);
int depth = -1, owner = 0;
spin_lock(&lock->l_spin);
- if (lock->l_owner == current) {
+ if (lock->l_owner == cfs_current()) {
depth = lock->l_depth;
owner = 1;
}
void l_check_no_ns_lock(struct ldlm_namespace *ns)
{
- static unsigned long next_msg;
+ static cfs_time_t next_msg;
- if (l_has_lock(&ns->ns_lock) && time_after(jiffies, next_msg)) {
+ if (l_has_lock(&ns->ns_lock) && cfs_time_after(cfs_time_current(), next_msg)) {
CERROR("namespace %s lock held illegally; tell phil\n",
ns->ns_name);
libcfs_debug_dumpstack(NULL);
- next_msg = jiffies + 60 * HZ;
+ next_msg = cfs_time_shift(60);
}
}
# include <liblustre.h>
#endif
-#include <linux/lustre_dlm.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
+#include <lustre_dlm.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
#include "ldlm_internal.h"
ldlm_error_t *err)
{
struct ldlm_resource *res = lock->l_resource;
- struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
+ struct list_head rpc_list = CFS_LIST_HEAD_INIT(rpc_list);
int rc, rc2;
ENTRY;
#define DEBUG_SUBSYSTEM S_LDLM
#ifdef __KERNEL__
-#include <linux/lustre_dlm.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_lib.h>
+#include <lustre_dlm.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_lib.h>
#include <libcfs/list.h>
#else
#include <liblustre.h>
-#include <linux/obd_class.h>
+#include <obd_class.h>
#endif
#include "ldlm_internal.h"
#define l_flock_waitq l_lru
-static struct list_head ldlm_flock_waitq = LIST_HEAD_INIT(ldlm_flock_waitq);
+static struct list_head ldlm_flock_waitq = CFS_LIST_HEAD_INIT(ldlm_flock_waitq);
int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
void *data, int flag);
* ldlm_reprocess_queue. */
if ((mode == LCK_NL) && overlaps) {
struct list_head rpc_list
- = LIST_HEAD_INIT(rpc_list);
+ = CFS_LIST_HEAD_INIT(rpc_list);
int rc;
restart:
res->lr_tmp = &rpc_list;
ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data)
{
struct ldlm_namespace *ns;
- struct file_lock *getlk = lock->l_ast_data;
+ cfs_flock_t *getlk = lock->l_ast_data;
struct ldlm_flock_wait_data fwd;
unsigned long irqflags;
struct obd_device *obd;
/* fcntl(F_GETLK) request */
/* The old mode was saved in getlk->fl_type so that if the mode
* in the lock changes we can decref the approprate refcount. */
- ldlm_flock_destroy(lock, getlk->fl_type, LDLM_FL_WAIT_NOREPROC);
+ ldlm_flock_destroy(lock, cfs_flock_type(getlk), LDLM_FL_WAIT_NOREPROC);
switch (lock->l_granted_mode) {
case LCK_PR:
- getlk->fl_type = F_RDLCK;
+ cfs_flock_set_type(getlk, F_RDLCK);
break;
case LCK_PW:
- getlk->fl_type = F_WRLCK;
+ cfs_flock_set_type(getlk, F_WRLCK);
break;
default:
- getlk->fl_type = F_UNLCK;
+ cfs_flock_set_type(getlk, F_UNLCK);
}
- getlk->fl_pid = lock->l_policy_data.l_flock.pid;
- getlk->fl_start = lock->l_policy_data.l_flock.start;
- getlk->fl_end = lock->l_policy_data.l_flock.end;
+ cfs_flock_set_pid(getlk, (pid_t)lock->l_policy_data.l_flock.pid);
+ cfs_flock_set_start(getlk, (off_t)lock->l_policy_data.l_flock.start);
+ cfs_flock_set_end(getlk, (off_t)lock->l_policy_data.l_flock.end);
} else {
int noreproc = LDLM_FL_WAIT_NOREPROC;
* with existing locks owned by this process. */
ldlm_process_flock_lock(lock, &noreproc, 1, &err);
if (flags == 0)
- wake_up(&lock->l_waitq);
+ cfs_waitq_signal(&lock->l_waitq);
}
l_unlock(&ns->ns_lock);
RETURN(0);
# include <liblustre.h>
#endif
-#include <linux/lustre_dlm.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
+#include <lustre_dlm.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
#include "ldlm_internal.h"
int first_enq, ldlm_error_t *err)
{
struct ldlm_resource *res = lock->l_resource;
- struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
+ struct list_head rpc_list = CFS_LIST_HEAD_INIT(rpc_list);
int rc;
ENTRY;
void l_check_ns_lock(struct ldlm_namespace *ns);
void l_check_no_ns_lock(struct ldlm_namespace *ns);
-extern struct proc_dir_entry *ldlm_svc_proc_dir;
+extern cfs_proc_dir_entry_t *ldlm_svc_proc_dir;
struct ldlm_state {
struct ptlrpc_service *ldlm_cb_service;
#define DEBUG_SUBSYSTEM S_LDLM
#ifdef __KERNEL__
-# include <linux/module.h>
+# include <libcfs/libcfs.h>
#else
# include <liblustre.h>
#endif
-#include <linux/obd.h>
-#include <linux/obd_ost.h> /* for LUSTRE_OSC_NAME */
-#include <linux/lustre_mds.h> /* for LUSTRE_MDC_NAME */
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_net.h>
+#include <obd.h>
+#include <obd_ost.h> /* for LUSTRE_OSC_NAME */
+#include <lustre_mds.h> /* for LUSTRE_MDC_NAME */
+#include <lustre_dlm.h>
+#include <lustre_net.h>
/* @priority: if non-zero, move the selected to the list head
* @create: if zero, only search in existed connections
cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024;
if (cli->cl_dirty_max >> PAGE_SHIFT > num_physpages / 8)
cli->cl_dirty_max = num_physpages << (PAGE_SHIFT - 3);
- INIT_LIST_HEAD(&cli->cl_cache_waiters);
- INIT_LIST_HEAD(&cli->cl_loi_ready_list);
- INIT_LIST_HEAD(&cli->cl_loi_write_list);
- INIT_LIST_HEAD(&cli->cl_loi_read_list);
- spin_lock_init(&cli->cl_loi_list_lock);
+ CFS_INIT_LIST_HEAD(&cli->cl_cache_waiters);
+ CFS_INIT_LIST_HEAD(&cli->cl_loi_ready_list);
+ CFS_INIT_LIST_HEAD(&cli->cl_loi_write_list);
+ CFS_INIT_LIST_HEAD(&cli->cl_loi_read_list);
+ client_obd_list_lock_init(&cli->cl_loi_list_lock);
cli->cl_r_in_flight = 0;
cli->cl_w_in_flight = 0;
spin_lock_init(&cli->cl_read_rpc_hist.oh_lock);
imp->imp_connect_op = connect_op;
imp->imp_generation = 0;
imp->imp_initial_recov = 1;
- INIT_LIST_HEAD(&imp->imp_pinger_chain);
+ CFS_INIT_LIST_HEAD(&imp->imp_pinger_chain);
memcpy(imp->imp_target_uuid.uuid, lustre_cfg_buf(lcfg, 1),
LUSTRE_CFG_BUFLEN(lcfg, 1));
class_import_put(imp);
RETURN(-EINVAL);
class_destroy_import(cli->cl_import);
cli->cl_import = NULL;
+ client_obd_list_lock_done(&cli->cl_loi_list_lock);
ldlm_put_ref(obddev->obd_force);
"%d clients in recovery for %lds\n",
target->obd_name, cluuid.uuid,
target->obd_recoverable_clients,
- (target->obd_recovery_timer.expires-jiffies)/HZ);
+ cfs_duration_sec(cfs_time_sub(cfs_timer_deadline(&target->obd_recovery_timer),
+ cfs_time_current())));
rc = -EBUSY;
} else {
dont_check_exports:
spin_lock_bh(&obd->obd_processing_task_lock);
if (obd->obd_recovering)
obd->obd_abort_recovery = 1;
- wake_up(&obd->obd_next_transno_waitq);
+ cfs_waitq_signal(&obd->obd_next_transno_waitq);
spin_unlock_bh(&obd->obd_processing_task_lock);
}
void target_cancel_recovery_timer(struct obd_device *obd)
{
CDEBUG(D_HA, "%s: cancel recovery timer\n", obd->obd_name);
- del_timer(&obd->obd_recovery_timer);
+ cfs_timer_disarm(&obd->obd_recovery_timer);
}
static void reset_recovery_timer(struct obd_device *obd)
spin_unlock_bh(&obd->obd_processing_task_lock);
return;
}
- mod_timer(&obd->obd_recovery_timer, jiffies + OBD_RECOVERY_TIMEOUT);
+ cfs_timer_arm(&obd->obd_recovery_timer,
+ cfs_time_shift(OBD_RECOVERY_TIMEOUT));
spin_unlock_bh(&obd->obd_processing_task_lock);
CDEBUG(D_HA, "%s: timer will expire in %u seconds\n", obd->obd_name,
- (int)(OBD_RECOVERY_TIMEOUT / HZ));
+ OBD_RECOVERY_TIMEOUT);
/* Only used for lprocfs_status */
- obd->obd_recovery_end = CURRENT_SECONDS + OBD_RECOVERY_TIMEOUT/HZ;
+ obd->obd_recovery_end = CURRENT_SECONDS + OBD_RECOVERY_TIMEOUT;
}
return;
}
CWARN("%s: starting recovery timer (%us)\n", obd->obd_name,
- (int)(OBD_RECOVERY_TIMEOUT / HZ));
+ OBD_RECOVERY_TIMEOUT);
obd->obd_recovery_handler = handler;
- obd->obd_recovery_timer.function = target_recovery_expired;
- obd->obd_recovery_timer.data = (unsigned long)obd;
+ cfs_timer_init(&obd->obd_recovery_timer, target_recovery_expired, obd);
spin_unlock_bh(&obd->obd_processing_task_lock);
reset_recovery_timer(obd);
for (;;) {
spin_lock_bh(&obd->obd_processing_task_lock);
- LASSERT(obd->obd_processing_task == current->pid);
+ LASSERT(obd->obd_processing_task == cfs_curproc_pid());
req = list_entry(obd->obd_recovery_queue.next,
struct ptlrpc_request, rq_list);
* buffers (eg mds_body, ost_body etc) have NOT been swabbed. */
if (!transno) {
- INIT_LIST_HEAD(&req->rq_list);
+ CFS_INIT_LIST_HEAD(&req->rq_list);
DEBUG_REQ(D_HA, req, "not queueing");
return 1;
}
* Also, a resent, replayed request that has already been
* handled will pass through here and be processed immediately.
*/
- if (obd->obd_processing_task == current->pid ||
+ if (obd->obd_processing_task == cfs_curproc_pid() ||
transno < obd->obd_next_recovery_transno) {
/* Processing the queue right now, don't re-add. */
LASSERT(list_empty(&req->rq_list));
req = saved_req;
req->rq_reqmsg = reqmsg;
class_export_get(req->rq_export);
- INIT_LIST_HEAD(&req->rq_list);
+ CFS_INIT_LIST_HEAD(&req->rq_list);
/* XXX O(n^2) */
list_for_each(tmp, &obd->obd_recovery_queue) {
/* Someone else is processing this queue, we'll leave it to
* them.
*/
- wake_up(&obd->obd_next_transno_waitq);
+ cfs_waitq_signal(&obd->obd_next_transno_waitq);
spin_unlock_bh(&obd->obd_processing_task_lock);
return 0;
}
/* Nobody is processing, and we know there's (at least) one to process
* now, so we'll do the honours.
*/
- obd->obd_processing_task = current->pid;
+ obd->obd_processing_task = cfs_curproc_pid();
spin_unlock_bh(&obd->obd_processing_task_lock);
process_recovery_queue(obd);
} else {
CWARN("%s: %d recoverable clients remain\n",
obd->obd_name, obd->obd_recoverable_clients);
- wake_up(&obd->obd_next_transno_waitq);
+ cfs_waitq_signal(&obd->obd_next_transno_waitq);
}
return 1;
list_empty(&rs->rs_exp_list) || /* completed already */
list_empty(&rs->rs_obd_list)) {
list_add_tail (&rs->rs_list, &svc->srv_reply_queue);
- wake_up (&svc->srv_waitq);
+ cfs_waitq_signal (&svc->srv_waitq);
} else {
list_add (&rs->rs_list, &svc->srv_active_replies);
rs->rs_scheduled = 0; /* allow notifier to schedule */
#ifdef __KERNEL__
# include <linux/slab.h>
# include <linux/module.h>
-# include <linux/lustre_dlm.h>
+# include <lustre_dlm.h>
#else
# include <liblustre.h>
# include <libcfs/kp30.h>
#endif
-#include <linux/obd_class.h>
+#include <obd_class.h>
#include "ldlm_internal.h"
//struct lustre_lock ldlm_everything_lock;
}
}
-extern kmem_cache_t *ldlm_lock_slab;
+extern cfs_mem_cache_t *ldlm_lock_slab;
struct lustre_lock ldlm_handle_lock;
static ldlm_processing_policy ldlm_processing_policy_table[] = {
if (resource == NULL)
LBUG();
- OBD_SLAB_ALLOC(lock, ldlm_lock_slab, SLAB_NOFS, sizeof(*lock));
+ OBD_SLAB_ALLOC(lock, ldlm_lock_slab, CFS_ALLOC_IO, sizeof(*lock));
if (lock == NULL)
RETURN(NULL);
lock->l_resource = ldlm_resource_getref(resource);
atomic_set(&lock->l_refc, 2);
- INIT_LIST_HEAD(&lock->l_children);
- INIT_LIST_HEAD(&lock->l_childof);
- INIT_LIST_HEAD(&lock->l_res_link);
- INIT_LIST_HEAD(&lock->l_lru);
- INIT_LIST_HEAD(&lock->l_export_chain);
- INIT_LIST_HEAD(&lock->l_pending_chain);
- init_waitqueue_head(&lock->l_waitq);
+ CFS_INIT_LIST_HEAD(&lock->l_children);
+ CFS_INIT_LIST_HEAD(&lock->l_childof);
+ CFS_INIT_LIST_HEAD(&lock->l_res_link);
+ CFS_INIT_LIST_HEAD(&lock->l_lru);
+ CFS_INIT_LIST_HEAD(&lock->l_export_chain);
+ CFS_INIT_LIST_HEAD(&lock->l_pending_chain);
+ cfs_waitq_init(&lock->l_waitq);
spin_lock(&resource->lr_namespace->ns_counter_lock);
resource->lr_namespace->ns_locks++;
l_unlock(&parent->l_resource->lr_namespace->ns_lock);
}
- INIT_LIST_HEAD(&lock->l_handle.h_link);
+ CFS_INIT_LIST_HEAD(&lock->l_handle.h_link);
class_handle_hash(&lock->l_handle, lock_handle_addref);
RETURN(lock);
lock->l_readers++;
if (mode & (LCK_EX | LCK_CW | LCK_PW | LCK_GROUP))
lock->l_writers++;
- lock->l_last_used = jiffies;
+ lock->l_last_used = cfs_time_current();
LDLM_LOCK_GET(lock);
LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]);
l_unlock(&lock->l_resource->lr_namespace->ns_lock);
{
l_lock(&lock->l_resource->lr_namespace->ns_lock);
lock->l_flags |= LDLM_FL_CAN_MATCH;
- wake_up(&lock->l_waitq);
+ cfs_waitq_signal(&lock->l_waitq);
l_unlock(&lock->l_resource->lr_namespace->ns_lock);
}
}
}
- lwi = LWI_TIMEOUT_INTR(obd_timeout*HZ, NULL,NULL,NULL);
+ lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(obd_timeout), NULL,NULL,NULL);
/* XXX FIXME see comment on CAN_MATCH in lustre_dlm.h */
l_wait_event(lock->l_waitq,
lock->l_blocking_ast = blocking;
lock->l_completion_ast = completion;
lock->l_glimpse_ast = glimpse;
- lock->l_pid = current->pid;
+ lock->l_pid = cfs_curproc_pid();
if (lvb_len) {
lock->l_lvb_len = lvb_len;
#define DEBUG_SUBSYSTEM S_LDLM
#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/slab.h>
-# include <linux/init.h>
-# include <linux/wait.h>
+# include <libcfs/libcfs.h>
#else
# include <liblustre.h>
#endif
-#include <linux/lustre_dlm.h>
-#include <linux/obd_class.h>
+#include <lustre_dlm.h>
+#include <obd_class.h>
#include <libcfs/list.h>
#include "ldlm_internal.h"
-extern kmem_cache_t *ldlm_resource_slab;
-extern kmem_cache_t *ldlm_lock_slab;
+extern cfs_mem_cache_t *ldlm_resource_slab;
+extern cfs_mem_cache_t *ldlm_lock_slab;
extern struct lustre_lock ldlm_handle_lock;
extern struct list_head ldlm_namespace_list;
-static DECLARE_MUTEX(ldlm_ref_sem);
+extern struct semaphore ldlm_namespace_lock;
+static struct semaphore ldlm_ref_sem;
static int ldlm_refcount;
/* LDLM state */
static struct ldlm_state *ldlm_state;
-inline unsigned long round_timeout(unsigned long timeout)
+inline cfs_time_t round_timeout(cfs_time_t timeout)
{
- return ((timeout / HZ) + 1) * HZ;
+ return cfs_time_seconds((int)cfs_duration_sec(cfs_time_sub(timeout, 0)) + 1);
}
#ifdef __KERNEL__
/* w_l_spinlock protects both waiting_locks_list and expired_lock_thread */
static spinlock_t waiting_locks_spinlock;
static struct list_head waiting_locks_list;
-static struct timer_list waiting_locks_timer;
+static cfs_timer_t waiting_locks_timer;
static struct expired_lock_thread {
- wait_queue_head_t elt_waitq;
+ cfs_waitq_t elt_waitq;
int elt_state;
int elt_dump;
struct list_head elt_expired_locks;
struct ldlm_bl_pool {
spinlock_t blp_lock;
struct list_head blp_list;
- wait_queue_head_t blp_waitq;
+ cfs_waitq_t blp_waitq;
atomic_t blp_num_threads;
struct completion blp_comp;
};
{
struct list_head *expired = &expired_lock_thread.elt_expired_locks;
struct l_wait_info lwi = { 0 };
- unsigned long flags;
ENTRY;
lock_kernel();
- libcfs_daemonize("ldlm_elt");
-
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_daemonize("ldlm_elt");
+ cfs_block_allsigs();
unlock_kernel();
expired_lock_thread.elt_state = ELT_READY;
- wake_up(&expired_lock_thread.elt_waitq);
+ cfs_waitq_signal(&expired_lock_thread.elt_waitq);
while (1) {
l_wait_event(expired_lock_thread.elt_waitq,
}
expired_lock_thread.elt_state = ELT_STOPPED;
- wake_up(&expired_lock_thread.elt_waitq);
+ cfs_waitq_signal(&expired_lock_thread.elt_waitq);
RETURN(0);
}
lock = list_entry(waiting_locks_list.next, struct ldlm_lock,
l_pending_chain);
- if (time_after(lock->l_callback_timeout, jiffies) ||
+ if (cfs_time_after(lock->l_callback_timeout, cfs_time_current()) ||
(lock->l_req_mode == LCK_GROUP))
break;
lock->l_pending_chain.next,
lock->l_pending_chain.prev);
- INIT_LIST_HEAD(&waiting_locks_list); /* HACK */
+ CFS_INIT_LIST_HEAD(&waiting_locks_list); /* HACK */
expired_lock_thread.elt_dump = __LINE__;
spin_unlock_bh(&waiting_locks_spinlock);
list_add(&lock->l_pending_chain,
&expired_lock_thread.elt_expired_locks);
- wake_up(&expired_lock_thread.elt_waitq);
+ cfs_waitq_signal(&expired_lock_thread.elt_waitq);
}
/*
* left.
*/
if (!list_empty(&waiting_locks_list)) {
- unsigned long timeout_rounded;
+ cfs_time_t timeout_rounded;
lock = list_entry(waiting_locks_list.next, struct ldlm_lock,
l_pending_chain);
- timeout_rounded = round_timeout(lock->l_callback_timeout);
- mod_timer(&waiting_locks_timer, timeout_rounded);
+ timeout_rounded = (cfs_time_t)round_timeout(lock->l_callback_timeout);
+ cfs_timer_arm(&waiting_locks_timer, timeout_rounded);
}
spin_unlock_bh(&waiting_locks_spinlock);
}
*/
static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
{
- unsigned long timeout_rounded;
+ cfs_time_t timeout_rounded;
l_check_ns_lock(lock->l_resource->lr_namespace);
spin_lock_bh(&waiting_locks_spinlock);
if (lock->l_destroyed) {
- static unsigned long next;
+ static cfs_time_t next;
spin_unlock_bh(&waiting_locks_spinlock);
LDLM_ERROR(lock, "not waiting on destroyed lock (bug 5653)");
- if (time_after(jiffies, next)) {
- next = jiffies + 14400 * HZ;
+ if (cfs_time_after(cfs_time_current(), next)) {
+ next = cfs_time_shift(14400);
libcfs_debug_dumpstack(NULL);
}
return 0;
return 0;
}
- lock->l_callback_timeout = jiffies + (obd_timeout * HZ / 2);
+ lock->l_callback_timeout = cfs_time_shift(obd_timeout / 2);
timeout_rounded = round_timeout(lock->l_callback_timeout);
- if (time_before(timeout_rounded, waiting_locks_timer.expires) ||
- !timer_pending(&waiting_locks_timer)) {
- mod_timer(&waiting_locks_timer, timeout_rounded);
+ if (cfs_time_before(timeout_rounded, cfs_timer_deadline(&waiting_locks_timer)) ||
+ !cfs_timer_is_armed(&waiting_locks_timer)) {
+ cfs_timer_arm(&waiting_locks_timer, timeout_rounded);
}
list_add_tail(&lock->l_pending_chain, &waiting_locks_list); /* FIFO */
spin_unlock_bh(&waiting_locks_spinlock);
/* Removing the head of the list, adjust timer. */
if (list_next == &waiting_locks_list) {
/* No more, just cancel. */
- del_timer(&waiting_locks_timer);
+ cfs_timer_disarm(&waiting_locks_timer);
} else {
struct ldlm_lock *next;
next = list_entry(list_next, struct ldlm_lock,
l_pending_chain);
- mod_timer(&waiting_locks_timer,
- round_timeout(next->l_callback_timeout));
+ cfs_timer_arm(&waiting_locks_timer,
+ round_timeout(next->l_callback_timeout));
}
}
list_del_init(&lock->l_pending_chain);
RETURN(rc);
}
-/* XXX copied from ptlrpc/service.c */
-static long timeval_sub(struct timeval *large, struct timeval *small)
-{
- return (large->tv_sec - small->tv_sec) * 1000000 +
- (large->tv_usec - small->tv_usec);
-}
-
int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data)
{
struct ldlm_request *body;
LASSERT(lock != NULL);
do_gettimeofday(&granted_time);
- total_enqueue_wait = timeval_sub(&granted_time,&lock->l_enqueued_time);
+ total_enqueue_wait = cfs_timeval_sub(&granted_time,&lock->l_enqueued_time, NULL);
if (total_enqueue_wait / 1000000 > obd_timeout)
LDLM_ERROR(lock, "enqueue wait took %luus from %lu",
struct ldlm_request *dlm_req,
struct ldlm_lock *lock)
{
- LIST_HEAD(ast_list);
+ CFS_LIST_HEAD(ast_list);
ENTRY;
l_lock(&ns->ns_lock);
l_unlock(&ns->ns_lock);
if (lock->l_granted_mode == LCK_PW &&
!lock->l_readers && !lock->l_writers &&
- time_after(jiffies, lock->l_last_used + 10 * HZ)) {
+ cfs_time_after(cfs_time_current(),
+ cfs_time_add(lock->l_last_used, cfs_time_seconds(10)))) {
if (ldlm_bl_to_thread(ns, NULL, lock))
ldlm_handle_bl_callback(ns, NULL, lock);
EXIT;
spin_lock(&blp->blp_lock);
list_add_tail(&blwi->blwi_entry, &blp->blp_list);
- wake_up(&blp->blp_waitq);
+ cfs_waitq_signal(&blp->blp_waitq);
spin_unlock(&blp->blp_lock);
RETURN(0);
{
struct ldlm_bl_thread_data *bltd = arg;
struct ldlm_bl_pool *blp = bltd->bltd_blp;
- unsigned long flags;
ENTRY;
/* XXX boiler-plate */
char name[sizeof(current->comm)];
snprintf(name, sizeof(name) - 1, "ldlm_bl_%02d",
bltd->bltd_num);
- libcfs_daemonize(name);
+ cfs_daemonize(name);
}
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_block_allsigs();
atomic_inc(&blp->blp_num_threads);
complete(&blp->blp_comp);
ldlm_state->ldlm_bl_pool = blp;
atomic_set(&blp->blp_num_threads, 0);
- init_waitqueue_head(&blp->blp_waitq);
+ cfs_waitq_init(&blp->blp_waitq);
spin_lock_init(&blp->blp_lock);
- INIT_LIST_HEAD(&blp->blp_list);
+ CFS_INIT_LIST_HEAD(&blp->blp_list);
#ifdef __KERNEL__
for (i = 0; i < LDLM_NUM_THREADS; i++) {
.bltd_blp = blp,
};
init_completion(&blp->blp_comp);
- rc = kernel_thread(ldlm_bl_thread_main, &bltd, 0);
+ rc = cfs_kernel_thread(ldlm_bl_thread_main, &bltd, 0);
if (rc < 0) {
CERROR("cannot start LDLM thread #%d: rc %d\n", i, rc);
GOTO(out_thread, rc);
if (rc)
GOTO(out_thread, rc);
- INIT_LIST_HEAD(&expired_lock_thread.elt_expired_locks);
+ CFS_INIT_LIST_HEAD(&expired_lock_thread.elt_expired_locks);
expired_lock_thread.elt_state = ELT_STOPPED;
- init_waitqueue_head(&expired_lock_thread.elt_waitq);
+ cfs_waitq_init(&expired_lock_thread.elt_waitq);
- INIT_LIST_HEAD(&waiting_locks_list);
+ CFS_INIT_LIST_HEAD(&waiting_locks_list);
spin_lock_init(&waiting_locks_spinlock);
- waiting_locks_timer.function = waiting_locks_callback;
- waiting_locks_timer.data = 0;
- init_timer(&waiting_locks_timer);
+ cfs_timer_init(&waiting_locks_timer, waiting_locks_callback, 0);
- rc = kernel_thread(expired_lock_main, NULL, CLONE_VM | CLONE_FS);
+ rc = cfs_kernel_thread(expired_lock_main, NULL, CLONE_VM | CLONE_FS);
if (rc < 0) {
CERROR("Cannot start ldlm expired-lock thread: %d\n", rc);
GOTO(out_thread, rc);
spin_lock(&blp->blp_lock);
list_add_tail(&blwi.blwi_entry, &blp->blp_list);
- wake_up(&blp->blp_waitq);
+ cfs_waitq_signal(&blp->blp_waitq);
spin_unlock(&blp->blp_lock);
wait_for_completion(&blp->blp_comp);
ldlm_proc_cleanup();
expired_lock_thread.elt_state = ELT_TERMINATE;
- wake_up(&expired_lock_thread.elt_waitq);
+ cfs_waitq_signal(&expired_lock_thread.elt_waitq);
wait_event(expired_lock_thread.elt_waitq,
expired_lock_thread.elt_state == ELT_STOPPED);
#else
int __init ldlm_init(void)
{
- ldlm_resource_slab = kmem_cache_create("ldlm_resources",
+ init_mutex(&ldlm_ref_sem);
+ init_mutex(&ldlm_namespace_lock);
+ ldlm_resource_slab = cfs_mem_cache_create("ldlm_resources",
sizeof(struct ldlm_resource), 0,
- SLAB_HWCACHE_ALIGN, NULL, NULL);
+ SLAB_HWCACHE_ALIGN);
if (ldlm_resource_slab == NULL)
return -ENOMEM;
- ldlm_lock_slab = kmem_cache_create("ldlm_locks",
+ ldlm_lock_slab = cfs_mem_cache_create("ldlm_locks",
sizeof(struct ldlm_lock), 0,
- SLAB_HWCACHE_ALIGN, NULL, NULL);
+ SLAB_HWCACHE_ALIGN);
if (ldlm_lock_slab == NULL) {
- kmem_cache_destroy(ldlm_resource_slab);
+ cfs_mem_cache_destroy(ldlm_resource_slab);
return -ENOMEM;
}
{
if ( ldlm_refcount )
CERROR("ldlm_refcount is %d in ldlm_exit!\n", ldlm_refcount);
- LASSERTF(kmem_cache_destroy(ldlm_resource_slab) == 0,
+ LASSERTF(cfs_mem_cache_destroy(ldlm_resource_slab) == 0,
"couldn't free ldlm resource slab\n");
- LASSERTF(kmem_cache_destroy(ldlm_lock_slab) == 0,
+ LASSERTF(cfs_mem_cache_destroy(ldlm_lock_slab) == 0,
"couldn't free ldlm lock slab\n");
}
#define DEBUG_SUBSYSTEM S_LDLM
#ifdef __KERNEL__
-#include <linux/lustre_dlm.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
+#include <lustre_dlm.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
#else
#include <liblustre.h>
#endif
ldlm_error_t *err)
{
struct ldlm_resource *res = lock->l_resource;
- struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
+ struct list_head rpc_list = CFS_LIST_HEAD_INIT(rpc_list);
int rc;
ENTRY;
#include <liblustre.h>
#endif
-#include <linux/lustre_dlm.h>
-#include <linux/obd_class.h>
-#include <linux/obd.h>
+#include <lustre_dlm.h>
+#include <obd_class.h>
+#include <obd.h>
#include "ldlm_internal.h"
struct obd_device *obd;
if (lock->l_conn_export == NULL) {
- static unsigned long next_dump = 0, last_dump = 0;
+ static cfs_time_t next_dump = 0, last_dump = 0;
LDLM_ERROR(lock, "lock timed out (enq %lus ago); not entering "
"recovery in server code, just going back to sleep",
lock->l_enqueued_time.tv_sec);
- if (time_after(jiffies, next_dump)) {
+ if (cfs_time_after(cfs_time_current(), next_dump)) {
last_dump = next_dump;
- next_dump = jiffies + 300 * HZ;
+ next_dump = cfs_time_shift(300);
ldlm_namespace_dump(D_DLMTRACE,
lock->l_resource->lr_namespace);
if (last_dump == 0)
if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
LDLM_FL_BLOCK_CONV))) {
- wake_up(&lock->l_waitq);
+ cfs_waitq_signal(&lock->l_waitq);
RETURN(0);
}
" met\n");
lwi = LWI_INTR(interrupted_completion_wait, &lwd);
} else {
- lwi = LWI_TIMEOUT_INTR(obd_timeout * HZ,
+ lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(obd_timeout),
ldlm_expired_completion_wait,
interrupted_completion_wait, &lwd);
}
{
struct ldlm_lock *lock, *next;
int count, rc = 0;
- LIST_HEAD(cblist);
+ CFS_LIST_HEAD(cblist);
ENTRY;
#ifndef __KERNEL__
void *opaque)
{
struct ldlm_resource *res;
- struct list_head *tmp, *next, list = LIST_HEAD_INIT(list);
+ struct list_head *tmp, *next, list = CFS_LIST_HEAD_INIT(list);
struct ldlm_ast_work *w;
ENTRY;
int rc = 0;
ENTRY;
- INIT_LIST_HEAD(&list);
+ CFS_INIT_LIST_HEAD(&list);
LASSERT(atomic_read(&imp->imp_replay_inflight) == 0);
#define DEBUG_SUBSYSTEM S_LDLM
#ifdef __KERNEL__
-# include <linux/lustre_dlm.h>
+# include <lustre_dlm.h>
#else
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
+#include <obd_class.h>
#include "ldlm_internal.h"
-kmem_cache_t *ldlm_resource_slab, *ldlm_lock_slab;
+cfs_mem_cache_t *ldlm_resource_slab, *ldlm_lock_slab;
DECLARE_MUTEX(ldlm_namespace_lock);
-struct list_head ldlm_namespace_list = LIST_HEAD_INIT(ldlm_namespace_list);
-struct proc_dir_entry *ldlm_type_proc_dir = NULL;
-struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
-struct proc_dir_entry *ldlm_svc_proc_dir = NULL;
+struct list_head ldlm_namespace_list = CFS_LIST_HEAD_INIT(ldlm_namespace_list);
+cfs_proc_dir_entry_t *ldlm_type_proc_dir = NULL;
+cfs_proc_dir_entry_t *ldlm_ns_proc_dir = NULL;
+cfs_proc_dir_entry_t *ldlm_svc_proc_dir = NULL;
#ifdef LPROCFS
static int ldlm_proc_dump_ns(struct file *file, const char *buffer,
strcpy(ns->ns_name, name);
- INIT_LIST_HEAD(&ns->ns_root_list);
+ CFS_INIT_LIST_HEAD(&ns->ns_root_list);
l_lock_init(&ns->ns_lock);
- init_waitqueue_head(&ns->ns_refcount_waitq);
+ cfs_waitq_init(&ns->ns_refcount_waitq);
atomic_set(&ns->ns_refcount, 0);
ns->ns_client = client;
spin_lock_init(&ns->ns_counter_lock);
for (bucket = ns->ns_hash + RES_HASH_SIZE - 1; bucket >= ns->ns_hash;
bucket--)
- INIT_LIST_HEAD(bucket);
+ CFS_INIT_LIST_HEAD(bucket);
- INIT_LIST_HEAD(&ns->ns_unused_list);
+ CFS_INIT_LIST_HEAD(&ns->ns_unused_list);
ns->ns_nr_unused = 0;
ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
{
struct ldlm_resource *res;
- OBD_SLAB_ALLOC(res, ldlm_resource_slab, SLAB_NOFS, sizeof *res);
+ OBD_SLAB_ALLOC(res, ldlm_resource_slab, CFS_ALLOC_IO, sizeof *res);
if (res == NULL)
return NULL;
memset(res, 0, sizeof(*res));
- INIT_LIST_HEAD(&res->lr_children);
- INIT_LIST_HEAD(&res->lr_childof);
- INIT_LIST_HEAD(&res->lr_granted);
- INIT_LIST_HEAD(&res->lr_converting);
- INIT_LIST_HEAD(&res->lr_waiting);
+ CFS_INIT_LIST_HEAD(&res->lr_children);
+ CFS_INIT_LIST_HEAD(&res->lr_childof);
+ CFS_INIT_LIST_HEAD(&res->lr_granted);
+ CFS_INIT_LIST_HEAD(&res->lr_converting);
+ CFS_INIT_LIST_HEAD(&res->lr_waiting);
sema_init(&res->lr_lvb_sem, 1);
atomic_set(&res->lr_refcount, 1);
if (atomic_dec_and_test(&ns->ns_refcount)) {
CDEBUG(D_DLMTRACE, "last ref on ns %s\n", ns->ns_name);
- wake_up(&ns->ns_refcount_waitq);
+ cfs_waitq_signal(&ns->ns_refcount_waitq);
}
rc = 1;
atomic_read(&ns->ns_refcount), ns->ns_client);
l_lock(&ns->ns_lock);
- if (time_after(jiffies, ns->ns_next_dump)) {
+ if (cfs_time_after(cfs_time_current(), ns->ns_next_dump)) {
list_for_each(tmp, &ns->ns_root_list) {
struct ldlm_resource *res;
res = list_entry(tmp, struct ldlm_resource, lr_childof);
* really dump them recursively. */
ldlm_resource_dump(level, res);
}
- ns->ns_next_dump = jiffies + 10 * HZ;
+ ns->ns_next_dump = cfs_time_shift(10);
}
l_unlock(&ns->ns_lock);
}
#define __LLU_H_
#include <liblustre.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
+#include <lustre_lite.h>
#include <sys/types.h>
#include <sys/stat.h>
#define __LUTIL_H_
#include <liblustre.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
+#include <obd.h>
+#include <obd_class.h>
void liblustre_init_random(void);
int liblustre_init_current(char *comm);
*/
#include <liblustre.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
-#include <linux/obd_ost.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <obd_ost.h>
#define LIBLUSTRE_TEST 1
#include "../utils/lctl.c"
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/obd_support.h>
-#include <linux/lustre_lite.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_dlm.h>
+#include <obd_support.h>
+#include <lustre_lite.h>
+#include <lustre_idl.h>
+#include <lustre_dlm.h>
#include <linux/lustre_version.h>
#include "llite_internal.h"
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
-#include <linux/lustre_dlm.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
+#include <lustre_mds.h>
+#include <lustre_lite.h>
+#include <lustre_dlm.h>
#include "llite_internal.h"
typedef struct ext2_dir_entry_2 ext2_dirent;
*/
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_lite.h>
+#include <lustre_dlm.h>
+#include <lustre_lite.h>
#include <linux/pagemap.h>
#include <linux/file.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
+#include <lustre_mds.h>
+#include <lustre_lite.h>
#include "llite_internal.h"
/* record that a write is in flight */
#ifndef LLITE_INTERNAL_H
#define LLITE_INTERNAL_H
-#include <linux/lustre_debug.h>
+#include <lustre_debug.h>
#include <linux/lustre_version.h>
/*
#include <linux/random.h>
#include <linux/version.h>
-#include <linux/lustre_lite.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lprocfs_status.h>
+#include <lustre_lite.h>
+#include <lustre_ha.h>
+#include <lustre_dlm.h>
+#include <lprocfs_status.h>
#include "llite_internal.h"
kmem_cache_t *ll_file_data_slab;
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
+#include <lustre_mds.h>
+#include <lustre_lite.h>
#include "llite_internal.h"
#include <linux/lustre_compat25.h>
*/
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_lite.h>
+#include <lustre_lite.h>
#include "llite_internal.h"
__u32 get_uuid2int(const char *name, int len)
#define DEBUG_SUBSYSTEM S_LLITE
#include <linux/version.h>
-#include <linux/lustre_lite.h>
-#include <linux/lprocfs_status.h>
+#include <lustre_lite.h>
+#include <lprocfs_status.h>
#include <linux/seq_file.h>
-#include <linux/obd_support.h>
+#include <obd_support.h>
#include "llite_internal.h"
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/obd_support.h>
-#include <linux/lustre_lite.h>
-#include <linux/lustre_dlm.h>
+#include <obd_support.h>
+#include <lustre_lite.h>
+#include <lustre_dlm.h>
#include <linux/lustre_version.h>
#include "llite_internal.h"
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
+#include <lustre_mds.h>
+#include <lustre_lite.h>
#include "llite_internal.h"
#include <linux/lustre_compat25.h>
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
+#include <lustre_mds.h>
+#include <lustre_lite.h>
#include "llite_internal.h"
#include <linux/lustre_compat25.h>
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_mds.h>
-#include <linux/lustre_lite.h>
+#include <lustre_mds.h>
+#include <lustre_lite.h>
#include "llite_internal.h"
#include <linux/lustre_compat25.h>
*/
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_lite.h>
+#include <lustre_dlm.h>
+#include <lustre_lite.h>
#include <linux/pagemap.h>
#include <linux/file.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#include <linux/types.h>
#include <linux/random.h>
#include <linux/version.h>
-#include <linux/lustre_lite.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_dlm.h>
+#include <lustre_lite.h>
+#include <lustre_ha.h>
+#include <lustre_dlm.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/cache_def.h>
-#include <linux/lprocfs_status.h>
+#include <lprocfs_status.h>
#include "llite_internal.h"
#include <lustre/lustre_user.h>
#include <linux/types.h>
#include <linux/random.h>
#include <linux/version.h>
-#include <linux/lustre_lite.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_dlm.h>
+#include <lustre_lite.h>
+#include <lustre_ha.h>
+#include <lustre_dlm.h>
#include <linux/init.h>
#include <linux/fs.h>
-#include <linux/lprocfs_status.h>
+#include <lprocfs_status.h>
#include "llite_internal.h"
struct super_block * ll_get_sb(struct file_system_type *fs_type,
#include <linux/version.h>
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/lustre_lite.h>
+#include <lustre_lite.h>
#include "llite_internal.h"
static int ll_readlink_internal(struct inode *inode,
#define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/obd_support.h>
-#include <linux/lustre_lite.h>
-#include <linux/lustre_dlm.h>
+#include <obd_support.h>
+#include <lustre_lite.h>
+#include <lustre_dlm.h>
#include <linux/lustre_version.h>
-#include <linux/lustre_mds.h>
+#include <lustre_mds.h>
#include "llite_internal.h"
#include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_mds.h>
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
-#include <linux/obd_ost.h>
-#include <linux/lprocfs_status.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
+#include <lustre_net.h>
+#include <lustre_idl.h>
+#include <lustre_dlm.h>
+#include <lustre_mds.h>
+#include <obd_class.h>
+#include <obd_lov.h>
+#include <obd_ost.h>
+#include <lprocfs_status.h>
#include "lov_internal.h"
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
+#include <obd_class.h>
+#include <obd_lov.h>
#include "lov_internal.h"
#include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_debug.h>
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
-#include <linux/obd_ost.h>
-#include <linux/lprocfs_status.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
+#include <lustre_net.h>
+#include <lustre_idl.h>
+#include <lustre_dlm.h>
+#include <lustre_mds.h>
+#include <lustre_debug.h>
+#include <obd_class.h>
+#include <obd_lov.h>
+#include <obd_ost.h>
+#include <lprocfs_status.h>
#include "lov_internal.h"
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
+#include <obd_class.h>
+#include <obd_lov.h>
#include "lov_internal.h"
#include <liblustre.h>
#endif
-#include <linux/lustre_net.h>
-#include <linux/obd.h>
-#include <linux/obd_lov.h>
-#include <linux/obd_class.h>
-#include <linux/obd_support.h>
+#include <lustre_net.h>
+#include <obd.h>
+#include <obd_lov.h>
+#include <obd_class.h>
+#include <obd_support.h>
#include <lustre/lustre_user.h>
#include "lov_internal.h"
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
+#include <obd_class.h>
+#include <obd_lov.h>
#include "lov_internal.h"
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
-#include <linux/lustre_idl.h>
+#include <obd_class.h>
+#include <obd_lov.h>
+#include <lustre_idl.h>
#include "lov_internal.h"
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
#include <asm/statfs.h>
#endif
-#include <linux/lprocfs_status.h>
-#include <linux/obd_class.h>
+#include <lprocfs_status.h>
+#include <obd_class.h>
#include <linux/seq_file.h>
#ifdef LPROCFS
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>lvfs</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.clusterfs.lustre.lvfs</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>KEXT</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0.1</string>
+ <key>OSBundleCompatibleVersion</key>
+ <string>1.0.0</string>
+ <key>OSBundleLibraries</key>
+ <dict>
+ <key>com.apple.kernel.bsd</key>
+ <string>1.1</string>
+ <key>com.apple.kernel.iokit</key>
+ <string>1.0.0b1</string>
+ <key>com.apple.kernel.mach</key>
+ <string>1.0.0b1</string>
+ <key>com.clusterfs.lustre.libcfs</key>
+ <string>1.0.0</string>
+ <key>com.clusterfs.lustre.lnet</key>
+ <string>1.0.0</string>
+ </dict>
+</dict>
+</plist>
if MODULES
+if LINUX
+
modulefs_DATA := lvfs$(KMODEXT)
if SERVER
fsfilt_ldiskfs_quota.h: fsfilt_ext3_quota.h
sed $(strip $(ldiskfs_sed_flags)) $< > $@
+endif # LINUX
-else
+if DARWIN
+
+macos_PROGRAMS := lvfs
+
+lvfs_SOURCES := lvfs_darwin.c
+
+lvfs_CFLAGS := $(EXTRA_KCFLAGS)
+lvfs_LDFLAGS := $(EXTRA_KLDFLAGS)
+lvfs_LDADD := $(EXTRA_KLIBS)
+
+plist_DATA := Info.plist
+
+#install-data-hook: fix-kext-ownership
+
+endif # DARWIN
+
+else # MODULES
sources:
#include <linux/kmod.h>
#include <linux/slab.h>
#include <libcfs/kp30.h>
-#include <linux/lustre_fsfilt.h>
+#include <lustre_fsfilt.h>
LIST_HEAD(fsfilt_types);
#endif
#include <libcfs/kp30.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_quota.h>
+#include <lustre_fsfilt.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <lustre_quota.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#include <linux/iobuf.h>
#endif
#include <asm/statfs.h>
#endif
#include <libcfs/kp30.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
+#include <lustre_fsfilt.h>
+#include <obd.h>
+#include <obd_class.h>
#include <linux/module.h>
#include <linux/init.h>
#define DEBUG_SUBSYSTEM S_FILTER
-#include <linux/lvfs.h>
+#include <lvfs.h>
struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *ctxt, __u64 id,
__u32 gen, __u64 gr, void *data)
--- /dev/null
+#define DEBUG_SUBSYSTEM S_FILTER
+
+#include <libcfs/libcfs.h>
+#include <obd.h>
+#include <lvfs.h>
+#include <lustre_lib.h>
+
+atomic_t obd_memory;
+int obd_memmax;
+
+/* XXX currently ctxt functions should not be used ?? */
+void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
+ struct lvfs_ucred *cred)
+{
+ LBUG();
+}
+
+void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
+ struct lvfs_ucred *cred)
+{
+ LBUG();
+}
+
+int lvfs_arch_init(void)
+{
+ return 0;
+}
+
+void lvfs_arch_exit(void)
+{
+ return;
+}
+
+
+static int __init lvfs_init(void)
+{
+ int ret = 0;
+ ENTRY;
+
+ ret = lvfs_arch_init();
+
+ RETURN(ret);
+}
+
+static void __exit lvfs_exit(void)
+{
+ int leaked;
+ ENTRY;
+
+ lvfs_arch_exit();
+ leaked = atomic_read(&obd_memory);
+ CDEBUG(leaked ? D_ERROR : D_INFO,
+ "obd mem max: %d leaked: %d\n", obd_memmax, leaked);
+
+ return;
+}
+
+cfs_module(lvfs, "1.0.0", lvfs_init, lvfs_exit);
+
#include <linux/quotaops.h>
#include <linux/version.h>
#include <libcfs/kp30.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
+#include <lustre_fsfilt.h>
+#include <obd.h>
+#include <obd_class.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/lustre_compat25.h>
-#include <linux/lvfs.h>
+#include <lvfs.h>
#include "lvfs_internal.h"
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_quota.h>
+#include <obd.h>
+#include <lustre_lib.h>
+#include <lustre_quota.h>
atomic_t obd_memory;
int obd_memmax;
*/
#include <liblustre.h>
-#include <linux/lvfs.h>
+#include <lvfs.h>
#include "lvfs_internal.h"
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
+#include <obd.h>
+#include <lustre_lib.h>
/* XXX currently ctxt functions should not be used ?? */
void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
#include <linux/slab.h>
#include <asm/segment.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
struct group_info *groups_alloc(int ngroups)
#include <linux/version.h>
#include <linux/vfs.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs_status.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
#ifdef LPROCFS
static struct lprocfs_vars lprocfs_obd_vars[] = {
-#include <linux/lustre_mds.h>
+#include <lustre_mds.h>
void mdc_pack_req_body(struct ptlrpc_request *);
void mdc_pack_rep_body(struct ptlrpc_request *);
void mdc_readdir_pack(struct ptlrpc_request *req, __u64 offset, __u32 size,
# include <fcntl.h>
# include <liblustre.h>
#endif
-#include <linux/lustre_idl.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_mds.h>
+#include <lustre_idl.h>
+#include <lustre_net.h>
+#include <lustre_mds.h>
#include "mdc_internal.h"
#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lprocfs_status.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lprocfs_status.h>
#include "mdc_internal.h"
int it_disposition(struct lookup_intent *it, int flag)
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
#include "mdc_internal.h"
/* mdc_setattr does its own semaphore handling */
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lprocfs_status.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lprocfs_status.h>
#include "mdc_internal.h"
#define REQUEST_MINOR 244
rpc_lock, obd->u.cli.cl_rpc_lock);
mdc_put_rpc_lock(rpc_lock, NULL);
}
- wake_up(&req->rq_reply_waitq);
+ cfs_waitq_signal(&req->rq_reply_waitq);
RETURN(rc);
}
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/module.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
#include <linux/init.h>
-#include <linux/obd_class.h>
+#include <obd_class.h>
#include <linux/random.h>
#include <linux/fs.h>
#include <linux/jbd.h>
#else
# include <linux/locks.h>
#endif
-#include <linux/obd_lov.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lprocfs_status.h>
-#include <linux/lustre_commit_confd.h>
-#include <linux/lustre_quota.h>
+#include <obd_lov.h>
+#include <lustre_mds.h>
+#include <lustre_fsfilt.h>
+#include <lprocfs_status.h>
+#include <lustre_commit_confd.h>
+#include <lustre_quota.h>
#include "mds_internal.h"
obd->obd_recoverable_clients,
(obd->obd_recoverable_clients == 1)
? "client" : "clients",
- (int)(OBD_RECOVERY_TIMEOUT / HZ) / 60,
- (int)(OBD_RECOVERY_TIMEOUT / HZ) % 60,
+ (int)(OBD_RECOVERY_TIMEOUT) / 60,
+ (int)(OBD_RECOVERY_TIMEOUT) % 60,
obd->obd_name);
} else {
LCONSOLE_INFO("MDT %s now serving %s with recovery %s.\n",
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
#include <asm/statfs.h>
#endif
-#include <linux/obd.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs_status.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
#include "mds_internal.h"
#ifdef LPROCFS
#include <linux/kmod.h>
#include <linux/version.h>
#include <linux/sched.h>
-#include <linux/lustre_quota.h>
+#include <lustre_quota.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
#include <linux/mount.h>
#endif
-#include <linux/lustre_mds.h>
-#include <linux/obd_class.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_fsfilt.h>
+#include <lustre_mds.h>
+#include <obd_class.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
+#include <lustre_fsfilt.h>
#include <libcfs/list.h>
#include "mds_internal.h"
obd->obd_recovery_start = CURRENT_SECONDS;
/* Only used for lprocfs_status */
obd->obd_recovery_end = obd->obd_recovery_start +
- OBD_RECOVERY_TIMEOUT / HZ;
+ OBD_RECOVERY_TIMEOUT;
}
mds->mds_mount_count = mount_count + 1;
#ifndef _MDS_INTERNAL_H
#define _MDS_INTERNAL_H
-#include <linux/lustre_mds.h>
+#include <lustre_mds.h>
#define MDS_SERVICE_WATCHDOG_TIMEOUT (obd_timeout * 1000)
#include <linux/slab.h>
#include <asm/segment.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_lib.h>
+#include <obd_support.h>
+#include <lustre_lib.h>
#include "mds_internal.h"
void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode)
#include <linux/version.h>
#include <libcfs/list.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_commit_confd.h>
-#include <linux/lustre_log.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
+#include <lustre_commit_confd.h>
+#include <lustre_log.h>
#include "mds_internal.h"
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/module.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_idl.h>
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_fsfilt.h>
+#include <lustre_mds.h>
+#include <lustre_idl.h>
+#include <obd_class.h>
+#include <obd_lov.h>
+#include <lustre_lib.h>
+#include <lustre_fsfilt.h>
#include "mds_internal.h"
# include <linux/locks.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lprocfs_status.h>
+#include <obd_class.h>
+#include <obd_lov.h>
+#include <lustre_fsfilt.h>
+#include <lprocfs_status.h>
#include "mds_internal.h"
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/fs.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_ucache.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <obd.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lustre_fsfilt.h>
+#include <lustre_ucache.h>
#include "mds_internal.h"
#include <linux/version.h>
#include <libcfs/list.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_commit_confd.h>
-#include <linux/lvfs.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
+#include <lustre_commit_confd.h>
+#include <lvfs.h>
#include "mds_internal.h"
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/fs.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_ucache.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <obd.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lustre_fsfilt.h>
+#include <lustre_ucache.h>
#include "mds_internal.h"
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>obdclass</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.clusterfs.lustre.obdclass</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>KEXT</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0.1</string>
+ <key>OSBundleCompatibleVersion</key>
+ <string>1.0.0</string>
+ <key>OSBundleLibraries</key>
+ <dict>
+ <key>com.apple.kernel.bsd</key>
+ <string>1.1</string>
+ <key>com.apple.kernel.iokit</key>
+ <string>1.0.0b1</string>
+ <key>com.apple.kernel.mach</key>
+ <string>1.0.0b1</string>
+ <key>com.clusterfs.lustre.libcfs</key>
+ <string>1.0.0</string>
+ <key>com.clusterfs.lustre.lnet</key>
+ <string>1.0.0</string>
+ <key>com.clusterfs.lustre.lvfs</key>
+ <string>1.0.0</string>
+ </dict>
+</dict>
+</plist>
MODULES := obdclass llog_test
-obdclass-objs := llog.o llog_cat.o llog_lvfs.o llog_obd.o llog_swab.o
-obdclass-objs += class_obd.o
-obdclass-objs += debug.o genops.o sysctl.o uuid.o llog_ioctl.o
-obdclass-objs += lprocfs_status.o lustre_handles.o lustre_peer.o
-obdclass-objs += statfs_pack.o obdo.o obd_config.o
+obdclass-linux-objs := linux-module.o linux-obdo.o linux-sysctl.o
+ifeq ($(PATCHLEVEL),6)
+obdclass-linux-objs := $(addprefix linux/,$(obdclass-linux-objs))
+endif
+
+default: all
+
+ifeq (@linux25@,no)
+sources:
+ @for i in $(obdclass-linux-objs:%.o=%.c) ; do \
+ echo "ln -s @srcdir@/linux/$$i ." ; \
+ ln -sf @srcdir@/linux/$$i . || exit 1 ; \
+ done
+
+else
+sources:
+
+endif
+
+obdclass-all-objs := llog.o llog_cat.o llog_lvfs.o llog_obd.o llog_swab.o
+obdclass-all-objs += class_obd.o
+obdclass-all-objs += debug.o genops.o uuid.o llog_ioctl.o
+obdclass-all-objs += lprocfs_status.o lustre_handles.o lustre_peer.o
+obdclass-all-objs += statfs_pack.o obdo.o obd_config.o
+
+obdclass-objs := $(obdclass-linux-objs) $(obdclass-all-objs)
ifeq ($(PATCHLEVEL),6)
llog_test-objs := llog-test.o
+SUBDIRS := linux
+if DARWIN
+SUBDIRS += darwin
+endif
+DIST_SUBDIRS := $(SUBDIRS)
+
if LIBLUSTRE
noinst_LIBRARIES = liblustreclass.a
endif
+
if MODULES
+
+if LINUX
modulefs_DATA = obdclass$(KMODEXT)
noinst_DATA = llog_test$(KMODEXT)
+endif # LINUX
+
+if DARWIN
+macos_PROGRAMS := obdclass
+
+obdclass_SOURCES := \
+ darwin/darwin-module.c darwin/darwin-sysctl.c \
+ class_obd.c genops.c lprocfs_status.c \
+ lustre_handles.c lustre_peer.c obd_config.c \
+ obdo.c debug.c llog_ioctl.c uuid.c \
+ llog_swab.c llog_obd.c llog.c llog_cat.c llog_lvfs.c
+
+obdclass_CFLAGS := $(EXTRA_KCFLAGS)
+obdclass_LDFLAGS := $(EXTRA_KLDFLAGS)
+obdclass_LDADD := $(EXTRA_KLIBS)
+
+plist_DATA := Info.plist
+
+#install-data-hook: fix-kext-ownership
+endif # DARWIN
+
endif # MODULES
MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ llog-test.c
-DIST_SOURCES = $(filter-out llog-test.c,$(obdclass-objs:.o=.c)) $(llog-test-objs:.o=.c) llog_test.c llog_internal.h
+MOSTLYCLEANFILES += linux/*.o darwin/*.o
+DIST_SOURCES = $(filter-out llog-test.c,$(obdclass-all-objs:.o=.c)) $(llog-test-objs:.o=.c) llog_test.c llog_internal.h
#ifndef EXPORT_SYMTAB
# define EXPORT_SYMTAB
#endif
-#ifdef __KERNEL__
-#include <linux/config.h> /* for CONFIG_PROC_FS */
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/lp.h>
-#include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/skbuff.h>
-#include <linux/proc_fs.h>
-#include <linux/fs.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/list.h>
-#include <linux/highmem.h>
-#include <asm/io.h>
-#include <asm/ioctls.h>
-#include <asm/system.h>
-#include <asm/poll.h>
-#include <asm/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/smp_lock.h>
-#include <linux/seq_file.h>
-#else
+#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_debug.h>
-#include <linux/lprocfs_status.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_debug.h>
+#include <lprocfs_status.h>
#ifdef __KERNEL__
#include <linux/lustre_build_version.h>
-#include <linux/lustre_version.h>
#endif
#include <libcfs/list.h>
#include "llog_internal.h"
int obd_memmax;
#endif
-int proc_version;
-
/* The following are visible and mutable through /proc/sys/lustre/. */
unsigned int obd_fail_loc;
unsigned int obd_dump_on_timeout;
char obd_lustre_upcall[128] = "DEFAULT"; /* or NONE or /full/path/to/upcall */
unsigned int obd_sync_filter; /* = 0, don't sync by default */
-DECLARE_WAIT_QUEUE_HEAD(obd_race_waitq);
+cfs_waitq_t obd_race_waitq;
#ifdef __KERNEL__
unsigned int obd_print_fail_loc(void)
}
/* opening /dev/obd */
-static int obd_class_open(struct inode * inode, struct file * file)
+static int obd_class_open(unsigned long flags, void *args)
{
ENTRY;
}
/* closing /dev/obd */
-static int obd_class_release(struct inode * inode, struct file * file)
+static int obd_class_release(unsigned long flags, void *args)
{
ENTRY;
int rc;
int dev;
+ ENTRY;
if (!len || !name) {
CERROR("No name passed,!\n");
GOTO(out, rc = -EINVAL);
int err = 0, len = 0;
ENTRY;
-#ifdef __KERNEL__
- if (current->fsuid != 0)
- RETURN(err = -EACCES);
-#endif
-
- if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
- RETURN(err = -ENOTTY);
-
/* only for debugging */
if (cmd == LIBCFS_IOC_DEBUG_MASK) {
debug_data = (struct libcfs_debug_ioctl_data*)arg;
#define OBD_MINOR 241
#ifdef __KERNEL__
/* to control /dev/obd */
-static int obd_class_ioctl(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+static int obd_class_ioctl (struct cfs_psdev_file *pfile, unsigned long cmd, void *arg)
{
- return class_handle_ioctl(cmd, arg);
+ return class_handle_ioctl(cmd, (unsigned long)arg);
}
/* declare character device */
-static struct file_operations obd_psdev_fops = {
- .owner = THIS_MODULE,
- .ioctl = obd_class_ioctl, /* ioctl */
- .open = obd_class_open, /* open */
- .release = obd_class_release, /* release */
+struct cfs_psdev_ops obd_psdev_ops = {
+ /* .p_open = */ obd_class_open, /* open */
+ /* .p_close = */ obd_class_release, /* release */
+ /* .p_read = */ NULL,
+ /* .p_write = */ NULL,
+ /* .p_ioctl = */ obd_class_ioctl /* ioctl */
};
-/* modules setup */
-static struct miscdevice obd_psdev = {
- .minor = OBD_MINOR,
- .name = "obd",
- .fops = &obd_psdev_fops,
-};
+extern cfs_psdev_t obd_psdev;
#else
void *obd_psdev = NULL;
#endif
EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
EXPORT_SYMBOL(ptlrpc_abort_inflight_superhack);
-struct proc_dir_entry *proc_lustre_root;
EXPORT_SYMBOL(proc_lustre_root);
EXPORT_SYMBOL(class_register_type);
EXPORT_SYMBOL(class_detach);
EXPORT_SYMBOL(class_manual_cleanup);
-#ifdef LPROCFS
-int obd_proc_read_version(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- *eof = 1;
- return snprintf(page, count, "%s\n", BUILD_VERSION);
-}
-
-int obd_proc_read_kernel_version(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- *eof = 1;
- return snprintf(page, count, "%u\n", LUSTRE_KERNEL_VERSION);
-}
-
-int obd_proc_read_pinger(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- *eof = 1;
- return snprintf(page, count, "%s\n",
-#ifdef ENABLE_PINGER
- "on"
-#else
- "off"
-#endif
- );
-}
-
-static int obd_proc_read_health(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int rc = 0, i;
- *eof = 1;
-
- if (libcfs_catastrophe)
- rc += snprintf(page + rc, count - rc, "LBUG\n");
-
- spin_lock(&obd_dev_lock);
- for (i = 0; i < MAX_OBD_DEVICES; i++) {
- struct obd_device *obd;
-
- obd = &obd_dev[i];
- if (obd->obd_type == NULL)
- continue;
-
- atomic_inc(&obd->obd_refcount);
- spin_unlock(&obd_dev_lock);
-
- if (obd_health_check(obd)) {
- rc += snprintf(page + rc, count - rc,
- "device %s reported unhealthy\n",
- obd->obd_name);
- }
- class_decref(obd);
- spin_lock(&obd_dev_lock);
- }
- spin_unlock(&obd_dev_lock);
-
- if (rc == 0)
- return snprintf(page, count, "healthy\n");
-
- rc += snprintf(page + rc, count - rc, "NOT HEALTHY\n");
- return rc;
-}
-
-static int obd_proc_rd_health_timeout(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- *eof = 1;
- return snprintf(page, count, "%d\n", obd_health_check_timeout);
-}
-
-static int obd_proc_wr_health_timeout(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- int val, rc;
-
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
-
- obd_health_check_timeout = val;
-
- return count;
-}
-
-/* Root for /proc/fs/lustre */
-struct lprocfs_vars lprocfs_base[] = {
- { "version", obd_proc_read_version, NULL, NULL },
- { "kernel_version", obd_proc_read_kernel_version, NULL, NULL },
- { "pinger", obd_proc_read_pinger, NULL, NULL },
- { "health_check", obd_proc_read_health, NULL, NULL },
- { "health_check_timeout", obd_proc_rd_health_timeout,
- obd_proc_wr_health_timeout, NULL },
- { 0 }
-};
-#else
-#define lprocfs_base NULL
-#endif /* LPROCFS */
-
-#ifdef __KERNEL__
-static void *obd_device_list_seq_start(struct seq_file *p, loff_t*pos)
-{
- if (*pos >= MAX_OBD_DEVICES)
- return NULL;
- return &obd_dev[*pos];
-}
-
-static void obd_device_list_seq_stop(struct seq_file *p, void *v)
-{
-}
-
-static void *obd_device_list_seq_next(struct seq_file *p, void *v, loff_t *pos)
-{
- ++*pos;
- if (*pos >= MAX_OBD_DEVICES)
- return NULL;
- return &obd_dev[*pos];
-}
-
-static int obd_device_list_seq_show(struct seq_file *p, void *v)
-{
- struct obd_device *obd = (struct obd_device *)v;
- int index = obd - &obd_dev[0];
- char *status;
-
- if (!obd->obd_type)
- return 0;
- if (obd->obd_stopping)
- status = "ST";
- else if (obd->obd_set_up)
- status = "UP";
- else if (obd->obd_attached)
- status = "AT";
- else
- status = "--";
-
- return seq_printf(p, "%3d %s %s %s %s %d\n",
- (int)index, status, obd->obd_type->typ_name,
- obd->obd_name, obd->obd_uuid.uuid,
- atomic_read(&obd->obd_refcount));
-}
-
-struct seq_operations obd_device_list_sops = {
- .start = obd_device_list_seq_start,
- .stop = obd_device_list_seq_stop,
- .next = obd_device_list_seq_next,
- .show = obd_device_list_seq_show,
-};
-
-static int obd_device_list_open(struct inode *inode, struct file *file)
-{
- struct proc_dir_entry *dp = PDE(inode);
- struct seq_file *seq;
- int rc = seq_open(file, &obd_device_list_sops);
-
- if (rc)
- return rc;
-
- seq = file->private_data;
- seq->private = dp->data;
-
- return 0;
-}
-
-struct file_operations obd_device_list_fops = {
- .owner = THIS_MODULE,
- .open = obd_device_list_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release,
-};
-#endif
-
#define OBD_INIT_CHECK
#ifdef OBD_INIT_CHECK
int obd_init_checks(void)
#define obd_init_checks() do {} while(0)
#endif
+extern spinlock_t obd_types_lock;
+extern spinlock_t handle_lock;
+extern int class_procfs_init(void);
+extern int class_procfs_clean(void);
+
#ifdef __KERNEL__
static int __init init_obdclass(void)
#else
#endif
{
struct obd_device *obd;
-#ifdef __KERNEL__
- struct proc_dir_entry *entry;
-#endif
int err;
int i;
CDEBUG(D_INFO, "Lustre: OBD class driver Build Version: "
BUILD_VERSION", info@clusterfs.com\n");
#endif
+ spin_lock_init(&obd_types_lock);
+ spin_lock_init(&handle_lock);
+ cfs_waitq_init(&obd_race_waitq);
err = obd_init_checks();
if (err == -EOVERFLOW)
spin_lock_init(&obd_dev_lock);
INIT_LIST_HEAD(&obd_types);
- err = misc_register(&obd_psdev);
+ err = cfs_psdev_register(&obd_psdev);
if (err) {
CERROR("cannot register %d err %d\n", OBD_MINOR, err);
return err;
err = obd_init_caches();
if (err)
return err;
-
#ifdef __KERNEL__
- obd_sysctl_init();
-
- proc_lustre_root = proc_mkdir("lustre", proc_root_fs);
- if (!proc_lustre_root) {
- printk(KERN_ERR
- "LustreError: error registering /proc/fs/lustre\n");
- RETURN(-ENOMEM);
- }
- proc_version = lprocfs_add_vars(proc_lustre_root, lprocfs_base, NULL);
- entry = create_proc_entry("devices", 0444, proc_lustre_root);
- if (entry == NULL) {
- CERROR("error registering /proc/fs/lustre/devices\n");
- lprocfs_remove(proc_lustre_root);
- RETURN(-ENOMEM);
- }
- entry->proc_fops = &obd_device_list_fops;
+ err = class_procfs_init();
#endif
- return 0;
+
+ return err;
}
/* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this
int leaked;
ENTRY;
- misc_deregister(&obd_psdev);
+ cfs_psdev_deregister(&obd_psdev);
for (i = 0; i < MAX_OBD_DEVICES; i++) {
struct obd_device *obd = &obd_dev[i];
if (obd->obd_type && obd->obd_set_up &&
obd_cleanup_caches();
obd_sysctl_clean();
- if (proc_lustre_root) {
- lprocfs_remove(proc_lustre_root);
- proc_lustre_root = NULL;
- }
+ class_procfs_clean();
class_handle_cleanup();
class_exit_uuidlist();
EXIT;
}
-/* Check that we're building against the appropriate version of the Lustre
- * kernel patch */
-#include <linux/lustre_version.h>
-#define LUSTRE_MIN_VERSION 37
-#define LUSTRE_MAX_VERSION 47
-#if (LUSTRE_KERNEL_VERSION < LUSTRE_MIN_VERSION)
-# error Cannot continue: Your Lustre kernel patch is older than the sources
-#elif (LUSTRE_KERNEL_VERSION > LUSTRE_MAX_VERSION)
-# error Cannot continue: Your Lustre sources are older than the kernel patch
-#endif
-
MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
MODULE_LICENSE("GPL");
-module_init(init_obdclass);
-module_exit(cleanup_obdclass);
+cfs_module(obdclass, "1.0.0", init_obdclass, cleanup_obdclass);
#endif
--- /dev/null
+EXTRA_DIST := \
+ darwin-module.c \
+ darwin-sysctl.c
--- /dev/null
+#define DEBUG_SUBSYSTEM S_CLASS
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+
+#include <mach/mach_types.h>
+#include <string.h>
+#include <sys/file.h>
+#include <sys/conf.h>
+#include <miscfs/devfs/devfs.h>
+
+#include <libcfs/libcfs.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
+
+#ifndef OBD_MAX_IOCTL_BUFFER
+#define OBD_MAX_IOCTL_BUFFER 8192
+#endif
+
+/* buffer MUST be at least the size of obd_ioctl_hdr */
+int obd_ioctl_getdata(char **buf, int *len, void *arg)
+{
+ struct obd_ioctl_hdr *hdr;
+ struct obd_ioctl_data *data;
+ int err = 0;
+ int offset = 0;
+ ENTRY;
+
+ hdr = (struct obd_ioctl_hdr *)arg;
+ if (hdr->ioc_version != OBD_IOCTL_VERSION) {
+ CERROR("Version mismatch kernel vs application\n");
+ RETURN(-EINVAL);
+ }
+
+ if (hdr->ioc_len > OBD_MAX_IOCTL_BUFFER) {
+ CERROR("User buffer len %d exceeds %d max buffer\n",
+ hdr->ioc_len, OBD_MAX_IOCTL_BUFFER);
+ RETURN(-EINVAL);
+ }
+
+ if (hdr->ioc_len < sizeof(struct obd_ioctl_data)) {
+ CERROR("OBD: user buffer too small for ioctl (%d)\n", hdr->ioc_len);
+ RETURN(-EINVAL);
+ }
+
+ /* XXX allocate this more intelligently, using kmalloc when
+ * appropriate */
+ OBD_VMALLOC(*buf, hdr->ioc_len);
+ if (*buf == NULL) {
+ CERROR("Cannot allocate control buffer of len %d\n",
+ hdr->ioc_len);
+ RETURN(-EINVAL);
+ }
+ *len = hdr->ioc_len;
+ data = (struct obd_ioctl_data *)*buf;
+
+ bzero(*buf, hdr->ioc_len);
+ memcpy(*buf, (void *)arg, sizeof(struct obd_ioctl_data));
+ if (data->ioc_inlbuf1)
+ err = copy_from_user(&data->ioc_bulk[0], (void *)data->ioc_inlbuf1,
+ hdr->ioc_len - ((void *)&data->ioc_bulk[0] - (void *)data));
+
+ if (obd_ioctl_is_invalid(data)) {
+ CERROR("ioctl not correctly formatted\n");
+ return -EINVAL;
+ }
+
+ if (data->ioc_inllen1) {
+ data->ioc_inlbuf1 = &data->ioc_bulk[0];
+ offset += size_round(data->ioc_inllen1);
+ }
+
+ if (data->ioc_inllen2) {
+ data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset;
+ offset += size_round(data->ioc_inllen2);
+ }
+
+ if (data->ioc_inllen3) {
+ data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset;
+ offset += size_round(data->ioc_inllen3);
+ }
+
+ if (data->ioc_inllen4) {
+ data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset;
+ }
+
+ EXIT;
+ return 0;
+}
+
+/*
+ * cfs pseudo device
+ */
+extern struct cfs_psdev_ops obd_psdev_ops;
+
+static int
+obd_class_open(dev_t dev, int flags, int devtype, struct proc *p)
+{
+ if (obd_psdev_ops.p_open != NULL)
+ return obd_psdev_ops.p_open(0, NULL);
+ return -EPERM;
+}
+
+/* closing /dev/obd */
+static int
+obd_class_release(dev_t dev, int flags, int mode, struct proc *p)
+{
+ if (obd_psdev_ops.p_close != NULL)
+ return obd_psdev_ops.p_close(0, NULL);
+ return -EPERM;
+}
+
+static int
+obd_class_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
+{
+ int err = 0;
+ ENTRY;
+
+ if (suser(p->p_ucred, &p->p_acflag))
+ RETURN (-EPERM);
+ if (obd_psdev_ops.p_ioctl != NULL)
+ err = obd_psdev_ops.p_ioctl(NULL, cmd, (void *)arg);
+ else
+ err = -EPERM;
+
+ RETURN(err);
+}
+
+static struct cdevsw obd_psdevsw = {
+ obd_class_open,
+ obd_class_release,
+ NULL,
+ NULL,
+ obd_class_ioctl,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+};
+
+cfs_psdev_t obd_psdev = {
+ -1,
+ NULL,
+ "obd",
+ &obd_psdevsw
+};
+
+int class_procfs_init(void)
+{
+ return 0;
+}
+
+int class_procfs_clean(void)
+{
+ return 0;
+}
--- /dev/null
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+#include <sys/unistd.h>
+#include <mach/mach_types.h>
+#include <linux/lustre_build_version.h>
+
+#define DEBUG_SUBSYSTEM S_CLASS
+
+#include <libcfs/libcfs.h>
+#ifndef BUILD_VERSION
+#define BUILD_VERSION "Unknown"
+#endif
+#ifndef LUSTRE_KERNEL_VERSION
+#define LUSTRE_KERNEL_VERSION "Unknown Darwin version"
+#endif
+
+cfs_sysctl_table_header_t *obd_table_header = NULL;
+
+int proc_fail_loc SYSCTL_HANDLER_ARGS;
+int proc_obd_timeout SYSCTL_HANDLER_ARGS;
+extern unsigned int obd_fail_loc;
+extern unsigned int obd_dump_on_timeout;
+extern unsigned int obd_timeout;
+extern unsigned int ldlm_timeout;
+extern char obd_lustre_upcall[128];
+extern unsigned int obd_sync_filter;
+extern atomic_t obd_memory;
+
+int read_build_version SYSCTL_HANDLER_ARGS;
+int read_lustre_kernel_version SYSCTL_HANDLER_ARGS;
+
+SYSCTL_NODE (, OID_AUTO, lustre, CTLFLAG_RW,
+ 0, "lustre sysctl top");
+SYSCTL_PROC(_lustre, OID_AUTO, fail_loc,
+ CTLTYPE_INT | CTLFLAG_RW , &obd_fail_loc,
+ 0, &proc_fail_loc, "I", "obd_fail_loc");
+SYSCTL_PROC(_lustre, OID_AUTO, timeout,
+ CTLTYPE_INT | CTLFLAG_RW , &obd_timeout,
+ 0, &proc_obd_timeout, "I", "obd_timeout");
+SYSCTL_PROC(_lustre, OID_AUTO, build_version,
+ CTLTYPE_STRING | CTLFLAG_RD , NULL,
+ 0, &read_build_version, "A", "lustre_build_version");
+SYSCTL_PROC(_lustre, OID_AUTO, lustre_kernel_version,
+ CTLTYPE_STRING | CTLFLAG_RD , NULL,
+ 0, &read_lustre_kernel_version, "A", "lustre_build_version");
+SYSCTL_INT(_lustre, OID_AUTO, dump_on_timeout,
+ CTLTYPE_INT | CTLFLAG_RW, &obd_dump_on_timeout,
+ 0, "lustre_dump_on_timeout");
+SYSCTL_STRING(_lustre, OID_AUTO, upcall,
+ CTLTYPE_STRING | CTLFLAG_RW, obd_lustre_upcall,
+ 128, "lustre_upcall");
+SYSCTL_INT(_lustre, OID_AUTO, memused,
+ CTLTYPE_INT | CTLFLAG_RW, (int *)&obd_memory.counter,
+ 0, "lustre_memory_used");
+SYSCTL_INT(_lustre, OID_AUTO, filter_sync_on_commit,
+ CTLTYPE_INT | CTLFLAG_RW, &obd_sync_filter,
+ 0, "filter_sync_on_commit");
+SYSCTL_INT(_lustre, OID_AUTO, ldlm_timeout,
+ CTLTYPE_INT | CTLFLAG_RW, &ldlm_timeout,
+ 0, "ldlm_timeout");
+
+static cfs_sysctl_table_t parent_table[] = {
+ &sysctl__lustre,
+ &sysctl__lustre_fail_loc,
+ &sysctl__lustre_timeout,
+ &sysctl__lustre_dump_on_timeout,
+ &sysctl__lustre_upcall,
+ &sysctl__lustre_memused,
+ &sysctl__lustre_filter_sync_on_commit,
+ &sysctl__lustre_ldlm_timeout,
+};
+
+extern cfs_waitq_t obd_race_waitq;
+
+int proc_fail_loc SYSCTL_HANDLER_ARGS
+{
+ int error = 0;
+ int old_fail_loc = obd_fail_loc;
+
+ error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
+ if (!error && req->newptr != NULL) {
+ if (old_fail_loc != obd_fail_loc)
+ cfs_waitq_signal(&obd_race_waitq);
+ } else if (req->newptr != NULL) {
+ /* Something was wrong with the write request */
+ printf ("sysctl fail loc fault: %d.\n", error);
+ } else {
+ /* Read request */
+ error = SYSCTL_OUT(req, &obd_fail_loc, sizeof obd_fail_loc);
+ }
+ return error;
+}
+
+int proc_obd_timeout SYSCTL_HANDLER_ARGS
+{
+ int error = 0;
+
+ error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
+ if (!error && req->newptr != NULL) {
+ if (ldlm_timeout >= obd_timeout)
+ ldlm_timeout = max(obd_timeout / 3, 1U);
+ } else if (req->newptr != NULL) {
+ printf ("sysctl fail obd_timeout: %d.\n", error);
+ } else {
+ /* Read request */
+ error = SYSCTL_OUT(req, &obd_timeout, sizeof obd_timeout);
+ }
+ return error;
+}
+
+int read_build_version SYSCTL_HANDLER_ARGS
+{
+ int error = 0;
+
+ error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
+ if ( req->newptr != NULL) {
+ printf("sysctl read_build_version is read-only!\n");
+ } else {
+ error = SYSCTL_OUT(req, BUILD_VERSION, strlen(BUILD_VERSION));
+ }
+ return error;
+}
+
+int read_lustre_kernel_version SYSCTL_HANDLER_ARGS
+{
+ int error = 0;
+
+ error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
+ if ( req->newptr != NULL) {
+ printf("sysctl lustre_kernel_version is read-only!\n");
+ } else {
+ error = SYSCTL_OUT(req, LUSTRE_KERNEL_VERSION, strlen(LUSTRE_KERNEL_VERSION));
+ }
+ return error;
+}
+
+void obd_sysctl_init (void)
+{
+#if 1
+ if ( !obd_table_header )
+ obd_table_header = cfs_register_sysctl_table(parent_table, 0);
+#endif
+}
+
+void obd_sysctl_clean (void)
+{
+#if 1
+ if ( obd_table_header )
+ cfs_unregister_sysctl_table(obd_table_header);
+ obd_table_header = NULL;
+#endif
+}
+
# include <liblustre.h>
#endif
-#include <linux/obd_ost.h>
-#include <linux/obd_support.h>
-#include <linux/lustre_debug.h>
-#include <linux/lustre_net.h>
+#include <obd_ost.h>
+#include <obd_support.h>
+#include <lustre_debug.h>
+#include <lustre_net.h>
int dump_ioo(struct obd_ioobj *ioo)
{
{
CERROR("niobuf_local: offset="LPD64", len=%d, page=%p, rc=%d\n",
nb->offset, nb->len, nb->page, nb->rc);
- CERROR("nb->page: index = %ld\n", nb->page ? nb->page->index : -1);
+ CERROR("nb->page: index = %ld\n", nb->page ? cfs_page_index(nb->page) : -1);
return -EINVAL;
}
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifdef __KERNEL__
-#include <linux/kmod.h> /* for request_module() */
-#include <linux/module.h>
-#else
+#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/lustre_mds.h>
-#include <linux/obd_ost.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs_status.h>
+#include <lustre_mds.h>
+#include <obd_ost.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
extern struct list_head obd_types;
-static spinlock_t obd_types_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t obd_types_lock;
-kmem_cache_t *obdo_cachep = NULL;
+cfs_mem_cache_t *obdo_cachep = NULL;
EXPORT_SYMBOL(obdo_cachep);
-kmem_cache_t *import_cachep = NULL;
+cfs_mem_cache_t *import_cachep = NULL;
int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
void (*ptlrpc_abort_inflight_superhack)(struct obd_import *imp);
{
ENTRY;
if (obdo_cachep) {
- LASSERTF(kmem_cache_destroy(obdo_cachep) == 0,
+ LASSERTF(cfs_mem_cache_destroy(obdo_cachep) == 0,
"Cannot destory ll_obdo_cache\n");
obdo_cachep = NULL;
}
if (import_cachep) {
- LASSERTF(kmem_cache_destroy(import_cachep) == 0,
+ LASSERTF(cfs_mem_cache_destroy(import_cachep) == 0,
"Cannot destory ll_import_cache\n");
import_cachep = NULL;
}
ENTRY;
LASSERT(obdo_cachep == NULL);
- obdo_cachep = kmem_cache_create("ll_obdo_cache", sizeof(struct obdo),
- 0, 0, NULL, NULL);
+ obdo_cachep = cfs_mem_cache_create("ll_obdo_cache", sizeof(struct obdo),
+ 0, 0);
if (!obdo_cachep)
GOTO(out, -ENOMEM);
LASSERT(import_cachep == NULL);
- import_cachep = kmem_cache_create("ll_import_cache",
+ import_cachep = cfs_mem_cache_create("ll_import_cache",
sizeof(struct obd_import),
- 0, 0, NULL, NULL);
+ 0, 0);
if (!import_cachep)
GOTO(out, -ENOMEM);
export->exp_conn_cnt = 0;
atomic_set(&export->exp_refcount, 2);
export->exp_obd = obd;
- INIT_LIST_HEAD(&export->exp_outstanding_replies);
+ CFS_INIT_LIST_HEAD(&export->exp_outstanding_replies);
/* XXX this should be in LDLM init */
- INIT_LIST_HEAD(&export->exp_ldlm_data.led_held_locks);
+ CFS_INIT_LIST_HEAD(&export->exp_ldlm_data.led_held_locks);
- INIT_LIST_HEAD(&export->exp_handle.h_link);
+ CFS_INIT_LIST_HEAD(&export->exp_handle.h_link);
class_handle_hash(&export->exp_handle, export_handle_addref);
export->exp_last_request_time = CURRENT_SECONDS;
spin_lock_init(&export->exp_lock);
if (imp == NULL)
return NULL;
- INIT_LIST_HEAD(&imp->imp_replay_list);
- INIT_LIST_HEAD(&imp->imp_sending_list);
- INIT_LIST_HEAD(&imp->imp_delayed_list);
+ CFS_INIT_LIST_HEAD(&imp->imp_replay_list);
+ CFS_INIT_LIST_HEAD(&imp->imp_sending_list);
+ CFS_INIT_LIST_HEAD(&imp->imp_delayed_list);
spin_lock_init(&imp->imp_lock);
imp->imp_conn_cnt = 0;
imp->imp_max_transno = 0;
imp->imp_peer_committed_transno = 0;
imp->imp_state = LUSTRE_IMP_NEW;
- init_waitqueue_head(&imp->imp_recovery_waitq);
+ cfs_waitq_init(&imp->imp_recovery_waitq);
atomic_set(&imp->imp_refcount, 2);
atomic_set(&imp->imp_inflight, 0);
atomic_set(&imp->imp_replay_inflight, 0);
- INIT_LIST_HEAD(&imp->imp_conn_list);
- INIT_LIST_HEAD(&imp->imp_handle.h_link);
+ CFS_INIT_LIST_HEAD(&imp->imp_conn_list);
+ CFS_INIT_LIST_HEAD(&imp->imp_handle.h_link);
class_handle_hash(&imp->imp_handle, import_handle_addref);
return imp;
int cnt = 0;
ENTRY;
- INIT_LIST_HEAD(&work_list);
+ CFS_INIT_LIST_HEAD(&work_list);
spin_lock(&obd->obd_dev_lock);
list_for_each_safe(pos, n, &obd->obd_exports) {
exp = list_entry(pos, struct obd_export, exp_obd_chain);
oig->oig_rc = 0;
oig->oig_pending = 0;
atomic_set(&oig->oig_refcount, 1);
- init_waitqueue_head(&oig->oig_waitq);
- INIT_LIST_HEAD(&oig->oig_occ_list);
+ cfs_waitq_init(&oig->oig_waitq);
+ CFS_INIT_LIST_HEAD(&oig->oig_occ_list);
*oig_out = oig;
RETURN(0);
struct oig_callback_context *occ, int rc)
{
unsigned long flags;
- wait_queue_head_t *wake = NULL;
+ cfs_waitq_t *wake = NULL;
int old_rc;
spin_lock_irqsave(&oig->oig_lock, flags);
"pending (racey)\n", oig, old_rc, oig->oig_rc, rc,
oig->oig_pending);
if (wake)
- wake_up(wake);
+ cfs_waitq_signal(wake);
oig_release(oig);
}
EXPORT_SYMBOL(oig_complete_one);
static int pet_refcount = 0;
static int pet_state;
-static wait_queue_head_t pet_waitq;
+static cfs_waitq_t pet_waitq;
static struct obd_export *pet_exp = NULL;
-static spinlock_t pet_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t pet_lock;
static int ping_evictor_wake(struct obd_export *exp)
{
pet_exp = class_export_get(exp);
spin_unlock(&pet_lock);
- wake_up(&pet_waitq);
+ cfs_waitq_signal(&pet_waitq);
return 0;
}
struct obd_export *exp;
struct l_wait_info lwi = { 0 };
time_t expire_time;
- unsigned long flags;
ENTRY;
lock_kernel();
- libcfs_daemonize("ping_evictor");
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_daemonize("ping_evictor");
+ cfs_block_allsigs();
unlock_kernel();
CDEBUG(D_HA, "Starting Ping Evictor\n");
if (++pet_refcount > 1)
return;
- init_waitqueue_head(&pet_waitq);
+ spin_lock_init(&pet_lock);
+ cfs_waitq_init(&pet_waitq);
- rc = kernel_thread(ping_evictor_main, NULL, CLONE_VM | CLONE_FS);
+ rc = cfs_kernel_thread(ping_evictor_main, NULL, CLONE_VM | CLONE_FS);
if (rc < 0) {
pet_refcount--;
CERROR("Cannot start ping evictor thread: %d\n", rc);
return;
pet_state = PET_TERMINATE;
- wake_up(&pet_waitq);
+ cfs_waitq_signal(&pet_waitq);
}
EXPORT_SYMBOL(ping_evictor_stop);
#else /* !__KERNEL__ */
--- /dev/null
+EXTRA_DIST := \
+ linux-module.c \
+ linux-sysctl.c \
+ linux-obdo.c
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Object Devices Class Driver
+ *
+ * Copyright (C) 2001-2003 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * These are the only exported functions, they provide some generic
+ * infrastructure for managing object devices
+ */
+#define DEBUG_SUBSYSTEM S_CLASS
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+
+#ifdef __KERNEL__
+#include <linux/config.h> /* for CONFIG_PROC_FS */
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/sched.h>
+#include <linux/lp.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/fcntl.h>
+#include <linux/delay.h>
+#include <linux/skbuff.h>
+#include <linux/proc_fs.h>
+#include <linux/fs.h>
+#include <linux/poll.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/highmem.h>
+#include <asm/io.h>
+#include <asm/ioctls.h>
+#include <asm/system.h>
+#include <asm/poll.h>
+#include <asm/uaccess.h>
+#include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
+#include <linux/seq_file.h>
+#else
+# include <liblustre.h>
+#endif
+
+#include <libcfs/libcfs.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
+#ifdef __KERNEL__
+#include <linux/lustre_build_version.h>
+#include <linux/lustre_version.h>
+
+int proc_version;
+
+/* buffer MUST be at least the size of obd_ioctl_hdr */
+int obd_ioctl_getdata(char **buf, int *len, void *arg)
+{
+ struct obd_ioctl_hdr hdr;
+ struct obd_ioctl_data *data;
+ int err;
+ int offset = 0;
+ ENTRY;
+
+ err = copy_from_user(&hdr, (void *)arg, sizeof(hdr));
+ if ( err )
+ RETURN(err);
+
+ if (hdr.ioc_version != OBD_IOCTL_VERSION) {
+ CERROR("Version mismatch kernel vs application\n");
+ RETURN(-EINVAL);
+ }
+
+ if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) {
+ CERROR("User buffer len %d exceeds %d max buffer\n",
+ hdr.ioc_len, OBD_MAX_IOCTL_BUFFER);
+ RETURN(-EINVAL);
+ }
+
+ if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) {
+ CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len);
+ RETURN(-EINVAL);
+ }
+
+ /* XXX allocate this more intelligently, using kmalloc when
+ * appropriate */
+ OBD_VMALLOC(*buf, hdr.ioc_len);
+ if (*buf == NULL) {
+ CERROR("Cannot allocate control buffer of len %d\n",
+ hdr.ioc_len);
+ RETURN(-EINVAL);
+ }
+ *len = hdr.ioc_len;
+ data = (struct obd_ioctl_data *)*buf;
+
+ err = copy_from_user(*buf, (void *)arg, hdr.ioc_len);
+ if ( err ) {
+ OBD_VFREE(*buf, hdr.ioc_len);
+ RETURN(err);
+ }
+
+ if (obd_ioctl_is_invalid(data)) {
+ CERROR("ioctl not correctly formatted\n");
+ OBD_VFREE(*buf, hdr.ioc_len);
+ RETURN(-EINVAL);
+ }
+
+ if (data->ioc_inllen1) {
+ data->ioc_inlbuf1 = &data->ioc_bulk[0];
+ offset += size_round(data->ioc_inllen1);
+ }
+
+ if (data->ioc_inllen2) {
+ data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset;
+ offset += size_round(data->ioc_inllen2);
+ }
+
+ if (data->ioc_inllen3) {
+ data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset;
+ offset += size_round(data->ioc_inllen3);
+ }
+
+ if (data->ioc_inllen4) {
+ data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset;
+ }
+
+ EXIT;
+ return 0;
+}
+
+EXPORT_SYMBOL(obd_ioctl_getdata);
+
+#define OBD_MINOR 241
+extern struct cfs_psdev_ops obd_psdev_ops;
+
+/* opening /dev/obd */
+static int obd_class_open(struct inode * inode, struct file * file)
+{
+ if (obd_psdev_ops.p_open != NULL)
+ return obd_psdev_ops.p_open(0, NULL);
+ return -EPERM;
+}
+
+/* closing /dev/obd */
+static int obd_class_release(struct inode * inode, struct file * file)
+{
+ if (obd_psdev_ops.p_close != NULL)
+ return obd_psdev_ops.p_close(0, NULL);
+ return -EPERM;
+}
+
+/* to control /dev/obd */
+static int obd_class_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ int err = 0;
+ ENTRY;
+
+ if (current->fsuid != 0)
+ RETURN(err = -EACCES);
+ if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
+ RETURN(err = -ENOTTY);
+
+ if (obd_psdev_ops.p_ioctl != NULL)
+ err = obd_psdev_ops.p_ioctl(NULL, cmd, (void *)arg);
+ else
+ err = -EPERM;
+
+ RETURN(err);
+}
+
+/* declare character device */
+static struct file_operations obd_psdev_fops = {
+ .owner = THIS_MODULE,
+ .ioctl = obd_class_ioctl, /* ioctl */
+ .open = obd_class_open, /* open */
+ .release = obd_class_release, /* release */
+};
+
+/* modules setup */
+cfs_psdev_t obd_psdev = {
+ .minor = OBD_MINOR,
+ .name = "obd_psdev",
+ .fops = &obd_psdev_fops,
+};
+
+#endif
+
+#ifdef LPROCFS
+int obd_proc_read_version(char *page, char **start, off_t off, int count,
+ int *eof, void *data)
+{
+ *eof = 1;
+ return snprintf(page, count, "%s\n", BUILD_VERSION);
+}
+
+int obd_proc_read_kernel_version(char *page, char **start, off_t off, int count,
+ int *eof, void *data)
+{
+ *eof = 1;
+ return snprintf(page, count, "%u\n", LUSTRE_KERNEL_VERSION);
+}
+
+int obd_proc_read_pinger(char *page, char **start, off_t off, int count,
+ int *eof, void *data)
+{
+ *eof = 1;
+ return snprintf(page, count, "%s\n",
+#ifdef ENABLE_PINGER
+ "on"
+#else
+ "off"
+#endif
+ );
+}
+
+static int obd_proc_read_health(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int rc = 0, i;
+ *eof = 1;
+
+ if (libcfs_catastrophe)
+ rc += snprintf(page + rc, count - rc, "LBUG\n");
+
+ spin_lock(&obd_dev_lock);
+ for (i = 0; i < MAX_OBD_DEVICES; i++) {
+ struct obd_device *obd;
+
+ obd = &obd_dev[i];
+ if (obd->obd_type == NULL)
+ continue;
+
+ atomic_inc(&obd->obd_refcount);
+ spin_unlock(&obd_dev_lock);
+
+ if (obd_health_check(obd)) {
+ rc += snprintf(page + rc, count - rc,
+ "device %s reported unhealthy\n",
+ obd->obd_name);
+ }
+ class_decref(obd);
+ spin_lock(&obd_dev_lock);
+ }
+ spin_unlock(&obd_dev_lock);
+
+ if (rc == 0)
+ return snprintf(page, count, "healthy\n");
+
+ rc += snprintf(page + rc, count - rc, "NOT HEALTHY\n");
+ return rc;
+}
+
+static int obd_proc_rd_health_timeout(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ *eof = 1;
+ return snprintf(page, count, "%d\n", obd_health_check_timeout);
+}
+
+static int obd_proc_wr_health_timeout(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ int val, rc;
+
+ rc = lprocfs_write_helper(buffer, count, &val);
+ if (rc)
+ return rc;
+
+ obd_health_check_timeout = val;
+
+ return count;
+}
+
+/* Root for /proc/fs/lustre */
+struct proc_dir_entry *proc_lustre_root = NULL;
+
+struct lprocfs_vars lprocfs_base[] = {
+ { "version", obd_proc_read_version, NULL, NULL },
+ { "kernel_version", obd_proc_read_kernel_version, NULL, NULL },
+ { "pinger", obd_proc_read_pinger, NULL, NULL },
+ { "health_check", obd_proc_read_health, NULL, NULL },
+ { "health_check_timeout", obd_proc_rd_health_timeout,
+ obd_proc_wr_health_timeout, NULL },
+ { 0 }
+};
+#else
+#define lprocfs_base NULL
+#endif /* LPROCFS */
+
+#ifdef __KERNEL__
+static void *obd_device_list_seq_start(struct seq_file *p, loff_t*pos)
+{
+ if (*pos >= MAX_OBD_DEVICES)
+ return NULL;
+ return &obd_dev[*pos];
+}
+
+static void obd_device_list_seq_stop(struct seq_file *p, void *v)
+{
+}
+
+static void *obd_device_list_seq_next(struct seq_file *p, void *v, loff_t *pos)
+{
+ ++*pos;
+ if (*pos >= MAX_OBD_DEVICES)
+ return NULL;
+ return &obd_dev[*pos];
+}
+
+static int obd_device_list_seq_show(struct seq_file *p, void *v)
+{
+ struct obd_device *obd = (struct obd_device *)v;
+ int index = obd - &obd_dev[0];
+ char *status;
+
+ if (!obd->obd_type)
+ return 0;
+ if (obd->obd_stopping)
+ status = "ST";
+ else if (obd->obd_set_up)
+ status = "UP";
+ else if (obd->obd_attached)
+ status = "AT";
+ else
+ status = "--";
+
+ return seq_printf(p, "%3d %s %s %s %s %d\n",
+ (int)index, status, obd->obd_type->typ_name,
+ obd->obd_name, obd->obd_uuid.uuid,
+ atomic_read(&obd->obd_refcount));
+}
+
+struct seq_operations obd_device_list_sops = {
+ .start = obd_device_list_seq_start,
+ .stop = obd_device_list_seq_stop,
+ .next = obd_device_list_seq_next,
+ .show = obd_device_list_seq_show,
+};
+
+static int obd_device_list_open(struct inode *inode, struct file *file)
+{
+ struct proc_dir_entry *dp = PDE(inode);
+ struct seq_file *seq;
+ int rc = seq_open(file, &obd_device_list_sops);
+
+ if (rc)
+ return rc;
+
+ seq = file->private_data;
+ seq->private = dp->data;
+
+ return 0;
+}
+
+struct file_operations obd_device_list_fops = {
+ .owner = THIS_MODULE,
+ .open = obd_device_list_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+#endif
+
+int class_procfs_init(void)
+{
+#ifdef __KERNEL__
+ struct proc_dir_entry *entry;
+ ENTRY;
+
+ obd_sysctl_init();
+ proc_lustre_root = proc_mkdir("lustre", proc_root_fs);
+ if (!proc_lustre_root) {
+ printk(KERN_ERR
+ "LustreError: error registering /proc/fs/lustre\n");
+ RETURN(-ENOMEM);
+ }
+ proc_version = lprocfs_add_vars(proc_lustre_root, lprocfs_base, NULL);
+ entry = create_proc_entry("devices", 0444, proc_lustre_root);
+ if (entry == NULL) {
+ CERROR("error registering /proc/fs/lustre/devices\n");
+ lprocfs_remove(proc_lustre_root);
+ RETURN(-ENOMEM);
+ }
+ entry->proc_fops = &obd_device_list_fops;
+#else
+ ENTRY;
+#endif
+ RETURN(0);
+}
+
+#ifdef __KERNEL__
+int class_procfs_clean(void)
+{
+ ENTRY;
+ if (proc_lustre_root) {
+ lprocfs_remove(proc_lustre_root);
+ proc_lustre_root = NULL;
+ }
+ RETURN(0);
+}
+
+
+/* Check that we're building against the appropriate version of the Lustre
+ * kernel patch */
+#include <linux/lustre_version.h>
+#define LUSTRE_MIN_VERSION 37
+#define LUSTRE_MAX_VERSION 47
+#if (LUSTRE_KERNEL_VERSION < LUSTRE_MIN_VERSION)
+# error Cannot continue: Your Lustre kernel patch is older than the sources
+#elif (LUSTRE_KERNEL_VERSION > LUSTRE_MAX_VERSION)
+# error Cannot continue: Your Lustre sources are older than the kernel patch
+#endif
+#endif
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Object Devices Class Driver
+ *
+ * Copyright (C) 2001-2003 Cluster File Systems, Inc.
+ *
+ * This file is part of the Lustre file system, http://www.lustre.org
+ * Lustre is a trademark of Cluster File Systems, Inc.
+ *
+ * You may have signed or agreed to another license before downloading
+ * this software. If so, you are bound by the terms and conditions
+ * of that agreement, and the following does not apply to you. See the
+ * LICENSE file included with this distribution for more information.
+ *
+ * If you did not agree to a different license, then this copy of Lustre
+ * is open source software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In either case, Lustre is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * license text for more details.
+ *
+ * These are the only exported functions, they provide some generic
+ * infrastructure for managing object devices
+ */
+
+#define DEBUG_SUBSYSTEM S_CLASS
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+
+#ifndef __KERNEL__
+#include <liblustre.h>
+#else
+#include <linux/module.h>
+#include <obd_class.h>
+#include <lustre_idl.h>
+#endif
+
+#ifdef __KERNEL__
+#include <linux/fs.h>
+#include <linux/pagemap.h> /* for PAGE_CACHE_SIZE */
+
+void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid)
+{
+ if (ia_valid & ATTR_ATIME) {
+ oa->o_atime = LTIME_S(attr->ia_atime);
+ oa->o_valid |= OBD_MD_FLATIME;
+ }
+ if (ia_valid & ATTR_MTIME) {
+ oa->o_mtime = LTIME_S(attr->ia_mtime);
+ oa->o_valid |= OBD_MD_FLMTIME;
+ }
+ if (ia_valid & ATTR_CTIME) {
+ oa->o_ctime = LTIME_S(attr->ia_ctime);
+ oa->o_valid |= OBD_MD_FLCTIME;
+ }
+ if (ia_valid & ATTR_SIZE) {
+ oa->o_size = attr->ia_size;
+ oa->o_valid |= OBD_MD_FLSIZE;
+ }
+ if (ia_valid & ATTR_MODE) {
+ oa->o_mode = attr->ia_mode;
+ oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE;
+ if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
+ oa->o_mode &= ~S_ISGID;
+ }
+ if (ia_valid & ATTR_UID) {
+ oa->o_uid = attr->ia_uid;
+ oa->o_valid |= OBD_MD_FLUID;
+ }
+ if (ia_valid & ATTR_GID) {
+ oa->o_gid = attr->ia_gid;
+ oa->o_valid |= OBD_MD_FLGID;
+ }
+}
+EXPORT_SYMBOL(obdo_from_iattr);
+
+void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid)
+{
+ valid &= oa->o_valid;
+
+ if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
+ CDEBUG(D_INODE, "valid "LPX64", new time "LPU64"/"LPU64"\n",
+ oa->o_valid, oa->o_mtime, oa->o_ctime);
+
+ attr->ia_valid = 0;
+ if (valid & OBD_MD_FLATIME) {
+ LTIME_S(attr->ia_atime) = oa->o_atime;
+ attr->ia_valid |= ATTR_ATIME;
+ }
+ if (valid & OBD_MD_FLMTIME) {
+ LTIME_S(attr->ia_mtime) = oa->o_mtime;
+ attr->ia_valid |= ATTR_MTIME;
+ }
+ if (valid & OBD_MD_FLCTIME) {
+ LTIME_S(attr->ia_ctime) = oa->o_ctime;
+ attr->ia_valid |= ATTR_CTIME;
+ }
+ if (valid & OBD_MD_FLSIZE) {
+ attr->ia_size = oa->o_size;
+ attr->ia_valid |= ATTR_SIZE;
+ }
+#if 0 /* you shouldn't be able to change a file's type with setattr */
+ if (valid & OBD_MD_FLTYPE) {
+ attr->ia_mode = (attr->ia_mode & ~S_IFMT)|(oa->o_mode & S_IFMT);
+ attr->ia_valid |= ATTR_MODE;
+ }
+#endif
+ if (valid & OBD_MD_FLMODE) {
+ attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT);
+ attr->ia_valid |= ATTR_MODE;
+ if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
+ attr->ia_mode &= ~S_ISGID;
+ }
+ if (valid & OBD_MD_FLUID) {
+ attr->ia_uid = oa->o_uid;
+ attr->ia_valid |= ATTR_UID;
+ }
+ if (valid & OBD_MD_FLGID) {
+ attr->ia_gid = oa->o_gid;
+ attr->ia_valid |= ATTR_GID;
+ }
+
+ if (valid & OBD_MD_FLFLAGS) {
+ attr->ia_attr_flags = oa->o_flags;
+ attr->ia_valid |= ATTR_ATTR_FLAG;
+ }
+}
+EXPORT_SYMBOL(iattr_from_obdo);
+
+/* WARNING: the file systems must take care not to tinker with
+ attributes they don't manage (such as blocks). */
+void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
+{
+ obd_flag newvalid = 0;
+
+ if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
+ CDEBUG(D_INODE, "valid %x, new time %lu/%lu\n",
+ valid, LTIME_S(src->i_mtime),
+ LTIME_S(src->i_ctime));
+
+ if (valid & OBD_MD_FLATIME) {
+ dst->o_atime = LTIME_S(src->i_atime);
+ newvalid |= OBD_MD_FLATIME;
+ }
+ if (valid & OBD_MD_FLMTIME) {
+ dst->o_mtime = LTIME_S(src->i_mtime);
+ newvalid |= OBD_MD_FLMTIME;
+ }
+ if (valid & OBD_MD_FLCTIME) {
+ dst->o_ctime = LTIME_S(src->i_ctime);
+ newvalid |= OBD_MD_FLCTIME;
+ }
+ if (valid & OBD_MD_FLSIZE) {
+ dst->o_size = src->i_size;
+ newvalid |= OBD_MD_FLSIZE;
+ }
+ if (valid & OBD_MD_FLBLOCKS) { /* allocation of space (x512 bytes) */
+ dst->o_blocks = src->i_blocks;
+ newvalid |= OBD_MD_FLBLOCKS;
+ }
+ if (valid & OBD_MD_FLBLKSZ) { /* optimal block size */
+ dst->o_blksize = src->i_blksize;
+ newvalid |= OBD_MD_FLBLKSZ;
+ }
+ if (valid & OBD_MD_FLTYPE) {
+ dst->o_mode = (dst->o_mode & S_IALLUGO)|(src->i_mode & S_IFMT);
+ newvalid |= OBD_MD_FLTYPE;
+ }
+ if (valid & OBD_MD_FLMODE) {
+ dst->o_mode = (dst->o_mode & S_IFMT)|(src->i_mode & S_IALLUGO);
+ newvalid |= OBD_MD_FLMODE;
+ }
+ if (valid & OBD_MD_FLUID) {
+ dst->o_uid = src->i_uid;
+ newvalid |= OBD_MD_FLUID;
+ }
+ if (valid & OBD_MD_FLGID) {
+ dst->o_gid = src->i_gid;
+ newvalid |= OBD_MD_FLGID;
+ }
+ if (valid & OBD_MD_FLFLAGS) {
+ dst->o_flags = src->i_flags;
+ newvalid |= OBD_MD_FLFLAGS;
+ }
+ if (valid & OBD_MD_FLGENER) {
+ dst->o_generation = src->i_generation;
+ newvalid |= OBD_MD_FLGENER;
+ }
+ if (valid & OBD_MD_FLFID) {
+ dst->o_fid = src->i_ino;
+ newvalid |= OBD_MD_FLFID;
+ }
+
+ dst->o_valid |= newvalid;
+}
+EXPORT_SYMBOL(obdo_from_inode);
+
+void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid)
+{
+ valid &= src->o_valid;
+
+ if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
+ CDEBUG(D_INODE,
+ "valid "LPX64", cur time %lu/%lu, new "LPU64"/"LPU64"\n",
+ src->o_valid, LTIME_S(dst->i_mtime),
+ LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime);
+
+ if (valid & OBD_MD_FLATIME && src->o_atime > LTIME_S(dst->i_atime))
+ LTIME_S(dst->i_atime) = src->o_atime;
+ if (valid & OBD_MD_FLMTIME && src->o_mtime > LTIME_S(dst->i_mtime))
+ LTIME_S(dst->i_mtime) = src->o_mtime;
+ if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime))
+ LTIME_S(dst->i_ctime) = src->o_ctime;
+ if (valid & OBD_MD_FLSIZE)
+ dst->i_size = src->o_size;
+ /* optimum IO size */
+ if (valid & OBD_MD_FLBLKSZ && src->o_blksize > dst->i_blksize)
+ dst->i_blksize = src->o_blksize;
+ if (dst->i_blksize < PAGE_CACHE_SIZE)
+ dst->i_blksize = PAGE_CACHE_SIZE;
+ /* allocation of space */
+ if (valid & OBD_MD_FLBLOCKS && src->o_blocks > dst->i_blocks)
+ dst->i_blocks = src->o_blocks;
+}
+EXPORT_SYMBOL(obdo_refresh_inode);
+
+void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
+{
+ valid &= src->o_valid;
+
+ if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
+ CDEBUG(D_INODE,
+ "valid "LPX64", cur time %lu/%lu, new "LPU64"/"LPU64"\n",
+ src->o_valid, LTIME_S(dst->i_mtime),
+ LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime);
+
+ if (valid & OBD_MD_FLATIME)
+ LTIME_S(dst->i_atime) = src->o_atime;
+ if (valid & OBD_MD_FLMTIME)
+ LTIME_S(dst->i_mtime) = src->o_mtime;
+ if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime))
+ LTIME_S(dst->i_ctime) = src->o_ctime;
+ if (valid & OBD_MD_FLSIZE)
+ dst->i_size = src->o_size;
+ if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
+ dst->i_blocks = src->o_blocks;
+ if (valid & OBD_MD_FLBLKSZ)
+ dst->i_blksize = src->o_blksize;
+ if (valid & OBD_MD_FLTYPE)
+ dst->i_mode = (dst->i_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
+ if (valid & OBD_MD_FLMODE)
+ dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
+ if (valid & OBD_MD_FLUID)
+ dst->i_uid = src->o_uid;
+ if (valid & OBD_MD_FLGID)
+ dst->i_gid = src->o_gid;
+ if (valid & OBD_MD_FLFLAGS)
+ dst->i_flags = src->o_flags;
+ if (valid & OBD_MD_FLGENER)
+ dst->i_generation = src->o_generation;
+}
+EXPORT_SYMBOL(obdo_to_inode);
+#endif
+
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
+#include <obd_support.h>
struct ctl_table_header *obd_table_header = NULL;
#define EXPORT_SYMTAB
#endif
-#ifdef __KERNEL__
-#include <linux/fs.h>
-#else
+#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
+#include <obd_class.h>
+#include <lustre_log.h>
#include <libcfs/list.h>
/* Allocate a new log or catalog handle */
out:
if (flags & LLOG_F_IS_CAT) {
- INIT_LIST_HEAD(&handle->u.chd.chd_head);
+ CFS_INIT_LIST_HEAD(&handle->u.chd.chd_head);
llh->llh_size = sizeof(struct llog_logid_rec);
} else if (flags & LLOG_F_IS_PLAIN) {
- INIT_LIST_HEAD(&handle->u.phd.phd_entry);
+ CFS_INIT_LIST_HEAD(&handle->u.phd.phd_entry);
} else {
CERROR("Unknown flags: %#x (Expected %#x or %#x\n",
flags, LLOG_F_IS_CAT, LLOG_F_IS_PLAIN);
#define EXPORT_SYMTAB
#endif
-#ifdef __KERNEL__
-#include <linux/fs.h>
-#else
+#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
+#include <obd_class.h>
+#include <lustre_log.h>
#include <libcfs/list.h>
/* Create a new log handle and add it to the open list.
struct llog_handle *llh;
int rc;
+ ENTRY;
if (rec->lrh_type != LLOG_LOGID_MAGIC) {
CERROR("invalid record in catalog\n");
RETURN(-EINVAL);
#define EXPORT_SYMTAB
#endif
-#include <linux/fs.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
+#include <obd_class.h>
+#include <lustre_log.h>
#include <libcfs/list.h>
#include "llog_internal.h"
{
char *start, *end, *endp;
+ ENTRY;
start = str;
if (*start != '#')
RETURN(-EINVAL);
char *endp;
int cur_index, rc = 0;
+ ENTRY;
cur_index = rec->lrh_index;
if (ioc_data && (ioc_data->ioc_inllen1)) {
char *endp;
int cur_index;
+ ENTRY;
if (ioc_data->ioc_inllen1) {
l = 0;
remains = ioc_data->ioc_inllen4 +
struct llog_handle *log;
int rc, index = 0;
+ ENTRY;
down_write(&cat->lgh_lock);
rc = llog_cat_id2handle(cat, &log, logid);
if (rc) {
struct llog_logid_rec *lir = (struct llog_logid_rec*)rec;
int rc;
+ ENTRY;
if (rec->lrh_type != LLOG_LOGID_MAGIC)
- return (-EINVAL);
+ RETURN (-EINVAL);
rc = llog_remove_log(handle, &lir->lid_id);
RETURN(rc);
int err = 0;
struct llog_handle *handle = NULL;
+ ENTRY;
if (*data->ioc_inlbuf1 == '#') {
err = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1);
if (err)
char *out;
int l, remains, rc = 0;
+ ENTRY;
size = sizeof(*idarray) * count;
OBD_ALLOC(idarray, size);
#define EXPORT_SYMTAB
#endif
-#ifdef __KERNEL__
-#include <linux/fs.h>
-#else
+#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/obd.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
-#include <linux/obd_ost.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <lustre_log.h>
+#include <obd_ost.h>
#include <libcfs/list.h>
-#include <linux/lvfs.h>
-#include <linux/lustre_fsfilt.h>
+#include <lvfs.h>
+#include <lustre_fsfilt.h>
#include "llog_internal.h"
-#ifdef __KERNEL__
+#if defined(__KERNEL__) && defined(LLOG_LVFS)
static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file,
int len, int index)
#define EXPORT_SYMTAB
#endif
-#ifdef __KERNEL__
-#include <linux/fs.h>
-#else
+#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
+#include <obd_class.h>
+#include <lustre_log.h>
#include <libcfs/list.h>
#include "llog_internal.h"
#include <liblustre.h>
#endif
-#include <linux/lustre_log.h>
+#include <lustre_log.h>
static void print_llogd_body(struct llogd_body *d)
{
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
-#include <linux/lustre_mds.h> /* for LUSTRE_MDC_NAME */
+#include <obd_class.h>
+#include <lustre_log.h>
+#include <lustre_mds.h> /* for LUSTRE_MDC_NAME */
static int llog_test_rand;
static struct obd_uuid uuid = { .uuid = "test_uuid" };
#endif
#define DEBUG_SUBSYSTEM S_CLASS
-#ifdef __KERNEL__
-# include <linux/config.h>
-# include <linux/module.h>
-# include <linux/version.h>
-# include <linux/slab.h>
-# include <linux/types.h>
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
-# include <asm/statfs.h>
-# endif
-# include <linux/seq_file.h>
-#else /* __KERNEL__ */
+#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lprocfs_status.h>
-#include <linux/lustre_fsfilt.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
+#include <lustre_fsfilt.h>
#if defined(LPROCFS)
for (i = num_private_stats; i < num_stats; i++) {
/* If this LBUGs, it is likely that an obd
* operation was added to struct obd_ops in
- * <linux/obd.h>, and that the corresponding line item
+ * <obd.h>, and that the corresponding line item
* LPROCFS_OBD_OP_INIT(.., .., opname)
* is missing from the list above. */
if (stats->ls_percpu[0]->lp_cntr[i].lc_name == NULL) {
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifdef __KERNEL__
-# include <linux/types.h>
-# include <linux/random.h>
-#else
+#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_handles.h>
+#include <obd_support.h>
+#include <lustre_handles.h>
-static spinlock_t handle_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t handle_lock;
static __u64 handle_base;
#define HANDLE_INCR 7
static struct list_head *handle_hash = NULL;
for (bucket = handle_hash + HANDLE_HASH_SIZE - 1; bucket >= handle_hash;
bucket--)
- INIT_LIST_HEAD(bucket);
+ CFS_INIT_LIST_HEAD(bucket);
get_random_bytes(&handle_base, sizeof(handle_base));
LASSERT(handle_base != 0ULL);
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/init.h>
-# include <linux/list.h>
-#else
+#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_net.h>
-#include <linux/lprocfs_status.h>
+#include <obd.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_lib.h>
+#include <lustre_ha.h>
+#include <lustre_net.h>
+#include <lprocfs_status.h>
struct uuid_nid_data {
struct list_head un_list;
void class_init_uuidlist(void)
{
- INIT_LIST_HEAD(&g_uuid_list);
+ CFS_INIT_LIST_HEAD(&g_uuid_list);
spin_lock_init(&g_uuid_lock);
}
struct list_head *n;
struct uuid_nid_data *data;
- INIT_LIST_HEAD (&deathrow);
+ CFS_INIT_LIST_HEAD (&deathrow);
spin_lock (&g_uuid_lock);
#define DEBUG_SUBSYSTEM S_CLASS
#ifdef __KERNEL__
-#include <linux/kmod.h> /* for request_module() */
-#include <linux/module.h>
-#include <linux/obd_class.h>
-#include <linux/random.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
+#include <obd_class.h>
#else
#include <liblustre.h>
-#include <linux/obd_class.h>
-#include <linux/obd.h>
+#include <obd_class.h>
+#include <obd.h>
#endif
-#include <linux/lustre_log.h>
-#include <linux/lprocfs_status.h>
+#include <lustre_log.h>
+#include <lprocfs_status.h>
#include <libcfs/list.h>
struct obd_device *obd = NULL;
char *typename, *name, *namecopy, *uuid;
int rc, len, cleanup_phase = 0;
+ ENTRY;
if (!LUSTRE_CFG_BUFLEN(lcfg, 1)) {
CERROR("No type passed!\n");
}
cleanup_phase = 3; /* class_release_dev */
- INIT_LIST_HEAD(&obd->obd_exports);
- INIT_LIST_HEAD(&obd->obd_exports_timed);
+ CFS_INIT_LIST_HEAD(&obd->obd_exports);
+ CFS_INIT_LIST_HEAD(&obd->obd_exports_timed);
obd->obd_num_exports = 0;
spin_lock_init(&obd->obd_dev_lock);
spin_lock_init(&obd->obd_osfs_lock);
- obd->obd_osfs_age = jiffies - 1000 * HZ;
+ obd->obd_osfs_age = cfs_time_shift(-1000);
/* XXX belongs in setup not attach */
/* recovery data */
- init_timer(&obd->obd_recovery_timer);
+ cfs_init_timer(&obd->obd_recovery_timer);
spin_lock_init(&obd->obd_processing_task_lock);
- init_waitqueue_head(&obd->obd_next_transno_waitq);
- INIT_LIST_HEAD(&obd->obd_recovery_queue);
- INIT_LIST_HEAD(&obd->obd_delayed_reply_queue);
+ cfs_waitq_init(&obd->obd_next_transno_waitq);
+ CFS_INIT_LIST_HEAD(&obd->obd_recovery_queue);
+ CFS_INIT_LIST_HEAD(&obd->obd_delayed_reply_queue);
spin_lock_init(&obd->obd_uncommitted_replies_lock);
- INIT_LIST_HEAD(&obd->obd_uncommitted_replies);
+ CFS_INIT_LIST_HEAD(&obd->obd_uncommitted_replies);
len = strlen(uuid);
if (len >= sizeof(obd->obd_uuid)) {
RETURN(rc);
}
-LIST_HEAD(lustre_profile_list);
+CFS_LIST_HEAD(lustre_profile_list);
struct lustre_profile *class_get_profile(char * prof)
{
struct lustre_profile *lprof;
+ ENTRY;
list_for_each_entry(lprof, &lustre_profile_list, lp_list) {
if (!strcmp(lprof->lp_profile, prof)) {
RETURN(lprof);
struct lustre_profile *lprof;
int err = 0;
+ ENTRY;
OBD_ALLOC(lprof, sizeof(*lprof));
if (lprof == NULL)
GOTO(out, err = -ENOMEM);
- INIT_LIST_HEAD(&lprof->lp_list);
+ CFS_INIT_LIST_HEAD(&lprof->lp_list);
LASSERT(proflen == (strlen(prof) + 1));
OBD_ALLOC(lprof->lp_profile, proflen);
#ifndef __KERNEL__
#include <liblustre.h>
#else
-#include <linux/module.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_idl.h>
-#endif
-
-#ifdef __KERNEL__
-#include <linux/fs.h>
-#include <linux/pagemap.h> /* for PAGE_CACHE_SIZE */
-
-void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid)
-{
- if (ia_valid & ATTR_ATIME) {
- oa->o_atime = LTIME_S(attr->ia_atime);
- oa->o_valid |= OBD_MD_FLATIME;
- }
- if (ia_valid & ATTR_MTIME) {
- oa->o_mtime = LTIME_S(attr->ia_mtime);
- oa->o_valid |= OBD_MD_FLMTIME;
- }
- if (ia_valid & ATTR_CTIME) {
- oa->o_ctime = LTIME_S(attr->ia_ctime);
- oa->o_valid |= OBD_MD_FLCTIME;
- }
- if (ia_valid & ATTR_SIZE) {
- oa->o_size = attr->ia_size;
- oa->o_valid |= OBD_MD_FLSIZE;
- }
- if (ia_valid & ATTR_MODE) {
- oa->o_mode = attr->ia_mode;
- oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE;
- if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
- oa->o_mode &= ~S_ISGID;
- }
- if (ia_valid & ATTR_UID) {
- oa->o_uid = attr->ia_uid;
- oa->o_valid |= OBD_MD_FLUID;
- }
- if (ia_valid & ATTR_GID) {
- oa->o_gid = attr->ia_gid;
- oa->o_valid |= OBD_MD_FLGID;
- }
-}
-EXPORT_SYMBOL(obdo_from_iattr);
-
-void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid)
-{
- valid &= oa->o_valid;
-
- if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
- CDEBUG(D_INODE, "valid "LPX64", new time "LPU64"/"LPU64"\n",
- oa->o_valid, oa->o_mtime, oa->o_ctime);
-
- attr->ia_valid = 0;
- if (valid & OBD_MD_FLATIME) {
- LTIME_S(attr->ia_atime) = oa->o_atime;
- attr->ia_valid |= ATTR_ATIME;
- }
- if (valid & OBD_MD_FLMTIME) {
- LTIME_S(attr->ia_mtime) = oa->o_mtime;
- attr->ia_valid |= ATTR_MTIME;
- }
- if (valid & OBD_MD_FLCTIME) {
- LTIME_S(attr->ia_ctime) = oa->o_ctime;
- attr->ia_valid |= ATTR_CTIME;
- }
- if (valid & OBD_MD_FLSIZE) {
- attr->ia_size = oa->o_size;
- attr->ia_valid |= ATTR_SIZE;
- }
-#if 0 /* you shouldn't be able to change a file's type with setattr */
- if (valid & OBD_MD_FLTYPE) {
- attr->ia_mode = (attr->ia_mode & ~S_IFMT)|(oa->o_mode & S_IFMT);
- attr->ia_valid |= ATTR_MODE;
- }
-#endif
- if (valid & OBD_MD_FLMODE) {
- attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT);
- attr->ia_valid |= ATTR_MODE;
- if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
- attr->ia_mode &= ~S_ISGID;
- }
- if (valid & OBD_MD_FLUID) {
- attr->ia_uid = oa->o_uid;
- attr->ia_valid |= ATTR_UID;
- }
- if (valid & OBD_MD_FLGID) {
- attr->ia_gid = oa->o_gid;
- attr->ia_valid |= ATTR_GID;
- }
-
- if (valid & OBD_MD_FLFLAGS) {
- attr->ia_attr_flags = oa->o_flags;
- attr->ia_valid |= ATTR_ATTR_FLAG;
- }
-}
-EXPORT_SYMBOL(iattr_from_obdo);
-
-/* WARNING: the file systems must take care not to tinker with
- attributes they don't manage (such as blocks). */
-void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
-{
- obd_flag newvalid = 0;
-
- if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
- CDEBUG(D_INODE, "valid %x, new time %lu/%lu\n",
- valid, LTIME_S(src->i_mtime),
- LTIME_S(src->i_ctime));
-
- if (valid & OBD_MD_FLATIME) {
- dst->o_atime = LTIME_S(src->i_atime);
- newvalid |= OBD_MD_FLATIME;
- }
- if (valid & OBD_MD_FLMTIME) {
- dst->o_mtime = LTIME_S(src->i_mtime);
- newvalid |= OBD_MD_FLMTIME;
- }
- if (valid & OBD_MD_FLCTIME) {
- dst->o_ctime = LTIME_S(src->i_ctime);
- newvalid |= OBD_MD_FLCTIME;
- }
- if (valid & OBD_MD_FLSIZE) {
- dst->o_size = src->i_size;
- newvalid |= OBD_MD_FLSIZE;
- }
- if (valid & OBD_MD_FLBLOCKS) { /* allocation of space (x512 bytes) */
- dst->o_blocks = src->i_blocks;
- newvalid |= OBD_MD_FLBLOCKS;
- }
- if (valid & OBD_MD_FLBLKSZ) { /* optimal block size */
- dst->o_blksize = src->i_blksize;
- newvalid |= OBD_MD_FLBLKSZ;
- }
- if (valid & OBD_MD_FLTYPE) {
- dst->o_mode = (dst->o_mode & S_IALLUGO)|(src->i_mode & S_IFMT);
- newvalid |= OBD_MD_FLTYPE;
- }
- if (valid & OBD_MD_FLMODE) {
- dst->o_mode = (dst->o_mode & S_IFMT)|(src->i_mode & S_IALLUGO);
- newvalid |= OBD_MD_FLMODE;
- }
- if (valid & OBD_MD_FLUID) {
- dst->o_uid = src->i_uid;
- newvalid |= OBD_MD_FLUID;
- }
- if (valid & OBD_MD_FLGID) {
- dst->o_gid = src->i_gid;
- newvalid |= OBD_MD_FLGID;
- }
- if (valid & OBD_MD_FLFLAGS) {
- dst->o_flags = src->i_flags;
- newvalid |= OBD_MD_FLFLAGS;
- }
- if (valid & OBD_MD_FLGENER) {
- dst->o_generation = src->i_generation;
- newvalid |= OBD_MD_FLGENER;
- }
- if (valid & OBD_MD_FLFID) {
- dst->o_fid = src->i_ino;
- newvalid |= OBD_MD_FLFID;
- }
-
- dst->o_valid |= newvalid;
-}
-EXPORT_SYMBOL(obdo_from_inode);
-
-void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid)
-{
- valid &= src->o_valid;
-
- if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
- CDEBUG(D_INODE,
- "valid "LPX64", cur time %lu/%lu, new "LPU64"/"LPU64"\n",
- src->o_valid, LTIME_S(dst->i_mtime),
- LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime);
-
- if (valid & OBD_MD_FLATIME && src->o_atime > LTIME_S(dst->i_atime))
- LTIME_S(dst->i_atime) = src->o_atime;
- if (valid & OBD_MD_FLMTIME && src->o_mtime > LTIME_S(dst->i_mtime))
- LTIME_S(dst->i_mtime) = src->o_mtime;
- if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime))
- LTIME_S(dst->i_ctime) = src->o_ctime;
- if (valid & OBD_MD_FLSIZE)
- dst->i_size = src->o_size;
- /* optimum IO size */
- if (valid & OBD_MD_FLBLKSZ && src->o_blksize > dst->i_blksize)
- dst->i_blksize = src->o_blksize;
- if (dst->i_blksize < PAGE_CACHE_SIZE)
- dst->i_blksize = PAGE_CACHE_SIZE;
- /* allocation of space */
- if (valid & OBD_MD_FLBLOCKS && src->o_blocks > dst->i_blocks)
- dst->i_blocks = src->o_blocks;
-}
-EXPORT_SYMBOL(obdo_refresh_inode);
-
-void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
-{
- valid &= src->o_valid;
-
- if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
- CDEBUG(D_INODE,
- "valid "LPX64", cur time %lu/%lu, new "LPU64"/"LPU64"\n",
- src->o_valid, LTIME_S(dst->i_mtime),
- LTIME_S(dst->i_ctime), src->o_mtime, src->o_ctime);
-
- if (valid & OBD_MD_FLATIME)
- LTIME_S(dst->i_atime) = src->o_atime;
- if (valid & OBD_MD_FLMTIME)
- LTIME_S(dst->i_mtime) = src->o_mtime;
- if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime))
- LTIME_S(dst->i_ctime) = src->o_ctime;
- if (valid & OBD_MD_FLSIZE)
- dst->i_size = src->o_size;
- if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
- dst->i_blocks = src->o_blocks;
- if (valid & OBD_MD_FLBLKSZ)
- dst->i_blksize = src->o_blksize;
- if (valid & OBD_MD_FLTYPE)
- dst->i_mode = (dst->i_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
- if (valid & OBD_MD_FLMODE)
- dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
- if (valid & OBD_MD_FLUID)
- dst->i_uid = src->o_uid;
- if (valid & OBD_MD_FLGID)
- dst->i_gid = src->o_gid;
- if (valid & OBD_MD_FLFLAGS)
- dst->i_flags = src->o_flags;
- if (valid & OBD_MD_FLGENER)
- dst->i_generation = src->o_generation;
-}
-EXPORT_SYMBOL(obdo_to_inode);
+#include <obd_class.h>
+#include <lustre_idl.h>
#endif
void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid)
#endif
#ifndef __KERNEL__
#include <liblustre.h>
-#else
-#include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
-#include <linux/statfs.h>
-#endif
#endif
-#include <linux/lustre_export.h>
-#include <linux/lustre_net.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
+#include <lustre_export.h>
+#include <lustre_net.h>
+#include <obd_support.h>
+#include <obd_class.h>
void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs)
{
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#ifdef __KERNEL__
-# include <linux/ctype.h>
-# include <linux/kernel.h>
-# include <linux/sched.h>
-# include <linux/smp_lock.h>
-#else
+#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/obd_ost.h> /* for LUSTRE_OST_NAME */
-#include <linux/lustre_mds.h> /* for LUSTRE_MDC_NAME */
+#include <obd_support.h>
+#include <obd_class.h>
+#include <obd_ost.h> /* for LUSTRE_OST_NAME */
+#include <lustre_mds.h> /* for LUSTRE_MDC_NAME */
struct uuid {
__u32 time_low;
# define EXPORT_SYMTAB
#endif
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/mm.h>
-#include <linux/highmem.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <linux/sched.h>
-#include <linux/smp_lock.h>
-#include <linux/proc_fs.h>
-#include <linux/init.h>
-#include <asm/unistd.h>
-
#define DEBUG_SUBSYSTEM S_ECHO
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/obd_echo.h>
-#include <linux/lustre_debug.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lprocfs_status.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <obd_echo.h>
+#include <lustre_debug.h>
+#include <lustre_dlm.h>
+#include <lprocfs_status.h>
#define ECHO_INIT_OBJID 0x1000000000000000ULL
#define ECHO_HANDLE_MAGIC 0xabcd0123fedc9876ULL
-#define ECHO_PERSISTENT_PAGES (ECHO_PERSISTENT_SIZE/PAGE_SIZE)
-static struct page *echo_persistent_pages[ECHO_PERSISTENT_PAGES];
+#define ECHO_PERSISTENT_PAGES (ECHO_PERSISTENT_SIZE/CFS_PAGE_SIZE)
+static cfs_page_t *echo_persistent_pages[ECHO_PERSISTENT_PAGES];
enum {
LPROC_ECHO_READ_BYTES = 1,
}
static void
-echo_page_debug_setup(struct page *page, int rw, obd_id id,
+echo_page_debug_setup(cfs_page_t *page, int rw, obd_id id,
__u64 offset, int len)
{
int page_offset = offset & (PAGE_SIZE - 1);
- char *addr = ((char *)kmap(page)) + page_offset;
+ char *addr = ((char *)cfs_kmap(page)) + page_offset;
if (len % OBD_ECHO_BLOCK_SIZE != 0)
CERROR("Unexpected block size %d\n", len);
len -= OBD_ECHO_BLOCK_SIZE;
}
- kunmap(page);
+ cfs_kunmap(page);
}
static int
-echo_page_debug_check(struct page *page, obd_id id,
+echo_page_debug_check(cfs_page_t *page, obd_id id,
__u64 offset, int len)
{
int page_offset = offset & (PAGE_SIZE - 1);
- char *addr = ((char *)kmap(page)) + page_offset;
+ char *addr = ((char *)cfs_kmap(page)) + page_offset;
int rc = 0;
int rc2;
len -= OBD_ECHO_BLOCK_SIZE;
}
- kunmap(page);
+ cfs_kunmap(page);
return (rc);
}
oti->oti_handle = (void *)DESC_PRIV;
for (i = 0; i < objcount; i++, obj++) {
- int gfp_mask = (obj->ioo_id & 1) ? GFP_HIGHUSER : GFP_KERNEL;
+ int gfp_mask = (obj->ioo_id & 1) ? CFS_ALLOC_HIGHUSER : CFS_ALLOC_STD;
int ispersistent = obj->ioo_id == ECHO_PERSISTENT_OBJID;
int debug_setup = (!ispersistent &&
(oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
r->page = echo_persistent_pages[nb->offset >>
PAGE_SHIFT];
/* Take extra ref so __free_pages() can be called OK */
- get_page (r->page);
+ cfs_get_page (r->page);
} else {
- r->page = alloc_pages(gfp_mask, 0);
+ r->page = cfs_alloc_page(gfp_mask);
if (r->page == NULL) {
CERROR("can't get page %u/%u for id "
LPU64"\n",
r->offset = nb->offset;
r->len = nb->len;
- LASSERT((r->offset & ~PAGE_MASK) + r->len <= PAGE_SIZE);
+ LASSERT((r->offset & ~CFS_PAGE_MASK) + r->len <= CFS_PAGE_SIZE);
CDEBUG(D_PAGE, "$$$$ get page %p @ "LPU64" for %d\n",
r->page, r->offset, r->len);
*/
CERROR("cleaning up %ld pages (%d obdos)\n", (long)(r - res), objcount);
while (r-- > res) {
- kunmap(r->page);
+ cfs_kunmap(r->page);
/* NB if this is a persistent page, __free_pages will just
* lose the extra ref gained above */
- __free_pages(r->page, 0);
+ cfs_free_page(r->page);
atomic_dec(&obd->u.echo.eo_prep);
}
memset(res, 0, sizeof(*res) * niocount);
int j;
for (j = 0 ; j < obj->ioo_bufcnt ; j++, r++) {
- struct page *page = r->page;
+ cfs_page_t *page = r->page;
void *addr;
if (page == NULL) {
GOTO(commitrw_cleanup, rc = -EFAULT);
}
- addr = kmap(page);
+ addr = cfs_kmap(page);
CDEBUG(D_PAGE, "$$$$ use page %p, addr %p@"LPU64"\n",
r->page, addr, r->offset);
rc = vrc;
}
- kunmap(page);
+ cfs_kunmap(page);
/* NB see comment above regarding persistent pages */
- __free_pages(page, 0);
+ cfs_free_page(page);
atomic_dec(&obd->u.echo.eo_prep);
}
}
CERROR("cleaning up %ld pages (%d obdos)\n",
niocount - (long)(r - res) - 1, objcount);
while (++r < res + niocount) {
- struct page *page = r->page;
+ cfs_page_t *page = r->page;
/* NB see comment above regarding persistent pages */
- __free_pages(page, 0);
+ cfs_free_page(page);
atomic_dec(&obd->u.echo.eo_prep);
}
return rc;
/* XXX Bug 3413; wait for a bit to ensure the BL callback has
* happened before calling ldlm_namespace_free() */
set_current_state (TASK_UNINTERRUPTIBLE);
- schedule_timeout (HZ);
+ schedule_timeout (cfs_time_seconds(1));
ldlm_namespace_free(obd->obd_namespace, obd->obd_force);
for (i = 0; i < ECHO_PERSISTENT_PAGES; i++)
if (echo_persistent_pages[i] != NULL) {
- __free_pages (echo_persistent_pages[i], 0);
+ cfs_free_page (echo_persistent_pages[i]);
echo_persistent_pages[i] = NULL;
}
}
static int
echo_persistent_pages_init (void)
{
- struct page *pg;
+ cfs_page_t *pg;
int i;
for (i = 0; i < ECHO_PERSISTENT_PAGES; i++) {
int gfp_mask = (i < ECHO_PERSISTENT_PAGES/2) ?
- GFP_KERNEL : GFP_HIGHUSER;
+ CFS_ALLOC_STD : CFS_ALLOC_HIGHUSER;
pg = alloc_pages (gfp_mask, 0);
if (pg == NULL) {
return (-ENOMEM);
}
- memset (kmap (pg), 0, PAGE_SIZE);
- kunmap (pg);
+ memset (cfs_kmap (pg), 0, CFS_PAGE_SIZE);
+ cfs_kunmap (pg);
echo_persistent_pages[i] = pg;
}
printk(KERN_INFO "Lustre: Echo OBD driver; info@clusterfs.com\n");
- LASSERT(PAGE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
+ LASSERT(CFS_PAGE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
lprocfs_init_vars(echo, &lvars);
MODULE_DESCRIPTION("Lustre Testing Echo OBD driver");
MODULE_LICENSE("GPL");
-module_init(obdecho_init);
-module_exit(obdecho_exit);
+cfs_module(obdecho, "1.0.0", obdecho_init, obdecho_exit)
#include <liblustre.h>
#endif
-#include <linux/obd.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/obd_echo.h>
-#include <linux/lustre_debug.h>
-#include <linux/lprocfs_status.h>
+#include <obd.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <obd_echo.h>
+#include <lustre_debug.h>
+#include <lprocfs_status.h>
static obd_id last_object_id;
if (ulsm_nob < nob ||
lsm->lsm_stripe_count > ec->ec_nstripes ||
lsm->lsm_magic != LOV_MAGIC ||
- (lsm->lsm_stripe_size & (PAGE_SIZE - 1)) != 0 ||
+ (lsm->lsm_stripe_size & (CFS_PAGE_SIZE - 1)) != 0 ||
((__u64)lsm->lsm_stripe_size * lsm->lsm_stripe_count > ~0UL))
return (-EINVAL);
lsm->lsm_stripe_count = ec->ec_nstripes;
if (lsm->lsm_stripe_size == 0)
- lsm->lsm_stripe_size = PAGE_SIZE;
+ lsm->lsm_stripe_size = CFS_PAGE_SIZE;
idx = ll_insecure_random_int();
static void
echo_client_page_debug_setup(struct lov_stripe_md *lsm,
- struct page *page, int rw, obd_id id,
+ cfs_page_t *page, int rw, obd_id id,
obd_off offset, obd_off count)
{
char *addr;
int delta;
/* no partial pages on the client */
- LASSERT(count == PAGE_SIZE);
+ LASSERT(count == CFS_PAGE_SIZE);
- addr = kmap(page);
+ addr = cfs_kmap(page);
- for (delta = 0; delta < PAGE_SIZE; delta += OBD_ECHO_BLOCK_SIZE) {
+ for (delta = 0; delta < CFS_PAGE_SIZE; delta += OBD_ECHO_BLOCK_SIZE) {
if (rw == OBD_BRW_WRITE) {
stripe_off = offset + delta;
stripe_id = id;
stripe_off, stripe_id);
}
- kunmap(page);
+ cfs_kunmap(page);
}
static int
echo_client_page_debug_check(struct lov_stripe_md *lsm,
- struct page *page, obd_id id,
+ cfs_page_t *page, obd_id id,
obd_off offset, obd_off count)
{
obd_off stripe_off;
int rc2;
/* no partial pages on the client */
- LASSERT(count == PAGE_SIZE);
+ LASSERT(count == CFS_PAGE_SIZE);
- addr = kmap(page);
+ addr = cfs_kmap(page);
- for (rc = delta = 0; delta < PAGE_SIZE; delta += OBD_ECHO_BLOCK_SIZE) {
+ for (rc = delta = 0; delta < CFS_PAGE_SIZE; delta += OBD_ECHO_BLOCK_SIZE) {
stripe_off = offset + delta;
stripe_id = id;
echo_get_stripe_off_id (lsm, &stripe_off, &stripe_id);
}
}
- kunmap(page);
+ cfs_kunmap(page);
return rc;
}
(oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
(oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
- gfp_mask = ((oa->o_id & 2) == 0) ? GFP_KERNEL : GFP_HIGHUSER;
+ gfp_mask = ((oa->o_id & 2) == 0) ? CFS_ALLOC_STD : CFS_ALLOC_HIGHUSER;
LASSERT(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ);
if (count <= 0 ||
- (count & (PAGE_SIZE - 1)) != 0 ||
+ (count & (CFS_PAGE_SIZE - 1)) != 0 ||
(lsm != NULL &&
lsm->lsm_object_id != oa->o_id))
return (-EINVAL);
/* XXX think again with misaligned I/O */
- npages = count >> PAGE_SHIFT;
+ npages = count >> CFS_PAGE_SHIFT;
OBD_ALLOC(pga, npages * sizeof(*pga));
if (pga == NULL)
for (i = 0, pgp = pga, off = offset;
i < npages;
- i++, pgp++, off += PAGE_SIZE) {
+ i++, pgp++, off += CFS_PAGE_SIZE) {
LASSERT (pgp->pg == NULL); /* for cleanup */
rc = -ENOMEM;
- pgp->pg = alloc_pages (gfp_mask, 0);
+ pgp->pg = cfs_alloc_page (gfp_mask);
if (pgp->pg == NULL)
goto out;
- pgp->count = PAGE_SIZE;
+ pgp->count = CFS_PAGE_SIZE;
pgp->off = off;
pgp->flag = 0;
if (vrc != 0 && rc == 0)
rc = vrc;
}
- __free_pages(pgp->pg, 0);
+ cfs_free_page(pgp->pg);
}
OBD_FREE(pga, npages * sizeof(*pga));
return (rc);
/* NB: for now, only whole pages, page aligned */
if (count <= 0 ||
- ((long)buffer & (PAGE_SIZE - 1)) != 0 ||
- (count & (PAGE_SIZE - 1)) != 0 ||
+ ((long)buffer & (CFS_PAGE_SIZE - 1)) != 0 ||
+ (count & (CFS_PAGE_SIZE - 1)) != 0 ||
(lsm != NULL && lsm->lsm_object_id != oa->o_id))
return (-EINVAL);
/* XXX think again with misaligned I/O */
- npages = count >> PAGE_SHIFT;
+ npages = count >> CFS_PAGE_SHIFT;
OBD_ALLOC(pga, npages * sizeof(*pga));
if (pga == NULL)
for (i = 0, off = offset, pgp = pga;
i < npages;
- i++, off += PAGE_SIZE, pgp++) {
+ i++, off += CFS_PAGE_SIZE, pgp++) {
pgp->off = off;
pgp->pg = kiobuf->maplist[i];
- pgp->count = PAGE_SIZE;
+ pgp->count = CFS_PAGE_SIZE;
pgp->flag = 0;
}
#define EAP_MAGIC 79277927
struct echo_async_page {
int eap_magic;
- struct page *eap_page;
+ cfs_page_t *eap_page;
void *eap_cookie;
obd_off eap_off;
struct echo_async_state *eap_eas;
obd_off eas_end_offset;
int eas_in_flight;
int eas_rc;
- wait_queue_head_t eas_waitq;
+ cfs_waitq_t eas_waitq;
struct list_head eas_avail;
struct obdo eas_oa;
struct lov_stripe_md *eas_lsm;
{
/* our pages are issued with a stable count */
LBUG();
- return PAGE_SIZE;
+ return CFS_PAGE_SIZE;
}
static void ec_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
{
(eas->eas_oa.o_flags & OBD_FL_DEBUG_CHECK) != 0)
echo_client_page_debug_check(eas->eas_lsm, eap->eap_page,
eas->eas_oa.o_id, eap->eap_off,
- PAGE_SIZE);
+ CFS_PAGE_SIZE);
spin_lock_irqsave(&eas->eas_lock, flags);
if (rc && !eas->eas_rc)
eas->eas_rc = rc;
eas->eas_in_flight--;
list_add(&eap->eap_item, &eas->eas_avail);
- wake_up(&eas->eas_waitq);
+ cfs_waitq_signal(&eas->eas_waitq);
spin_unlock_irqrestore(&eas->eas_lock, flags);
}
struct list_head *pos, *n;
int rc = 0;
unsigned long flags;
- LIST_HEAD(pages);
+ CFS_LIST_HEAD(pages);
#if 0
int verify;
int gfp_mask;
LASSERT(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ);
if (count <= 0 ||
- (count & (PAGE_SIZE - 1)) != 0 ||
+ (count & (CFS_PAGE_SIZE - 1)) != 0 ||
(lsm != NULL &&
lsm->lsm_object_id != oa->o_id))
return (-EINVAL);
/* XXX think again with misaligned I/O */
- npages = batching >> PAGE_SHIFT;
+ npages = batching >> CFS_PAGE_SHIFT;
memcpy(&eas.eas_oa, oa, sizeof(*oa));
eas.eas_next_offset = offset;
eas.eas_end_offset = offset + count;
spin_lock_init(&eas.eas_lock);
- init_waitqueue_head(&eas.eas_waitq);
+ cfs_waitq_init(&eas.eas_waitq);
eas.eas_in_flight = 0;
eas.eas_rc = 0;
eas.eas_lsm = lsm;
- INIT_LIST_HEAD(&eas.eas_avail);
+ CFS_INIT_LIST_HEAD(&eas.eas_avail);
/* prepare the group of pages that we're going to be keeping
* in flight */
for (i = 0; i < npages; i++) {
- struct page *page = alloc_page(GFP_KERNEL);
+ cfs_page_t *page = cfs_alloc_page(CFS_ALLOC_STD);
if (page == NULL)
GOTO(out, rc = -ENOMEM);
eap->eap_cookie = NULL;
}
- eas.eas_next_offset += PAGE_SIZE;
+ eas.eas_next_offset += CFS_PAGE_SIZE;
eap->eap_off = eas.eas_next_offset;
rc = obd_prep_async_page(exp, lsm, NULL, eap->eap_page,
(oa->o_flags & OBD_FL_DEBUG_CHECK) != 0)
echo_client_page_debug_setup(lsm, eap->eap_page, rw,
oa->o_id,
- eap->eap_off, PAGE_SIZE);
+ eap->eap_off, CFS_PAGE_SIZE);
/* always asserts urgent, which isn't quite right */
rc = obd_queue_async_io(exp, lsm, NULL, eap->eap_cookie,
- rw, 0, PAGE_SIZE, 0,
+ rw, 0, CFS_PAGE_SIZE, 0,
ASYNC_READY | ASYNC_URGENT |
ASYNC_COUNT_STABLE);
spin_lock_irqsave(&eas.eas_lock, flags);
out:
list_for_each_safe(pos, n, &pages) {
- struct page *page = list_entry(pos, struct page,
+ cfs_page_t *page = list_entry(pos, cfs_page_t,
PAGE_LIST_ENTRY);
list_del(&PAGE_LIST(page));
eap->eap_cookie);
OBD_FREE(eap, sizeof(*eap));
}
- __free_page(page);
+ cfs_free_page(page);
}
RETURN(rc);
int i, ret = 0;
ENTRY;
- if (count <= 0 || (count & (PAGE_SIZE - 1)) != 0 ||
+ if (count <= 0 || (count & (CFS_PAGE_SIZE - 1)) != 0 ||
(lsm != NULL && lsm->lsm_object_id != oa->o_id))
RETURN(-EINVAL);
- npages = batch >> PAGE_SHIFT;
- tot_pages = count >> PAGE_SHIFT;
+ npages = batch >> CFS_PAGE_SHIFT;
+ tot_pages = count >> CFS_PAGE_SHIFT;
OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local));
OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote));
if (tot_pages < npages)
npages = tot_pages;
- for (i = 0; i < npages; i++, off += PAGE_SIZE) {
+ for (i = 0; i < npages; i++, off += CFS_PAGE_SIZE) {
rnb[i].offset = off;
- rnb[i].len = PAGE_SIZE;
+ rnb[i].len = CFS_PAGE_SIZE;
}
/* XXX this can't be the best.. */
GOTO(out, ret);
for (i = 0; i < npages; i++) {
- struct page *page = lnb[i].page;
+ cfs_page_t *page = lnb[i].page;
/* read past eof? */
if (page == NULL && lnb[i].rc == 0)
if (!(mode == LCK_PR || mode == LCK_PW))
return -EINVAL;
- if ((offset & (PAGE_SIZE - 1)) != 0 ||
- (nob & (PAGE_SIZE - 1)) != 0)
+ if ((offset & (CFS_PAGE_SIZE - 1)) != 0 ||
+ (nob & (CFS_PAGE_SIZE - 1)) != 0)
return -EINVAL;
rc = echo_get_object (&eco, obd, oa);
}
spin_lock_init (&ec->ec_lock);
- INIT_LIST_HEAD (&ec->ec_objects);
+ CFS_INIT_LIST_HEAD (&ec->ec_objects);
ec->ec_unique = 0;
rc = obd_connect(&conn, tgt, &echo_uuid, NULL /* obd_connect_data */);
rc = class_connect(conn, src, cluuid);
if (rc == 0) {
exp = class_conn2export(conn);
- INIT_LIST_HEAD(&exp->exp_ec_data.eced_locks);
+ CFS_INIT_LIST_HEAD(&exp->exp_ec_data.eced_locks);
class_export_put(exp);
}
*/
#define DEBUG_SUBSYSTEM S_ECHO
-#include <linux/lprocfs_status.h>
-#include <linux/obd_class.h>
+#include <lprocfs_status.h>
+#include <obd_class.h>
#ifdef LPROCFS
static struct lprocfs_vars lprocfs_obd_vars[] = {
# include <linux/buffer_head.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lprocfs_status.h>
-#include <linux/lustre_log.h>
-#include <linux/lustre_commit_confd.h>
+#include <obd_class.h>
+#include <obd_lov.h>
+#include <lustre_dlm.h>
+#include <lustre_fsfilt.h>
+#include <lprocfs_status.h>
+#include <lustre_log.h>
+#include <lustre_commit_confd.h>
#include <libcfs/list.h>
-#include <linux/lustre_quota.h>
+#include <lustre_quota.h>
#include "filter_internal.h"
obd->obd_recovery_start = CURRENT_SECONDS;
/* Only used for lprocfs_status */
obd->obd_recovery_end = obd->obd_recovery_start +
- OBD_RECOVERY_TIMEOUT / HZ;
+ OBD_RECOVERY_TIMEOUT;
}
out:
LASSERT(count <= OST_NUM_THREADS);
- OBD_ALLOC_GFP(pool, OST_NUM_THREADS * sizeof pool[0], GFP_KERNEL);
+ OBD_ALLOC_GFP(pool, OST_NUM_THREADS * sizeof pool[0], CFS_ALLOC_STD);
if (pool == NULL)
RETURN(-ENOMEM);
obd->obd_recoverable_clients,
(obd->obd_recoverable_clients == 1)
? "client" : "clients",
- (int)(OBD_RECOVERY_TIMEOUT / HZ) / 60,
- (int)(OBD_RECOVERY_TIMEOUT / HZ) % 60,
+ (int)(OBD_RECOVERY_TIMEOUT) / 60,
+ (int)(OBD_RECOVERY_TIMEOUT) % 60,
obd->obd_name);
} else {
LCONSOLE_INFO("OST %s now serving %s with recovery %s.\n",
#ifdef __KERNEL__
# include <linux/spinlock.h>
#endif
-#include <linux/lustre_handles.h>
-#include <linux/lustre_debug.h>
-#include <linux/obd.h>
+#include <lustre_handles.h>
+#include <lustre_debug.h>
+#include <obd.h>
#define FILTER_LAYOUT_VERSION "2"
#include <linux/pagemap.h> // XXX kill me soon
#include <linux/version.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
#include "filter_internal.h"
int *obdfilter_created_scratchpad;
#include <linux/iobuf.h>
#include <linux/locks.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
#include "filter_internal.h"
/* Bug 2254 -- this is better done in ext3_map_inode_page, but this
#define DEBUG_SUBSYSTEM S_FILTER
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_quota.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
+#include <lustre_quota.h>
#include "filter_internal.h"
/* 512byte block min */
#include <linux/version.h>
#include <libcfs/list.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_commit_confd.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
+#include <lustre_commit_confd.h>
#include "filter_internal.h"
#include <linux/version.h>
#include <libcfs/list.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_dlm.h>
+#include <obd_class.h>
+#include <lustre_dlm.h>
#include "filter_internal.h"
#include <linux/pagemap.h> // XXX kill me soon
#include <linux/version.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
#include "filter_internal.h"
/* sanobd setup methods - use a specific mount option */
#define DEBUG_SUBSYSTEM S_CLASS
#include <linux/version.h>
-#include <linux/lprocfs_status.h>
-#include <linux/obd.h>
+#include <lprocfs_status.h>
+#include <obd.h>
#include <linux/seq_file.h>
#include <linux/version.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
#include <asm/statfs.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lprocfs_status.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
#include <linux/seq_file.h>
#include "osc_internal.h"
struct client_obd *cli = &dev->u.cli;
int rc;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
rc = snprintf(page, count, "%d\n", cli->cl_max_pages_per_rpc);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return rc;
}
if (val < 1 || val > PTLRPC_MAX_BRW_PAGES)
return -ERANGE;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
cli->cl_max_pages_per_rpc = val;
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return count;
}
struct client_obd *cli = &dev->u.cli;
int rc;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
rc = snprintf(page, count, "%u\n", cli->cl_max_rpcs_in_flight);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return rc;
}
cli->cl_rq_pool->prp_populate(cli->cl_rq_pool,
val - cli->cl_max_rpcs_in_flight);
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
cli->cl_max_rpcs_in_flight = val;
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return count;
}
struct client_obd *cli = &dev->u.cli;
unsigned val;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
val = cli->cl_dirty_max >> 20;
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return snprintf(page, count, "%u\n", val);
}
val > num_physpages >> (20 - PAGE_SHIFT - 2)) /* 1/4 of RAM */
return -ERANGE;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
cli->cl_dirty_max = (obd_count)val * 1024 * 1024;
osc_wake_cache_waiters(cli);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return count;
}
struct client_obd *cli = &dev->u.cli;
int rc;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
rc = snprintf(page, count, "%lu\n", cli->cl_dirty);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return rc;
}
struct client_obd *cli = &dev->u.cli;
int rc;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
rc = snprintf(page, count, "%lu\n", cli->cl_avail_grant);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return rc;
}
struct timeval now;
struct obd_device *dev = seq->private;
struct client_obd *cli = &dev->u.cli;
- unsigned long flags;
unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
int i;
do_gettimeofday(&now);
- spin_lock_irqsave(&cli->cl_loi_list_lock, flags);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
now.tv_sec, now.tv_usec);
break;
}
- spin_unlock_irqrestore(&cli->cl_loi_list_lock, flags);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
return 0;
}
# include <ctype.h>
#endif
-# include <linux/lustre_dlm.h>
-#include <linux/obd_class.h>
+# include <lustre_dlm.h>
+#include <obd_class.h>
#include "osc_internal.h"
int oscc_recovering(struct osc_creator *oscc)
oscc->oscc_flags &= ~OSCC_FLAG_RECOVERING;
CDEBUG(D_HA, "%s: oscc recovery finished: %d\n",
oscc->oscc_obd->obd_name, rc);
- wake_up(&oscc->oscc_waitq);
+ cfs_waitq_signal(&oscc->oscc_waitq);
} else {
CDEBUG(D_ERROR, "%s: oscc recovery failed: %d\n",
oscc->oscc_obd->obd_name, rc);
oscc->oscc_obd = obd;
spin_lock_init(&oscc->oscc_lock);
oscc->oscc_flags |= OSCC_FLAG_RECOVERING;
- init_waitqueue_head(&oscc->oscc_waitq);
+ cfs_waitq_init(&oscc->oscc_waitq);
}
unsigned long oap_interrupted:1;
struct oig_callback_context oap_occ;
- struct page *oap_page;
+ cfs_page_t *oap_page;
struct obd_io_group *oap_oig;
struct ptlrpc_request *oap_request;
struct client_obd *oap_cli;
struct osc_cache_waiter {
struct list_head ocw_entry;
- wait_queue_head_t ocw_waitq;
+ cfs_waitq_t ocw_waitq;
struct osc_async_page *ocw_oap;
int ocw_rc;
};
#ifdef __KERNEL__
# include <linux/module.h>
-# include <linux/obd.h>
-# include <linux/obd_ost.h>
-# include <linux/lustre_net.h>
-# include <linux/lustre_dlm.h>
-# include <linux/lustre_lib.h>
+# include <obd.h>
+# include <obd_ost.h>
+# include <lustre_net.h>
+# include <lustre_dlm.h>
+# include <lustre_lib.h>
# include <linux/lustre_compat25.h>
/* convert a pathname into a kdev_t */
# include <liblustre.h>
#endif
-# include <linux/lustre_dlm.h>
+# include <lustre_dlm.h>
#include <libcfs/kp30.h>
-#include <linux/lustre_net.h>
+#include <lustre_net.h>
#include <lustre/lustre_user.h>
-#include <linux/obd_ost.h>
-#include <linux/obd_lov.h>
+#include <obd_ost.h>
+#include <obd_lov.h>
#ifdef __CYGWIN__
# include <ctype.h>
#endif
-#include <linux/lustre_ha.h>
-#include <linux/lprocfs_status.h>
-#include <linux/lustre_log.h>
-#include <linux/lustre_debug.h>
+#include <lustre_ha.h>
+#include <lprocfs_status.h>
+#include <lustre_log.h>
+#include <lustre_debug.h>
#include "osc_internal.h"
/* Pack OSC object metadata for disk storage (LE byte order). */
LASSERT(!(oa->o_valid & bits));
oa->o_valid |= bits;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
oa->o_dirty = cli->cl_dirty;
if (cli->cl_dirty > cli->cl_dirty_max) {
CERROR("dirty %lu > dirty_max %lu\n",
oa->o_grant = cli->cl_avail_grant;
oa->o_dropped = cli->cl_lost_grant;
cli->cl_lost_grant = 0;
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
CDEBUG(D_CACHE,"dirty: "LPU64" undirty: %u dropped %u grant: "LPU64"\n",
oa->o_dirty, oa->o_undirty, oa->o_dropped, oa->o_grant);
}
osc_consume_write_grant(cli, ocw->ocw_oap);
}
- wake_up(&ocw->ocw_waitq);
+ cfs_waitq_signal(&ocw->ocw_waitq);
}
EXIT;
static void osc_update_grant(struct client_obd *cli, struct ost_body *body)
{
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
CDEBUG(D_CACHE, "got "LPU64" extra grant\n", body->oa.o_grant);
cli->cl_avail_grant += body->oa.o_grant;
/* waiters are woken in brw_interpret_oap */
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
}
/* We assume that the reason this OSC got a short read is because it read
/* XXX member_of() */
oap = list_entry(occ, struct osc_async_page, oap_occ);
- spin_lock(&oap->oap_cli->cl_loi_list_lock);
+ client_obd_list_lock(&oap->oap_cli->cl_loi_list_lock);
oap->oap_interrupted = 1;
}
unlock:
- spin_unlock(&oap->oap_cli->cl_loi_list_lock);
+ client_obd_list_unlock(&oap->oap_cli->cl_loi_list_lock);
}
/* this is trying to propogate async writeback errors back up to the
cli = aa->aa_cli;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
/* We need to decrement before osc_ap_completion->osc_wake_cache_waiters
* is called so we know whether to go to sync BRWs or wait for more
osc_wake_cache_waiters(cli);
osc_check_rpcs(cli);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
obdo_free(aa->aa_oa);
OBD_FREE(aa->aa_pga, aa->aa_page_count * sizeof(struct brw_page));
loi_list_maint(cli, loi);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
request = osc_build_req(cli, &rpc_list, page_count, cmd);
if (IS_ERR(request)) {
/* this should happen rarely and is pretty bad, it makes the
* pending list not follow the dirty order */
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
list_for_each_safe(pos, tmp, &rpc_list) {
oap = list_entry(pos, struct osc_async_page,
oap_rpc_item);
starting_offset/PAGE_SIZE + 1);
}
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
if (cmd == OBD_BRW_READ)
cli->cl_r_in_flight++;
{
int rc;
ENTRY;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
rc = list_empty(&ocw->ocw_entry) || rpcs_in_flight(cli) == 0;
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
RETURN(rc);
};
* other objects sure might. */
if (cli->cl_w_in_flight) {
list_add_tail(&ocw.ocw_entry, &cli->cl_cache_waiters);
- init_waitqueue_head(&ocw.ocw_waitq);
+ cfs_waitq_init(&ocw.ocw_waitq);
ocw.ocw_oap = oap;
ocw.ocw_rc = 0;
loi_list_maint(cli, loi);
osc_check_rpcs(cli);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
CDEBUG(D_CACHE, "sleeping for cache space\n");
l_wait_event(ocw.ocw_waitq, ocw_granted(cli, &ocw), &lwi);
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
if (!list_empty(&ocw.ocw_entry)) {
list_del(&ocw.ocw_entry);
RETURN(-EINTR);
if (loi == NULL)
loi = &lsm->lsm_oinfo[0];
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
oap->oap_cmd = cmd;
oap->oap_page_off = off;
if (cmd & OBD_BRW_WRITE) {
rc = osc_enter_cache(cli, loi, oap);
if (rc) {
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
RETURN(rc);
}
lop = &loi->loi_write_lop;
cmd);
osc_check_rpcs(cli);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
RETURN(0);
}
lop = &loi->loi_read_lop;
}
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
if (list_empty(&oap->oap_pending_item))
GOTO(out, rc = -EINVAL);
oap->oap_async_flags);
out:
osc_check_rpcs(cli);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
RETURN(rc);
}
if (loi == NULL)
loi = &lsm->lsm_oinfo[0];
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
oap->oap_cmd = cmd;
oap->oap_page_off = off;
LOI_DEBUG(loi, "oap %p page %p on group pending\n", oap, oap->oap_page);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
RETURN(0);
}
if (loi == NULL)
loi = &lsm->lsm_oinfo[0];
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
osc_group_to_pending(cli, loi, &loi->loi_write_lop, OBD_BRW_WRITE);
osc_group_to_pending(cli, loi, &loi->loi_read_lop, OBD_BRW_READ);
osc_check_rpcs(cli);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
RETURN(0);
}
lop = &loi->loi_read_lop;
}
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
if (!list_empty(&oap->oap_rpc_item))
GOTO(out, rc = -EBUSY);
LOI_DEBUG(loi, "oap %p page %p torn down\n", oap, oap->oap_page);
out:
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
RETURN(rc);
}
/* Reset grants */
cli = &obd->u.cli;
- spin_lock(&cli->cl_loi_list_lock);
+ client_obd_list_lock(&cli->cl_loi_list_lock);
cli->cl_avail_grant = 0;
cli->cl_lost_grant = 0;
/* all pages go to failing rpcs due to the invalid import */
osc_check_rpcs(cli);
- spin_unlock(&cli->cl_loi_list_lock);
+ client_obd_list_unlock(&cli->cl_loi_list_lock);
ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
*/
#define DEBUG_SUBSYSTEM S_OST
-#include <linux/obd_class.h>
-#include <linux/lprocfs_status.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
#include <linux/seq_file.h>
#include "ost_internal.h"
#define DEBUG_SUBSYSTEM S_OST
#include <linux/module.h>
-#include <linux/obd_ost.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_export.h>
-#include <linux/lustre_debug.h>
+#include <obd_ost.h>
+#include <lustre_net.h>
+#include <lustre_dlm.h>
+#include <lustre_export.h>
+#include <lustre_debug.h>
#include <linux/init.h>
-#include <linux/lprocfs_status.h>
-#include <linux/lustre_commit_confd.h>
+#include <lprocfs_status.h>
+#include <lustre_commit_confd.h>
#include <libcfs/list.h>
-#include <linux/lustre_quota.h>
+#include <lustre_quota.h>
#include "ost_internal.h"
void oti_init(struct obd_trans_info *oti, struct ptlrpc_request *req)
endif
if MODULES
+
+if LINUX
modulefs_DATA = ptlrpc$(KMODEXT)
+endif #LINUX
+
+if DARWIN
+macos_PROGRAMS := ptlrpc
+
+ptlrpc_SOURCES := \
+ ptlrpc_module.c \
+ client.c \
+ connection.c \
+ events.c \
+ import.c \
+ llog_client.c \
+ llog_net.c \
+ llog_server.c \
+ lproc_ptlrpc.c \
+ niobuf.c \
+ pack_generic.c \
+ pers.c \
+ pinger.c \
+ ptlrpcd.c \
+ recover.c \
+ recov_thread.c \
+ service.c \
+ $(LDLM_COMM_SOURCES)
+
+ptlrpc_CFLAGS := $(EXTRA_KCFLAGS)
+ptlrpc_LDFLAGS := $(EXTRA_KLDFLAGS)
+ptlrpc_LDADD := $(EXTRA_KLIBS)
+
+plist_DATA := Info.plist
+
+#install-data-hook: fix-kext-ownership
+endif # DARWIN
+
endif # MODULES
MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ ldlm_*.c l_lock.c
#include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_import.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_lib.h>
+#include <lustre_ha.h>
+#include <lustre_import.h>
#include "ptlrpc_internal.h"
return NULL;
spin_lock_init(&desc->bd_lock);
- init_waitqueue_head(&desc->bd_waitq);
+ cfs_waitq_init(&desc->bd_waitq);
desc->bd_max_iov = npages;
desc->bd_iov_count = 0;
desc->bd_md_h = LNET_INVALID_HANDLE;
}
void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
- struct page *page, int pageoffset, int len)
+ cfs_page_t *page, int pageoffset, int len)
{
LASSERT(desc->bd_iov_count < desc->bd_max_iov);
LASSERT(page != NULL);
LASSERT(pageoffset >= 0);
LASSERT(len > 0);
- LASSERT(pageoffset + len <= PAGE_SIZE);
+ LASSERT(pageoffset + len <= CFS_PAGE_SIZE);
desc->bd_nob += len;
OBD_ALLOC(req, sizeof(struct ptlrpc_request));
if (!req)
goto out;
- OBD_ALLOC_GFP(msg, size, GFP_KERNEL);
+ OBD_ALLOC_GFP(msg, size, CFS_ALLOC_STD);
if (!msg) {
OBD_FREE(req, sizeof(struct ptlrpc_request));
goto out;
kernel would do exactly this */
spin_lock_init(&pool->prp_lock);
- INIT_LIST_HEAD(&pool->prp_req_list);
+ CFS_INIT_LIST_HEAD(&pool->prp_req_list);
pool->prp_rq_size = msgsize;
pool->prp_populate = populate_pool;
request->rq_reply_portal = imp->imp_client->cli_reply_portal;
spin_lock_init(&request->rq_lock);
- INIT_LIST_HEAD(&request->rq_list);
- INIT_LIST_HEAD(&request->rq_replay_list);
- INIT_LIST_HEAD(&request->rq_set_chain);
- init_waitqueue_head(&request->rq_reply_waitq);
+ CFS_INIT_LIST_HEAD(&request->rq_list);
+ CFS_INIT_LIST_HEAD(&request->rq_replay_list);
+ CFS_INIT_LIST_HEAD(&request->rq_set_chain);
+ cfs_waitq_init(&request->rq_reply_waitq);
request->rq_xid = ptlrpc_next_xid();
atomic_set(&request->rq_refcount, 1);
OBD_ALLOC(set, sizeof *set);
if (!set)
RETURN(NULL);
- INIT_LIST_HEAD(&set->set_requests);
- init_waitqueue_head(&set->set_waitq);
+ CFS_INIT_LIST_HEAD(&set->set_requests);
+ cfs_waitq_init(&set->set_waitq);
set->set_remaining = 0;
spin_lock_init(&set->set_new_req_lock);
- INIT_LIST_HEAD(&set->set_new_requests);
+ CFS_INIT_LIST_HEAD(&set->set_new_requests);
RETURN(set);
}
list_add_tail(&req->rq_list, &imp->imp_sending_list);
spin_unlock_irqrestore(&imp->imp_lock, flags);
- req->rq_reqmsg->status = current->pid;
+ req->rq_reqmsg->status = cfs_curproc_pid();
CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc"
- " %s:%s:%d:"LPU64":%s:%d\n", current->comm,
+ " %s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
}
CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:nid:"
- "opc %s:%s:%d:"LPU64":%s:%d\n", current->comm,
+ "opc %s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
set->set_remaining--;
atomic_dec(&imp->imp_inflight);
- wake_up(&imp->imp_recovery_waitq);
+ cfs_waitq_signal(&imp->imp_recovery_waitq);
}
/* If we hit an error, we want to recover promptly. */
* req times out */
CDEBUG(D_HA, "set %p going to sleep for %d seconds\n",
set, timeout);
- lwi = LWI_TIMEOUT_INTR((timeout ? timeout : 1) * HZ,
+ lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout ? timeout : 1),
ptlrpc_expired_set,
ptlrpc_interrupted_set, set);
rc = l_wait_event(set->set_waitq, ptlrpc_check_set(set), &lwi);
void ptlrpc_unregister_reply (struct ptlrpc_request *request)
{
int rc;
- wait_queue_head_t *wq;
+ cfs_waitq_t *wq;
struct l_wait_info lwi;
LASSERT(!in_interrupt ()); /* might sleep */
for (;;) {
/* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs */
- lwi = LWI_TIMEOUT(300 * HZ, NULL, NULL);
+ lwi = LWI_TIMEOUT(cfs_time_seconds(300), NULL, NULL);
rc = l_wait_event (*wq, !ptlrpc_client_receiving_reply(request), &lwi);
if (rc == 0)
return;
struct l_wait_info lwi;
struct obd_import *imp = req->rq_import;
unsigned long flags;
- int timeout = 0;
+ cfs_duration_t timeout = 0;
ENTRY;
LASSERT(req->rq_set == NULL);
atomic_inc(&imp->imp_inflight);
/* for distributed debugging */
- req->rq_reqmsg->status = current->pid;
+ req->rq_reqmsg->status = cfs_curproc_pid();
LASSERT(imp->imp_obd != NULL);
CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc "
- "%s:%s:%d:"LPU64":%s:%d\n", current->comm,
+ "%s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
imp->imp_obd->obd_uuid.uuid,
req->rq_reqmsg->status, req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
spin_unlock_irqrestore(&imp->imp_lock, flags);
DEBUG_REQ(D_HA, req, "\"%s\" waiting for recovery: (%s != %s)",
- current->comm,
+ cfs_curproc_comm(),
ptlrpc_import_state_name(req->rq_send_state),
ptlrpc_import_state_name(imp->imp_state));
lwi = LWI_INTR(interrupted_request, req);
req->rq_err || req->rq_intr),
&lwi);
DEBUG_REQ(D_HA, req, "\"%s\" awake: (%s == %s or %d/%d == 1)",
- current->comm,
+ cfs_curproc_comm(),
ptlrpc_import_state_name(imp->imp_state),
ptlrpc_import_state_name(req->rq_send_state),
req->rq_err, req->rq_intr);
rc = ptl_send_rpc(req);
if (rc) {
DEBUG_REQ(D_HA, req, "send failed (%d); recovering", rc);
- timeout = 1;
+ timeout = cfs_time_minimal_timeout();
} else {
- timeout = MAX(req->rq_timeout * HZ, 1);
- DEBUG_REQ(D_NET, req, "-- sleeping for %d jiffies", timeout);
+ timeout = cfs_timeout_cap(cfs_time_seconds(req->rq_timeout));
+ DEBUG_REQ(D_NET, req,
+ "-- sleeping for "CFS_DURATION_T" jiffies", timeout);
}
lwi = LWI_TIMEOUT_INTR(timeout, expired_request, interrupted_request,
req);
DEBUG_REQ(D_NET, req, "-- done sleeping");
CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:nid:opc "
- "%s:%s:%d:"LPU64":%s:%d\n", current->comm,
+ "%s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
imp->imp_obd->obd_uuid.uuid,
req->rq_reqmsg->status, req->rq_xid,
libcfs_nid2str(imp->imp_connection->c_peer.nid),
req->rq_phase = RQ_PHASE_INTERPRET;
atomic_dec(&imp->imp_inflight);
- wake_up(&imp->imp_recovery_waitq);
+ cfs_waitq_signal(&imp->imp_recovery_waitq);
RETURN(rc);
}
}
static __u64 ptlrpc_last_xid = 0;
-static spinlock_t ptlrpc_last_xid_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t ptlrpc_last_xid_lock;
__u64 ptlrpc_next_xid(void)
{
#define DEBUG_SUBSYSTEM S_RPC
#ifdef __KERNEL__
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_net.h>
#else
#include <liblustre.h>
#endif
void ptlrpc_init_connection(void)
{
- INIT_LIST_HEAD(&conn_list);
- INIT_LIST_HEAD(&conn_unused_list);
- conn_lock = SPIN_LOCK_UNLOCKED;
+ CFS_INIT_LIST_HEAD(&conn_list);
+ CFS_INIT_LIST_HEAD(&conn_unused_list);
+ spin_lock_init(&conn_lock);
}
void ptlrpc_cleanup_connection(void)
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
-#include <linux/module.h>
-#else
+#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
+#include <obd_class.h>
+#include <lustre_net.h>
#include "ptlrpc_internal.h"
lnet_handle_eq_t ptlrpc_eq_h;
/* We moaned above already... */
return;
}
- OBD_ALLOC_GFP(req, sizeof(*req), GFP_ATOMIC);
+ OBD_ALLOC_GFP(req, sizeof(*req), CFS_ALLOC_ATOMIC_TRY);
if (req == NULL) {
CERROR("Can't allocate incoming request descriptor: "
"Dropping %s RPC from %s\n",
/* NB everything can disappear under us once the request
* has been queued and we unlock, so do the wake now... */
- wake_up(&service->srv_waitq);
+ cfs_waitq_signal(&service->srv_waitq);
spin_unlock_irqrestore(&service->srv_lock, flags);
EXIT;
if (ev->unlinked) {
/* This is the last callback no matter what... */
desc->bd_network_rw = 0;
- wake_up(&desc->bd_waitq);
+ cfs_waitq_signal(&desc->bd_waitq);
}
spin_unlock_irqrestore (&desc->bd_lock, flags);
void ptlrpc_ni_fini(void)
{
- wait_queue_head_t waitq;
+ cfs_waitq_t waitq;
struct l_wait_info lwi;
int rc;
int retries;
CWARN("Event queue still busy\n");
/* Wait for a bit */
- init_waitqueue_head(&waitq);
- lwi = LWI_TIMEOUT(2*HZ, NULL, NULL);
+ cfs_waitq_init(&waitq);
+ lwi = LWI_TIMEOUT(cfs_time_seconds(2), NULL, NULL);
l_wait_event(waitq, 0, &lwi);
break;
}
}
#ifndef __KERNEL__
-LIST_HEAD(liblustre_wait_callbacks);
+CFS_LIST_HEAD(liblustre_wait_callbacks);
void *liblustre_services_callback;
void *
*/
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
-# include <linux/config.h>
-# include <linux/module.h>
-# include <linux/kmod.h>
-#else
+#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_import.h>
-#include <linux/lustre_export.h>
-#include <linux/obd.h>
-#include <linux/obd_class.h>
+#include <obd_support.h>
+#include <lustre_ha.h>
+#include <lustre_net.h>
+#include <lustre_import.h>
+#include <lustre_export.h>
+#include <obd.h>
+#include <obd_class.h>
#include "ptlrpc_internal.h"
LASSERT(imp->imp_invalid);
/* wait for all requests to error out and call completion callbacks */
- lwi = LWI_TIMEOUT_INTR(MAX(obd_timeout * HZ, 1), NULL,
- NULL, NULL);
+ lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(cfs_time_seconds(obd_timeout)),
+ NULL, NULL, NULL);
rc = l_wait_event(imp->imp_recovery_waitq,
(atomic_read(&imp->imp_inflight) == 0),
&lwi);
(char *)imp->imp_connection->c_remote_uuid.uuid, rc);
}
- wake_up(&imp->imp_recovery_waitq);
+ cfs_waitq_signal(&imp->imp_recovery_waitq);
RETURN(rc);
}
static int ptlrpc_invalidate_import_thread(void *data)
{
struct obd_import *imp = data;
- unsigned long flags;
ENTRY;
lock_kernel();
ptlrpc_daemonize();
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
- THREAD_NAME(current->comm, sizeof(current->comm), "ll_imp_inval");
+ cfs_block_allsigs();
+ THREAD_NAME(cfs_curproc_comm(), CFS_CURPROC_COMM_MAX - 1, "ll_imp_inval");
unlock_kernel();
CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n",
imp->imp_connection->c_remote_uuid.uuid);
#ifdef __KERNEL__
- rc = kernel_thread(ptlrpc_invalidate_import_thread, imp,
+ rc = cfs_kernel_thread(ptlrpc_invalidate_import_thread, imp,
CLONE_VM | CLONE_FILES);
if (rc < 0)
CERROR("error starting invalidate thread: %d\n", rc);
}
if (imp->imp_state == LUSTRE_IMP_FULL) {
- wake_up(&imp->imp_recovery_waitq);
+ cfs_waitq_signal(&imp->imp_recovery_waitq);
ptlrpc_wake_delayed(imp);
}
if (ptlrpc_import_in_recovery(imp)) {
struct l_wait_info lwi;
- lwi = LWI_TIMEOUT_INTR(MAX(obd_timeout * HZ, 1), back_to_sleep,
- NULL, NULL);
+ lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(cfs_time_seconds(obd_timeout)),
+ back_to_sleep, NULL, NULL);
rc = l_wait_event(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp), &lwi);
#endif
#ifdef __KERNEL__
-#include <linux/fs.h>
+#include <libcfs/libcfs.h>
#else
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
-#include <linux/lustre_net.h>
+#include <obd_class.h>
+#include <lustre_log.h>
+#include <lustre_net.h>
#include <libcfs/list.h>
/* This is a callback from the llog_* functions.
#endif
#ifdef __KERNEL__
-#include <linux/fs.h>
+#include <libcfs/libcfs.h>
#else
#include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
+#include <obd_class.h>
+#include <lustre_log.h>
#include <libcfs/list.h>
-#include <linux/lvfs.h>
+#include <lvfs.h>
#ifdef __KERNEL__
int llog_origin_connect(struct llog_ctxt *ctxt, int count,
#include <linux/fs.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_log.h>
-#include <linux/lustre_net.h>
+#include <obd_class.h>
+#include <lustre_log.h>
+#include <lustre_net.h>
#include <libcfs/list.h>
-#include <linux/lustre_fsfilt.h>
+#include <lustre_fsfilt.h>
-#ifdef __KERNEL__
+#if defined(__KERNEL__) && defined(LUSTRE_LOG_SERVER)
int llog_origin_handle_create(struct ptlrpc_request *req)
{
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd.h>
-#include <linux/lprocfs_status.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_net.h>
-#include <linux/obd_class.h>
-#include <linux/seq_file.h>
+#include <obd_support.h>
+#include <obd.h>
+#include <lprocfs_status.h>
+#include <lustre_idl.h>
+#include <lustre_net.h>
+#include <obd_class.h>
#include "ptlrpc_internal.h"
#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_lib.h>
-#include <linux/obd.h>
+#include <obd_support.h>
+#include <lustre_net.h>
+#include <lustre_lib.h>
+#include <obd.h>
#include "ptlrpc_internal.h"
static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len,
for (;;) {
/* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs */
- lwi = LWI_TIMEOUT (300 * HZ, NULL, NULL);
+ lwi = LWI_TIMEOUT (cfs_time_seconds(300), NULL, NULL);
rc = l_wait_event(desc->bd_waitq,
!ptlrpc_bulk_active(desc), &lwi);
if (rc == 0)
/* Disconnect a bulk desc from the network. Idempotent. Not
* thread-safe (i.e. only interlocks with completion callback). */
struct ptlrpc_bulk_desc *desc = req->rq_bulk;
- wait_queue_head_t *wq;
+ cfs_waitq_t *wq;
struct l_wait_info lwi;
int rc;
# include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_net.h>
#define HDR_SIZE(count) \
#if RS_DEBUG
LIST_HEAD(ptlrpc_rs_debug_lru);
-spinlock_t ptlrpc_rs_debug_lock = SPIN_LOCK_UNLOCKED;
+spinlock_t ptlrpc_rs_debug_lock;
#define PTLRPC_RS_DEBUG_LRU_ADD(rs) \
do { \
rs->rs_cb_id.cbid_arg = rs;
rs->rs_service = req->rq_rqbd->rqbd_service;
rs->rs_size = size;
- INIT_LIST_HEAD(&rs->rs_exp_list);
- INIT_LIST_HEAD(&rs->rs_obd_list);
+ CFS_INIT_LIST_HEAD(&rs->rs_exp_list);
+ CFS_INIT_LIST_HEAD(&rs->rs_obd_list);
req->rq_replen = msg_len;
req->rq_reply_state = rs;
list_add(&rs->rs_list,
&svc->srv_free_rs_list);
spin_unlock_irqrestore(&svc->srv_lock, flags);
- wake_up(&svc->srv_free_rs_waitq);
+ cfs_waitq_signal(&svc->srv_free_rs_waitq);
} else {
OBD_FREE(rs, rs->rs_size);
}
#include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_import.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_lib.h>
+#include <lustre_ha.h>
+#include <lustre_import.h>
#include "ptlrpc_internal.h"
md->length = desc->bd_iov_count;
}
-void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, struct page *page,
+void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, cfs_page_t *page,
int pageoffset, int len)
{
lnet_kiov_t *kiov = &desc->bd_iov[desc->bd_iov_count];
return 0;
}
-void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, struct page *page,
+void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, cfs_page_t *page,
int pageoffset, int len)
{
lnet_md_iovec_t *iov = &desc->bd_iov[desc->bd_iov_count];
#define DEBUG_SUBSYSTEM S_RPC
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
+#include <obd_support.h>
+#include <obd_class.h>
#include "ptlrpc_internal.h"
-static DECLARE_MUTEX(pinger_sem);
-static struct list_head pinger_imports = LIST_HEAD_INIT(pinger_imports);
+struct semaphore pinger_sem;
+static struct list_head pinger_imports = CFS_LIST_HEAD_INIT(pinger_imports);
int ptlrpc_ping(struct obd_import *imp)
{
spin_lock(&obd->obd_osfs_lock);
obd->obd_osfs = *msfs;
- obd->obd_osfs_age = jiffies;
+ obd->obd_osfs_age = cfs_time_current();
spin_unlock(&obd->obd_osfs_lock);
RETURN(0);
static void ptlrpc_update_next_ping(struct obd_import *imp)
{
- __u32 interval;
+ cfs_duration_t interval;
interval = IMP_CROW_ABLE(imp) ?
STATFS_INTERVAL : PING_INTERVAL;
- imp->imp_next_ping = jiffies + HZ *
- (imp->imp_state == LUSTRE_IMP_DISCON ? 10 : interval);
+ imp->imp_next_ping = cfs_time_shift(cfs_time_seconds(
+ (imp->imp_state == LUSTRE_IMP_DISCON ? 10 : interval)));
}
void ptlrpc_ping_import_soon(struct obd_import *imp)
{
- imp->imp_next_ping = jiffies;
+ imp->imp_next_ping = cfs_time_current();
}
#ifdef __KERNEL__
{
struct ptlrpc_svc_data *data = (struct ptlrpc_svc_data *)arg;
struct ptlrpc_thread *thread = data->thread;
- unsigned long flags;
ENTRY;
lock_kernel();
ptlrpc_daemonize();
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_block_allsigs();
LASSERTF(strlen(data->name) < sizeof(current->comm),
"name %d > len %d\n",
/* Record that the thread is running */
thread->t_flags = SVC_RUNNING;
- wake_up(&thread->t_ctl_waitq);
+ cfs_waitq_signal(&thread->t_ctl_waitq);
/* And now, loop forever, pinging as needed. */
while (1) {
unsigned long sleep_interval = PING_INTERVAL;
unsigned long update_interval = 0;
- unsigned long this_ping = jiffies;
+ cfs_time_t this_ping = cfs_time_current();
struct l_wait_info lwi;
- long time_to_next_ping;
+ cfs_duration_t time_to_next_ping;
struct list_head *iter;
down(&pinger_sem);
if (force ||
/* if the next ping is within, say, 5 jiffies from
now, go ahead and ping. See note below. */
- time_after_eq(this_ping, imp->imp_next_ping - 5)) {
+ cfs_time_aftereq(this_ping,
+ imp->imp_next_ping - 5 * CFS_MIN_DELAY)) {
if (level == LUSTRE_IMP_DISCON &&
!imp->imp_deactive) {
/* wait at least a timeout before
trying recovery again. */
- imp->imp_next_ping = jiffies +
- obd_timeout * HZ;
+ imp->imp_next_ping = cfs_time_shift(obd_timeout);
ptlrpc_initiate_recovery(imp);
} else if (level != LUSTRE_IMP_FULL ||
imp->imp_obd->obd_no_recov ||
if (!imp->imp_pingable)
continue;
CDEBUG(D_INFO,
- "don't need to ping %s (%lu > %lu)\n",
+ "don't need to ping %s ("CFS_TIME_T
+ " > "CFS_TIME_T")\n",
imp->imp_target_uuid.uuid,
imp->imp_next_ping, this_ping);
}
STATFS_INTERVAL : PING_INTERVAL;
/* obd_timeout might have changed */
- if (time_after(imp->imp_next_ping,
- this_ping + update_interval * HZ))
+ if (cfs_time_after(imp->imp_next_ping,
+ cfs_time_add(this_ping,
+ cfs_time_seconds(update_interval))))
ptlrpc_update_next_ping(imp);
}
up(&pinger_sem);
* sleep here smaller interval of two possible (ping or
* statfs). If one of imports is CROW capable we'll sleep
* STATFS_INTERVAL and PING_INTERVAL otherwise. */
- time_to_next_ping = this_ping + (sleep_interval * HZ) - jiffies;
+ time_to_next_ping = cfs_time_sub(cfs_time_add(this_ping,
+ cfs_time_seconds(sleep_interval)),
+ cfs_time_current());
/* The ping sent by ptlrpc_send_rpc may get sent out
say .01 second after this.
next ping time to next_ping + .01 sec, which means
we will SKIP the next ping at next_ping, and the
ping will get sent 2 timeouts from now! Beware. */
- CDEBUG(D_INFO, "next ping in %lu (%lu)\n", time_to_next_ping,
- this_ping + sleep_interval * HZ);
+ CDEBUG(D_INFO, "next ping in "CFS_DURATION_T" ("CFS_TIME_T")\n",
+ time_to_next_ping,
+ cfs_time_add(this_ping, cfs_time_seconds(sleep_interval)));
if (time_to_next_ping > 0) {
- lwi = LWI_TIMEOUT(max_t(long, time_to_next_ping, HZ),
+ lwi = LWI_TIMEOUT(max_t(cfs_duration_t, time_to_next_ping, cfs_time_seconds(1)),
NULL, NULL);
l_wait_event(thread->t_ctl_waitq,
thread->t_flags & (SVC_STOPPING|SVC_EVENT),
}
thread->t_flags = SVC_STOPPED;
- wake_up(&thread->t_ctl_waitq);
+ cfs_waitq_signal(&thread->t_ctl_waitq);
CDEBUG(D_NET, "pinger thread exiting, process %d\n", current->pid);
return 0;
RETURN(-EALREADY);
down(&pinger_sem);
pinger_thread->t_flags = SVC_STOPPING;
- wake_up(&pinger_thread->t_ctl_waitq);
+ cfs_waitq_signal(&pinger_thread->t_ctl_waitq);
up(&pinger_sem);
l_wait_event(pinger_thread->t_ctl_waitq,
{
#ifdef ENABLE_PINGER
pinger_thread->t_flags |= SVC_EVENT;
- wake_up(&pinger_thread->t_ctl_waitq);
+ cfs_waitq_signal(&pinger_thread->t_ctl_waitq);
#endif
}
static struct pinger_data {
int pd_recursion;
- unsigned long pd_this_ping; /* jiffies */
- unsigned long pd_next_ping; /* jiffies */
+ cfs_time_t pd_this_ping; /* jiffies */
+ cfs_time_t pd_next_ping; /* jiffies */
struct ptlrpc_request_set *pd_set;
} pinger_args;
static int pinger_check_rpcs(void *arg)
{
- unsigned long curtime = jiffies;
+ cfs_time_t curtime = cfs_time_current();
struct ptlrpc_request *req;
struct ptlrpc_request_set *set;
struct list_head *iter;
int generation, level;
unsigned long flags;
- if (time_after_eq(pd->pd_this_ping, imp->imp_next_ping - 5)) {
+ if (cfs_time_aftereq(pd->pd_this_ping,
+ imp->imp_next_ping - 5 * CFS_MIN_DELAY)) {
/* Add a ping. */
spin_lock_irqsave(&imp->imp_lock, flags);
generation = imp->imp_generation;
req->rq_import_generation = generation;
ptlrpc_set_add_req(set, req);
} else {
- CDEBUG(D_HA, "don't need to ping %s (%lu > "
- "%lu)\n", imp->imp_target_uuid.uuid,
+ CDEBUG(D_HA, "don't need to ping %s ("CFS_TIME_T" > "
+ CFS_TIME_T")\n", imp->imp_target_uuid.uuid,
imp->imp_next_ping, pd->pd_this_ping);
}
}
rc = ptlrpc_check_set(set);
/* not finished, and we are not expired, simply return */
- if (!rc && time_before(curtime, pd->pd_this_ping + PING_INTERVAL * HZ)) {
+ if (!rc && cfs_time_before(curtime,
+ cfs_time_add(pd->pd_this_ping,
+ cfs_time_seconds(PING_INTERVAL)))) {
CDEBUG(D_HA, "not finished, but also not expired\n");
pd->pd_recursion--;
return 0;
pd->pd_set = NULL;
out:
- pd->pd_next_ping = pd->pd_this_ping + PING_INTERVAL * HZ;
+ pd->pd_next_ping = cfs_time_add(pd->pd_this_ping,
+ cfs_time_seconds(PING_INTERVAL));
pd->pd_this_ping = 0; /* XXX for debug */
CDEBUG(D_HA, "finished a round ping\n");
ptlrpc_update_next_ping(imp);
if (pinger_args.pd_set == NULL &&
time_before(imp->imp_next_ping, pinger_args.pd_next_ping)) {
- CDEBUG(D_HA, "set next ping to %ld(cur %ld)\n",
- imp->imp_next_ping, jiffies);
+ CDEBUG(D_HA, "set next ping to "CFS_TIME_T"(cur "CFS_TIME_T")\n",
+ imp->imp_next_ping, cfs_time_current());
pinger_args.pd_next_ping = imp->imp_next_ping;
}
up(&pinger_sem);
/* pers.c */
void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc);
-void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, struct page *page,
+void ptlrpc_add_bulk_page(struct ptlrpc_bulk_desc *desc, cfs_page_t *page,
int pageoffset, int len);
/* pinger.c */
#endif
#define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/init.h>
-#else
+#ifndef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_net.h>
#include "ptlrpc_internal.h"
+extern spinlock_t ptlrpc_last_xid_lock;
+extern spinlock_t ptlrpc_rs_debug_lock;
+extern spinlock_t ptlrpc_all_services_lock;
+extern struct semaphore pinger_sem;
+extern struct semaphore ptlrpcd_sem;
extern int ptlrpc_init_portals(void);
extern void ptlrpc_exit_portals(void);
ENTRY;
lustre_assert_wire_constants();
+ spin_lock_init(&ptlrpc_last_xid_lock);
+ spin_lock_init(&ptlrpc_rs_debug_lock);
+ spin_lock_init(&ptlrpc_all_services_lock);
+ init_mutex(&pinger_sem);
+ init_mutex(&ptlrpcd_sem);
rc = ptlrpc_init_portals();
if (rc)
MODULE_DESCRIPTION("Lustre Request Processor and Lock Management");
MODULE_LICENSE("GPL");
-module_init(ptlrpc_init);
-module_exit(ptlrpc_exit);
+cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit);
#endif
#define DEBUG_SUBSYSTEM S_RPC
#ifdef __KERNEL__
-# include <linux/version.h>
-# include <linux/module.h>
-# include <linux/mm.h>
-# include <linux/highmem.h>
-# include <linux/lustre_dlm.h>
-# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
-# include <linux/workqueue.h>
-# include <linux/smp_lock.h>
-# else
-# include <linux/locks.h>
-# endif
-# include <linux/ctype.h>
-# include <linux/init.h>
+# include <libcfs/libcfs.h>
#else /* __KERNEL__ */
# include <liblustre.h>
# include <ctype.h>
#endif
#include <libcfs/kp30.h>
-#include <linux/lustre_net.h>
+#include <lustre_net.h>
+# include <lustre_lib.h>
-#include <linux/lustre_ha.h>
-#include <linux/obd_support.h> /* for OBD_FAIL_CHECK */
-#include <linux/lprocfs_status.h>
+#include <lustre_ha.h>
+#include <obd_support.h> /* for OBD_FAIL_CHECK */
+#include <lprocfs_status.h>
#define LIOD_STOP 0
struct ptlrpcd_ctl {
struct completion pc_starting;
struct completion pc_finishing;
struct list_head pc_req_list;
- wait_queue_head_t pc_waitq;
+ cfs_waitq_t pc_waitq;
struct ptlrpc_request_set *pc_set;
char pc_name[16];
#ifndef __KERNEL__
static struct ptlrpcd_ctl ptlrpcd_pc;
static struct ptlrpcd_ctl ptlrpcd_recovery_pc;
-static DECLARE_MUTEX(ptlrpcd_sem);
+struct semaphore ptlrpcd_sem;
static int ptlrpcd_users = 0;
void ptlrpcd_wake(struct ptlrpc_request *req)
LASSERT(pc != NULL);
- wake_up(&pc->pc_waitq);
+ cfs_waitq_signal(&pc->pc_waitq);
}
void ptlrpcd_add_req(struct ptlrpc_request *req)
static int ptlrpcd(void *arg)
{
struct ptlrpcd_ctl *pc = arg;
- unsigned long flags;
ENTRY;
- libcfs_daemonize(pc->pc_name);
-
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_daemonize(pc->pc_name);
+ cfs_block_allsigs();
complete(&pc->pc_starting);
* on the set's new_req_list and ptlrpcd_check moves them into
* the set. */
while (1) {
- wait_queue_t set_wait;
+ cfs_waitlink_t set_wait;
struct l_wait_info lwi;
- int timeout;
+ cfs_duration_t timeout;
- timeout = ptlrpc_set_next_timeout(pc->pc_set) * HZ;
+ timeout = cfs_time_seconds(ptlrpc_set_next_timeout(pc->pc_set));
lwi = LWI_TIMEOUT(timeout, ptlrpc_expired_set, pc->pc_set);
/* ala the pinger, wait on pc's waitqueue and the set's */
- init_waitqueue_entry(&set_wait, current);
- add_wait_queue(&pc->pc_set->set_waitq, &set_wait);
+ cfs_waitlink_init(&set_wait);
+ cfs_waitq_add(&pc->pc_set->set_waitq, &set_wait);
+ cfs_waitq_forward(&set_wait, &pc->pc_waitq);
l_wait_event(pc->pc_waitq, ptlrpcd_check(pc), &lwi);
- remove_wait_queue(&pc->pc_set->set_waitq, &set_wait);
+ cfs_waitq_del(&pc->pc_set->set_waitq, &set_wait);
if (test_bit(LIOD_STOP, &pc->pc_flags))
break;
memset(pc, 0, sizeof(*pc));
init_completion(&pc->pc_starting);
init_completion(&pc->pc_finishing);
- init_waitqueue_head(&pc->pc_waitq);
+ cfs_waitq_init(&pc->pc_waitq);
pc->pc_flags = 0;
spin_lock_init(&pc->pc_lock);
- INIT_LIST_HEAD(&pc->pc_req_list);
+ CFS_INIT_LIST_HEAD(&pc->pc_req_list);
snprintf (pc->pc_name, sizeof (pc->pc_name), name);
pc->pc_set = ptlrpc_prep_set();
GOTO(out, rc = -ENOMEM);
#ifdef __KERNEL__
- if (kernel_thread(ptlrpcd, pc, 0) < 0) {
+ if (cfs_kernel_thread(ptlrpcd, pc, 0) < 0) {
ptlrpc_set_destroy(pc->pc_set);
GOTO(out, rc = -ECHILD);
}
static void ptlrpcd_stop(struct ptlrpcd_ctl *pc)
{
set_bit(LIOD_STOP, &pc->pc_flags);
- wake_up(&pc->pc_waitq);
+ cfs_waitq_signal(&pc->pc_waitq);
#ifdef __KERNEL__
wait_for_completion(&pc->pc_finishing);
#else
#endif
#ifdef __KERNEL__
-#include <linux/fs.h>
+# include <libcfs/libcfs.h>
#else
# include <libcfs/list.h>
# include <liblustre.h>
#endif
#include <libcfs/kp30.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_commit_confd.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
+#include <obd_class.h>
+#include <lustre_commit_confd.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_net.h>
#include <lnet/types.h>
#include <libcfs/list.h>
-#include <linux/lustre_log.h>
+#include <lustre_log.h>
#include "ptlrpc_internal.h"
#ifdef __KERNEL__
list_add_tail(&llcd->llcd_list, &llcd->llcd_lcm->lcm_llcd_pending);
spin_unlock(&llcd->llcd_lcm->lcm_llcd_lock);
- wake_up_nr(&llcd->llcd_lcm->lcm_waitq, 1);
+ cfs_waitq_signal_nr(&llcd->llcd_lcm->lcm_waitq, 1);
}
EXPORT_SYMBOL(llcd_send);
struct llog_commit_master *lcm = arg;
struct llog_commit_daemon *lcd;
struct llog_canceld_ctxt *llcd, *n;
- unsigned long flags;
ENTRY;
OBD_ALLOC(lcd, sizeof(*lcd));
lock_kernel();
ptlrpc_daemonize(); /* thread never needs to do IO */
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_block_allsigs();
spin_lock(&lcm->lcm_thread_lock);
- THREAD_NAME(current->comm, sizeof(current->comm) - 1,
+ THREAD_NAME(cfs_curproc_comm(), CFS_CURPROC_COMM_MAX - 1,
"ll_log_comt_%02d", atomic_read(&lcm->lcm_thread_total));
atomic_inc(&lcm->lcm_thread_total);
spin_unlock(&lcm->lcm_thread_lock);
unlock_kernel();
- INIT_LIST_HEAD(&lcd->lcd_lcm_list);
- INIT_LIST_HEAD(&lcd->lcd_llcd_list);
+ CFS_INIT_LIST_HEAD(&lcd->lcd_lcm_list);
+ CFS_INIT_LIST_HEAD(&lcd->lcd_llcd_list);
lcd->lcd_lcm = lcm;
- CDEBUG(D_HA, "%s started\n", current->comm);
+ CDEBUG(D_HA, "%s started\n", cfs_curproc_comm());
do {
struct ptlrpc_request *request;
struct obd_import *import = NULL;
spin_lock(&lcm->lcm_llcd_lock);
list_splice(&lcd->lcd_llcd_list,
&lcm->lcm_llcd_resend);
- INIT_LIST_HEAD(&lcd->lcd_llcd_list);
+ CFS_INIT_LIST_HEAD(&lcd->lcd_llcd_list);
spin_unlock(&lcm->lcm_llcd_lock);
break;
}
spin_unlock(&lcm->lcm_thread_lock);
OBD_FREE(lcd, sizeof(*lcd));
- CDEBUG(D_HA, "%s exiting\n", current->comm);
+ CDEBUG(D_HA, "%s exiting\n", cfs_curproc_comm());
spin_lock(&lcm->lcm_thread_lock);
atomic_dec(&lcm->lcm_thread_total);
spin_unlock(&lcm->lcm_thread_lock);
- wake_up(&lcm->lcm_waitq);
+ cfs_waitq_signal(&lcm->lcm_waitq);
return 0;
}
if (atomic_read(&lcm->lcm_thread_total) >= lcm->lcm_thread_max)
RETURN(0);
- rc = kernel_thread(log_commit_thread, lcm, CLONE_VM | CLONE_FILES);
+ rc = cfs_kernel_thread(log_commit_thread, lcm, CLONE_VM | CLONE_FILES);
if (rc < 0) {
CERROR("error starting thread #%d: %d\n",
atomic_read(&lcm->lcm_thread_total), rc);
int llog_init_commit_master(void)
{
- INIT_LIST_HEAD(&lcm->lcm_thread_busy);
- INIT_LIST_HEAD(&lcm->lcm_thread_idle);
+ CFS_INIT_LIST_HEAD(&lcm->lcm_thread_busy);
+ CFS_INIT_LIST_HEAD(&lcm->lcm_thread_idle);
spin_lock_init(&lcm->lcm_thread_lock);
atomic_set(&lcm->lcm_thread_numidle, 0);
init_waitqueue_head(&lcm->lcm_waitq);
- INIT_LIST_HEAD(&lcm->lcm_llcd_pending);
- INIT_LIST_HEAD(&lcm->lcm_llcd_resend);
- INIT_LIST_HEAD(&lcm->lcm_llcd_free);
+ CFS_INIT_LIST_HEAD(&lcm->lcm_llcd_pending);
+ CFS_INIT_LIST_HEAD(&lcm->lcm_llcd_resend);
+ CFS_INIT_LIST_HEAD(&lcm->lcm_llcd_free);
spin_lock_init(&lcm->lcm_llcd_lock);
atomic_set(&lcm->lcm_llcd_numfree, 0);
lcm->lcm_llcd_minfree = 0;
lcm->lcm_flags |= LLOG_LCM_FL_EXIT;
if (force)
lcm->lcm_flags |= LLOG_LCM_FL_EXIT_FORCE;
- wake_up(&lcm->lcm_waitq);
+ cfs_waitq_signal(&lcm->lcm_waitq);
wait_event_interruptible(lcm->lcm_waitq,
atomic_read(&lcm->lcm_thread_total) == 0);
void *cb = data->llpa_cb;
struct llog_logid logid = *(struct llog_logid *)(data->llpa_arg);
struct llog_handle *llh = NULL;
- unsigned long flags;
int rc;
ENTRY;
up(&data->llpa_sem);
lock_kernel();
ptlrpc_daemonize(); /* thread does IO to log files */
- THREAD_NAME(current->comm, sizeof(current->comm) - 1, "llog_process");
+ THREAD_NAME(cfs_curproc_comm(), CFS_CURPROC_COMM_MAX - 1, "llog_process");
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_block_allsigs();
unlock_kernel();
rc = llog_create(ctxt, &llh, &logid, NULL);
llpa.llpa_cb = handle;
llpa.llpa_arg = arg;
- rc = kernel_thread(log_process_thread, &llpa, CLONE_VM | CLONE_FILES);
+ rc = cfs_kernel_thread(log_process_thread, &llpa, CLONE_VM | CLONE_FILES);
if (rc < 0)
CERROR("error starting log_process_thread: %d\n", rc);
else {
# include <liblustre.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/lustre_ha.h>
-#include <linux/lustre_net.h>
-#include <linux/lustre_import.h>
-#include <linux/lustre_export.h>
-#include <linux/obd.h>
-#include <linux/obd_ost.h>
-#include <linux/obd_class.h>
-#include <linux/obd_lov.h> /* for IOC_LOV_SET_OSC_ACTIVE */
+#include <obd_support.h>
+#include <lustre_ha.h>
+#include <lustre_net.h>
+#include <lustre_import.h>
+#include <lustre_export.h>
+#include <obd.h>
+#include <obd_ost.h>
+#include <obd_class.h>
+#include <obd_lov.h> /* for IOC_LOV_SET_OSC_ACTIVE */
#include <libcfs/list.h>
#include "ptlrpc_internal.h"
CDEBUG(D_HA, "%s: recovery started, waiting\n",
imp->imp_target_uuid.uuid);
- lwi = LWI_TIMEOUT(MAX(obd_timeout * HZ, 1), NULL, NULL);
+ lwi = LWI_TIMEOUT(cfs_timeout_cap(cfs_time_seconds(obd_timeout)),
+ NULL, NULL);
rc = l_wait_event(imp->imp_recovery_waitq,
!ptlrpc_import_in_recovery(imp), &lwi);
CDEBUG(D_HA, "%s: recovery finished\n",
#include <liblustre.h>
#include <libcfs/kp30.h>
#endif
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_net.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lustre_net.h>
#include <lnet/types.h>
#include "ptlrpc_internal.h"
/* forward ref */
static int ptlrpc_server_post_idle_rqbds (struct ptlrpc_service *svc);
-static LIST_HEAD (ptlrpc_all_services);
-static spinlock_t ptlrpc_all_services_lock = SPIN_LOCK_UNLOCKED;
+static CFS_LIST_HEAD (ptlrpc_all_services);
+spinlock_t ptlrpc_all_services_lock;
static char *
ptlrpc_alloc_request_buffer (int size)
rqbd->rqbd_refcount = 0;
rqbd->rqbd_cbid.cbid_fn = request_in_callback;
rqbd->rqbd_cbid.cbid_arg = rqbd;
- INIT_LIST_HEAD(&rqbd->rqbd_reqs);
+ CFS_INIT_LIST_HEAD(&rqbd->rqbd_reqs);
rqbd->rqbd_buffer = ptlrpc_alloc_request_buffer(svc->srv_buf_size);
if (rqbd->rqbd_buffer == NULL) {
rs->rs_scheduled = 1;
list_del (&rs->rs_list);
list_add (&rs->rs_list, &svc->srv_reply_queue);
- wake_up (&svc->srv_waitq);
+ cfs_waitq_signal (&svc->srv_waitq);
}
void
ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size, int max_reply_size,
int req_portal, int rep_portal, int watchdog_timeout,
svc_handler_t handler, char *name,
- struct proc_dir_entry *proc_entry,
+ cfs_proc_dir_entry_t *proc_entry,
svcreq_printfn_t svcreq_printfn, int num_threads)
{
int rc;
service->srv_name = name;
spin_lock_init(&service->srv_lock);
- INIT_LIST_HEAD(&service->srv_threads);
- init_waitqueue_head(&service->srv_waitq);
+ CFS_INIT_LIST_HEAD(&service->srv_threads);
+ cfs_waitq_init(&service->srv_waitq);
service->srv_nbuf_per_group = nbufs;
service->srv_max_req_size = max_req_size;
service->srv_request_max_cull_seq = 0;
service->srv_num_threads = num_threads;
- INIT_LIST_HEAD(&service->srv_request_queue);
- INIT_LIST_HEAD(&service->srv_idle_rqbds);
- INIT_LIST_HEAD(&service->srv_active_rqbds);
- INIT_LIST_HEAD(&service->srv_history_rqbds);
- INIT_LIST_HEAD(&service->srv_request_history);
- INIT_LIST_HEAD(&service->srv_active_replies);
- INIT_LIST_HEAD(&service->srv_reply_queue);
- INIT_LIST_HEAD(&service->srv_free_rs_list);
- init_waitqueue_head(&service->srv_free_rs_waitq);
+ CFS_INIT_LIST_HEAD(&service->srv_request_queue);
+ CFS_INIT_LIST_HEAD(&service->srv_idle_rqbds);
+ CFS_INIT_LIST_HEAD(&service->srv_active_rqbds);
+ CFS_INIT_LIST_HEAD(&service->srv_history_rqbds);
+ CFS_INIT_LIST_HEAD(&service->srv_request_history);
+ CFS_INIT_LIST_HEAD(&service->srv_active_replies);
+ CFS_INIT_LIST_HEAD(&service->srv_reply_queue);
+ CFS_INIT_LIST_HEAD(&service->srv_free_rs_list);
+ cfs_waitq_init(&service->srv_free_rs_waitq);
spin_lock (&ptlrpc_all_services_lock);
list_add (&service->srv_list, &ptlrpc_all_services);
request->rq_phase = RQ_PHASE_INTERPRET;
CDEBUG(D_RPCTRACE, "Handling RPC pname:cluuid+ref:pid:xid:nid:opc "
- "%s:%s+%d:%d:"LPU64":%s:%d\n", current->comm,
+ "%s:%s+%d:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
(request->rq_export ?
(char *)request->rq_export->exp_client_uuid.uuid : "0"),
(request->rq_export ?
request->rq_phase = RQ_PHASE_COMPLETE;
CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc "
- "%s:%s+%d:%d:"LPU64":%s:%d\n", current->comm,
+ "%s:%s+%d:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
(request->rq_export ?
(char *)request->rq_export->exp_client_uuid.uuid : "0"),
(request->rq_export ?
/* Don't use daemonize, it removes fs struct from new thread (bug 418) */
void ptlrpc_daemonize(void)
{
- exit_mm(current);
+ exit_mm(cfs_current());
lustre_daemonize_helper();
+#if LINUX_
+ /* XXX Liang: */
set_fs_pwd(current->fs, init_task.fs->pwdmnt, init_task.fs->pwd);
- exit_files(current);
+#endif
+ exit_files(cfs_current());
reparent_to_init();
}
struct ptlrpc_reply_state *rs;
struct lc_watchdog *watchdog;
unsigned long flags;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
+#ifdef WITH_GROUP_INFO
struct group_info *ginfo = NULL;
#endif
int rc = 0;
lock_kernel();
ptlrpc_daemonize();
- SIGNAL_MASK_LOCK(current, flags);
- sigfillset(¤t->blocked);
- RECALC_SIGPENDING;
- SIGNAL_MASK_UNLOCK(current, flags);
+ cfs_block_allsigs();
- LASSERTF(strlen(data->name) < sizeof(current->comm),
+ LASSERTF(strlen(data->name) < CFS_CURPROC_COMM_MAX,
"name %d > len %d\n",
- (int)strlen(data->name), (int)sizeof(current->comm));
- THREAD_NAME(current->comm, sizeof(current->comm) - 1, "%s", data->name);
+ (int)strlen(data->name), CFS_CURPROC_COMM_MAX);
+ THREAD_NAME(cfs_curproc_comm(), CFS_CURPROC_COMM_MAX - 1, "%s", data->name);
unlock_kernel();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9) && CONFIG_NUMA
break;
num_cpu++;
}
- set_cpus_allowed(current, node_to_cpumask(cpu_to_node(cpu)));
+ set_cpus_allowed(cfs_current(), node_to_cpumask(cpu_to_node(cpu)));
}
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
+#ifdef WITH_GROUP_INFO
ginfo = groups_alloc(0);
if (!ginfo) {
rc = -ENOMEM;
}
/* Alloc reply state structure for this one */
- OBD_ALLOC_GFP(rs, svc->srv_max_reply_size, GFP_KERNEL);
+ OBD_ALLOC_GFP(rs, svc->srv_max_reply_size, CFS_ALLOC_STD);
if (!rs) {
rc = -ENOMEM;
goto out_srv_init;
* wake up our creator. Note: @data is invalid after this point,
* because it's allocated on ptlrpc_start_thread() stack.
*/
- wake_up(&thread->t_ctl_waitq);
+ cfs_waitq_signal(&thread->t_ctl_waitq);
watchdog = lc_watchdog_add(svc->srv_watchdog_timeout,
LC_WATCHDOG_DEFAULT_CB, NULL);
svc->srv_nthreads++;
list_add(&rs->rs_list, &svc->srv_free_rs_list);
spin_unlock_irqrestore(&svc->srv_lock, flags);
- wake_up(&svc->srv_free_rs_waitq);
+ cfs_waitq_signal(&svc->srv_free_rs_waitq);
CDEBUG(D_NET, "service thread %d started\n", thread->t_id);
/* I just failed to repost request buffers. Wait
* for a timeout (unless something else happens)
* before I try again */
- svc->srv_rqbd_timeout = HZ/10;
+ svc->srv_rqbd_timeout = cfs_time_seconds(1)/10;
}
}
svc->srv_nthreads--; /* must know immediately */
thread->t_flags = SVC_STOPPED;
- wake_up(&thread->t_ctl_waitq);
+ cfs_waitq_signal(&thread->t_ctl_waitq);
spin_unlock_irqrestore(&svc->srv_lock, flags);
thread->t_flags = SVC_STOPPING;
spin_unlock_irqrestore(&svc->srv_lock, flags);
- wake_up_all(&svc->srv_waitq);
+ cfs_waitq_broadcast(&svc->srv_waitq);
l_wait_event(thread->t_ctl_waitq, (thread->t_flags & SVC_STOPPED),
&lwi);
OBD_ALLOC(thread, sizeof(*thread));
if (thread == NULL)
RETURN(-ENOMEM);
- init_waitqueue_head(&thread->t_ctl_waitq);
+ cfs_waitq_init(&thread->t_ctl_waitq);
thread->t_id = id;
spin_lock_irqsave(&svc->srv_lock, flags);
/* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
* just drop the VM and FILES in ptlrpc_daemonize() right away.
*/
- rc = kernel_thread(ptlrpc_main, &d, CLONE_VM | CLONE_FILES);
+ rc = cfs_kernel_thread(ptlrpc_main, &d, CLONE_VM | CLONE_FILES);
if (rc < 0) {
CERROR("cannot start thread '%s': rc %d\n", name, rc);
/* Network access will complete in finite time but the HUGE
* timeout lets us CWARN for visibility of sluggish NALs */
- lwi = LWI_TIMEOUT(300 * HZ, NULL, NULL);
+ lwi = LWI_TIMEOUT(cfs_time_seconds(300), NULL, NULL);
rc = l_wait_event(service->srv_waitq,
service->srv_nrqbd_receiving == 0,
&lwi);
/* wait for all outstanding replies to complete (they were
* scheduled having been flagged to abort above) */
while (atomic_read(&service->srv_outstanding_replies) != 0) {
- struct l_wait_info lwi = LWI_TIMEOUT(10 * HZ, NULL, NULL);
+ struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL);
rc = l_wait_event(service->srv_waitq,
!list_empty(&service->srv_reply_queue), &lwi);
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_cfg.h>
-#include <linux/obd_ost.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_quota.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lustre_cfg.h>
+#include <obd_ost.h>
+#include <lustre_fsfilt.h>
+#include <lustre_quota.h>
#include "quota_internal.h"
#ifdef __KERNEL__
RECALC_SIGPENDING;
SIGNAL_MASK_UNLOCK(current, flags);
- THREAD_NAME(cfs_curproc_comm(), CFS_CURPROC_COMM_MAX, "%s",
+ THREAD_NAME(cfs_curproc_comm(), CFS_CURPROC_COMM_MAX - 1, "%s",
"quotacheck");
unlock_kernel();
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_quota.h>
-#include <linux/lustre_fsfilt.h>
+#include <obd_class.h>
+#include <lustre_quota.h>
+#include <lustre_fsfilt.h>
#include "quota_internal.h"
unsigned long default_bunit_sz = 100 * 1024 * 1024; /* 100M bytes */
struct qunit_waiter {
struct list_head qw_entry;
- wait_queue_head_t qw_waitq;
+ cfs_waitq_t qw_waitq;
int qw_rc;
};
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_cfg.h>
-#include <linux/obd_ost.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_quota.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lustre_cfg.h>
+#include <obd_ost.h>
+#include <lustre_fsfilt.h>
+#include <lustre_quota.h>
#include "quota_internal.h"
#ifdef __KERNEL__
# include <liblustre.h>
#endif
-#include <linux/obd_class.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_cfg.h>
-#include <linux/obd_ost.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_quota.h>
+#include <obd_class.h>
+#include <lustre_mds.h>
+#include <lustre_dlm.h>
+#include <lustre_cfg.h>
+#include <obd_ost.h>
+#include <lustre_fsfilt.h>
+#include <lustre_quota.h>
#include "quota_internal.h"
static struct list_head qinfo_hash[NR_DQHASH];
/* SLAB cache for client quota context */
-kmem_cache_t *qinfo_cachep = NULL;
+cfs_mem_cache_t *qinfo_cachep = NULL;
static inline int const hashfn(struct client_obd *cli,
unsigned long id,
struct osc_quota_info *oqi;
ENTRY;
- OBD_SLAB_ALLOC(oqi, qinfo_cachep, SLAB_KERNEL, sizeof(*oqi));
+ OBD_SLAB_ALLOC(oqi, qinfo_cachep, CFS_ALLOC_STD, sizeof(*oqi));
if(!oqi)
RETURN(NULL);
ENTRY;
LASSERT(qinfo_cachep == NULL);
- qinfo_cachep = kmem_cache_create("osc_quota_info",
+ qinfo_cachep = cfs_mem_cache_create("osc_quota_info",
sizeof(struct osc_quota_info),
- 0, 0, NULL, NULL);
+ 0, 0);
if (!qinfo_cachep)
RETURN(-ENOMEM);
}
spin_unlock(&qinfo_list_lock);
- rc = kmem_cache_destroy(qinfo_cachep);
+ rc = cfs_mem_cache_destroy(qinfo_cachep);
LASSERT(rc == 0);
RETURN(0);
}
#ifndef __QUOTA_INTERNAL_H
#define __QUOTA_INTERNAL_H
-#include <linux/lustre_quota.h>
+#include <lustre_quota.h>
/* QUSG covnert bytes to blocks when counting block quota */
#define QUSG(count, isblk) (isblk ? toqb(count) : count)
#include <linux/init.h>
#include <linux/quota.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_quota.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_mds.h>
+#include <obd_class.h>
+#include <lustre_quota.h>
+#include <lustre_fsfilt.h>
+#include <lustre_mds.h>
#include "quota_internal.h"
#include <linux/version.h>
#include <linux/bitops.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_mds.h>
-#include <linux/obd_ost.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
+#include <lustre_mds.h>
+#include <obd_ost.h>
char *test_quotafile[] = {"aquotacheck.user", "aquotacheck.group"};
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/obd_class.h>
-#include <linux/lustre_fsfilt.h>
-#include <linux/lustre_mds.h>
-#include <linux/obd_ost.h>
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
+#include <lustre_mds.h>
+#include <obd_ost.h>
static struct obd_quotactl oqctl;
#include <dirent.h>
#include <liblustre.h>
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
+#include <obd.h>
+#include <lustre_lib.h>
#include <lustre/lustre_user.h>
-#include <linux/obd_lov.h>
+#include <obd_lov.h>
#include <lnet/lnetctl.h>
#include <linux/ldiskfs_fs.h>
#endif
#include <liblustre.h>
-#include <linux/lustre_lib.h>
-#include <linux/obd.h>
+#include <lustre_lib.h>
+#include <obd.h>
struct option longopts[] = {
{"ea", 0, 0, 'e'},
#include <fcntl.h>
#include <liblustre.h>
-#include <linux/lustre_lib.h>
-#include <linux/obd.h>
+#include <lustre_lib.h>
+#include <obd.h>
int main(int argc, char **argv)
{
#undef _GNU_SOURCE
#include <liblustre.h>
-#include <linux/lustre_mds.h>
+#include <lustre_mds.h>
static void usage(char *argv0, int status)
{
#include <limits.h>
#include <sys/ioctl.h>
#include <liblustre.h>
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
+#include <obd.h>
+#include <lustre_lib.h>
static int usage(char *prog, FILE *out)
{
sbin_PROGRAMS = lctl obdio obdbarrier lload wirecheck wiretest llmount \
l_getgroups
bin_PROGRAMS = lfs llog_reader
-lib_LIBRARIES = liblustreapi.a
+lib_LIBRARIES = liblustreapi.a
sbin_SCRIPTS = $(sbin_scripts)
bin_SCRIPTS = $(bin_scripts)
endif # UTILS
-lctl_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
-lctl_DEPENDENCIES := $(LIBPTLCTL)
+lctl_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
+lctl_DEPENDENCIES := $(LIBPTLCTL)
lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
-lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
+lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
lload_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
lload_DEPENDENCIES := $(LIBPTLCTL)
wirecheck_CPPFLAGS = -DCC="\"$(CC)\""
wiretest_SOURCES = wiretest.c
-lctl_SOURCES = parser.c obd.c lustre_cfg.c lctl.c parser.h obdctl.h
+lctl_SOURCES = parser.c obd.c lustre_cfg.c lctl.c parser.h obdctl.h
lload_SOURCES = lload.c
obdio_SOURCES = obdio.c obdiolib.c obdiolib.h
obdbarrier_SOURCES = obdbarrier.c obdiolib.c obdiolib.h
llmount_SOURCES = llmount.c
llmount_CFLAGS = $(LLMOUNT_GM_CFLAGS)
-llmount_LDADD = $(LIBREADLINE) $(LIBPTLCTL) $(LLMOUNT_GM_LDADD)
-llmount_DEPENDENCIES := $(LIBPTLCTL)
+llmount_LDADD = $(LIBREADLINE) $(LIBPTLCTL) $(LLMOUNT_GM_LDADD)
+llmount_DEPENDENCIES := $(LIBPTLCTL)
EXTRA_DIST = $(bin_scripts) $(sbin_scripts)
#include <lnet/lnetctl.h>
#include <liblustre.h>
-#include <linux/lustre_idl.h>
+#include <lustre_idl.h>
#include <lustre/liblustreapi.h>
#include <lustre/lustre_user.h>
#include <lnet/lnetctl.h>
#include <liblustre.h>
-#include <linux/obd.h>
-#include <linux/lustre_lib.h>
+#include <obd.h>
+#include <lustre_lib.h>
#include <lustre/liblustreapi.h>
-#include <linux/obd_lov.h>
+#include <obd_lov.h>
#include <lustre/liblustreapi.h>
static void err_msg(char *fmt, ...)
#include <time.h>
#include <liblustre.h>
-#include <linux/lustre_idl.h>
+#include <lustre_idl.h>
int llog_pack_buffer(int fd, struct llog_log_hdr** llog_buf, struct llog_rec_hdr*** recs, int* recs_number);
#ifndef __KERNEL__
#include <liblustre.h>
#endif
-#include <linux/lustre_lib.h>
-#include <linux/lustre_cfg.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_dlm.h>
-#include <linux/obd.h> /* for struct lov_stripe_md */
-#include <linux/obd_lov.h>
+#include <lustre_lib.h>
+#include <lustre_cfg.h>
+#include <lustre_idl.h>
+#include <lustre_dlm.h>
+#include <obd.h> /* for struct lov_stripe_md */
+#include <obd_lov.h>
#include <linux/lustre_build_version.h>
#include <unistd.h>
#include "obdctl.h"
-#include <linux/obd.h> /* for struct lov_stripe_md */
+#include <obd.h> /* for struct lov_stripe_md */
#include <linux/lustre_build_version.h>
#include <unistd.h>
#include <asm/page.h> /* needed for PAGE_SIZE - rread */
#endif
-#include <linux/obd_class.h>
+#include <obd_class.h>
#include <lnet/lnetctl.h>
#include "parser.h"
#include <stdio.h>
#include <liblustre.h>
#endif
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_dlm.h>
-#include <linux/lustre_cfg.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
+#include <lustre_dlm.h>
+#include <lustre_cfg.h>
/* obd.c */
int do_disconnect(char *func, int verbose);
#include <sys/types.h>
#include <sys/stat.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/obd_class.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
+#include <obd_class.h>
struct obdio_conn {
int oc_fd;
#include <sys/types.h>
#include <sys/wait.h>
#include <liblustre.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
#define BLANK_LINE() \
do { \
#include <stdio.h>
#include <liblustre.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
#undef LASSERT
#undef LASSERTF
#include <stdio.h>
#include <liblustre.h>
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
+#include <lustre_lib.h>
+#include <lustre_idl.h>
#undef LASSERT
#undef LASSERTF