#include <linux/types.h>
#include <portals/types.h>
-/****************** last_rcvd file *********************/
-
-#define LAST_RCVD "last_rcvd"
-#define LR_SERVER_SIZE 512
-
-/* Data stored per server at the head of the last_rcvd file. In le32 order.
- This should be common to filter_internal.h, lustre_mds.h */
-struct lr_server_data {
- __u8 lsd_uuid[40]; /* server UUID */
- __u64 lsd_unused; /* was lsd_last_objid - don't use for now */
- __u64 lsd_last_transno; /* last completed transaction ID */
- __u64 lsd_mount_count; /* FILTER incarnation number */
- __u32 lsd_feature_compat; /* compatible feature flags */
- __u32 lsd_feature_rocompat;/* read-only compatible feature flags */
- __u32 lsd_feature_incompat;/* incompatible feature flags */
- __u32 lsd_server_size; /* size of server data area */
- __u32 lsd_client_start; /* start of per-client data area */
- __u16 lsd_client_size; /* size of per-client data area */
- __u16 lsd_subdir_count; /* number of subdirectories for objects */
- __u64 lsd_catalog_oid; /* recovery catalog object id */
- __u32 lsd_catalog_ogen; /* recovery catalog inode generation */
- __u8 lsd_peeruuid[40]; /* UUID of MDS associated with this OST */
- __u32 lsd_index; /* target index (stripe index for ost)*/
- __u8 lsd_padding[LR_SERVER_SIZE - 144];
-};
/****************** persistent mount data *********************/
/* Persistent mount data are stored on the disk in this file.
Used before the setup llog can be read. */
-#define MOUNT_DATA_FILE "CONFIGS/mountdata"
+#define MOUNT_CONFIGS_DIR "CONFIGS/"
+#define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"mountdata"
#define LDD_MAGIC 0xbabb0001
int mo_stripe_sz;
int mo_stripe_count;
int mo_stripe_pattern;
- int mo_index; /* stripe index for osts, pool index
+ __u16 mo_index; /* stripe index for osts, pool index
for pooled mdts. index will be put
in lr_server_data */
int mo_timeout; /* obd timeout */
};
+/****************** last_rcvd file *********************/
+
+#define LAST_RCVD "last_rcvd"
+#define LR_SERVER_SIZE 512
+
+/* Data stored per server at the head of the last_rcvd file. In le32 order.
+ This should be common to filter_internal.h, lustre_mds.h */
+struct lr_server_data {
+ __u8 lsd_uuid[40]; /* server UUID */
+ __u64 lsd_unused; /* was lsd_last_objid - don't use for now */
+ __u64 lsd_last_transno; /* last completed transaction ID */
+ __u64 lsd_mount_count; /* FILTER incarnation number */
+ __u32 lsd_feature_compat; /* compatible feature flags */
+ __u32 lsd_feature_rocompat;/* read-only compatible feature flags */
+ __u32 lsd_feature_incompat;/* incompatible feature flags */
+ __u32 lsd_server_size; /* size of server data area */
+ __u32 lsd_client_start; /* start of per-client data area */
+ __u16 lsd_client_size; /* size of per-client data area */
+ __u16 lsd_subdir_count; /* number of subdirectories for objects */
+ __u64 lsd_catalog_oid; /* recovery catalog object id */
+ __u32 lsd_catalog_ogen; /* recovery catalog inode generation */
+ __u8 lsd_peeruuid[40]; /* UUID of MDS associated with this OST */
+ __u32 lsd_index; /* target index (stripe index for ost)*/
+ __u8 lsd_padding[LR_SERVER_SIZE - 144];
+};
+
+#ifdef __KERNEL__
+/****************** superblock additional info *********************/
+struct ll_sb_info;
+
+struct lustre_sb_info {
+ int lsi_flags;
+ //struct lvfs_run_ctxt lsi_ctxt; /* mount context */
+ struct obd_device *lsi_mgc; /* mgmt cli obd */
+ struct lustre_mount_data *lsi_lmd; /* mount command info */
+ struct lustre_disk_data *lsi_ldd; /* mount info on-disk */
+ //struct fsfilt_operations *lsi_fsops;
+ struct ll_sb_info *lsi_llsbi; /* add'l client sbi info */
+};
+
+#define LSI_SERVER 0x00000001
+#define LSI_UMOUNT_FORCE 0x00000010
+#define LSI_UMOUNT_FAILOVER 0x00000020
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
+# define s2sbi(sb) ((struct lustre_sb_info *)((sb)->s_fs_info))
+# define s2sbi_nocast(sb) ((sb)->s_fs_info)
+#else /* 2.4 here */
+# define s2sbi(sb) ((struct lustre_sb_info *)((sb)->u.generic_sbp))
+# define s2sbi_nocast(sb) ((sb)->u.generic_sbp)
+#endif
+#endif /* __KERNEL__ */
#endif // _LUSTRE_DISK_H
#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_START _IOWR('f', 187, long)
+#define OBD_IOC_UPDATE_LOG _IOWR('f', 188, long)
#define OBD_IOC_CATLOGLIST _IOWR('f', 190, long)
#define OBD_IOC_LLOG_INFO _IOWR('f', 191, long)
#include <linux/obd.h>
#include <linux/lustre_idl.h>
+#define LOG_NAME_MAX 256 /* 2.4 limit */
#define LOG_NAME_LIMIT(logname, name) \
snprintf(logname, sizeof(logname), "LOGS/%s", name)
#define LLOG_EEMPTY 4711
struct lvfs_ucred *cred);
#ifdef __KERNEL__
+struct obd_device;
struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode, int fix);
struct dentry *simple_mknod(struct dentry *dir, char *name, int mode, int fix);
-struct ll_sb_info *lustre_init_sbi(struct super_block *sb);
-void lustre_free_sbi(struct super_block *sb);
-void lustre_manual_cleanup(struct ll_sb_info *sbi);
int lustre_fill_super(struct super_block *sb, void *data, int silent);
void lustre_put_super(struct super_block *sb);
int lustre_remount_fs(struct super_block *sb, int *flags, char *data);
+int class_manual_cleanup(struct obd_device *obd, char *flags);
int lustre_fread(struct file *file, void *buf, int len, loff_t *off);
int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off);
/* Like a client, with some hangers-on. Keep mc_client_obd first so that we
* can reuse the various client setup/connect functions. */
struct mgmtcli_obd {
- struct client_obd mc_client_obd; /* nested */
- struct ptlrpc_thread *mc_ping_thread;
- struct obd_export *mc_ping_exp; /* XXX single-target */
- struct list_head mc_registered;
- void *mc_hammer;
+ /* from confobd */
+ struct super_block *mc_sb; /* from mount */
+ struct vfsmount *mc_vfsmnt; /* local mount */
+ struct dentry *mc_configs_dir;
+ struct llog_handle *mc_cfg_llh;
+ //struct logs_info mc_logs_info;
+ struct list_head mc_registered; /* chain of mgc's */
};
#define mc_import mc_client_obd.cl_import
#define LL_FILE_IGNORE_LOCK 0x00000001
#define LL_FILE_GROUP_LOCKED 0x00000002
#define LL_FILE_READAHEAD 0x00000004
-#define LL_UMOUNT_FORCE 0x00000010
-#define LL_UMOUNT_FAILOVER 0x00000020
#define LOV_USER_MAGIC_V1 0x0BD10BD0
#define LOV_USER_MAGIC LOV_USER_MAGIC_V1
#include <linux/lustre_debug.h>
#include <linux/lustre_version.h>
-
+#include <linux/lustre_disk.h> /* for s2sbi */
+
/*
struct lustre_intent_data {
__u64 it_lock_handle[2];
struct proc_dir_entry* ll_proc_root;
obd_id ll_rootino; /* number of root inode */
- struct lvfs_run_ctxt ll_ctxt; /* mount context */
- struct lustre_mount_data *ll_lmd; /* mount command info */
- struct lustre_disk_data *ll_ldd; /* mount info on-disk */
- struct fsfilt_operations *ll_fsops;
-
int ll_flags;
struct list_head ll_conn_chain; /* per-conn chain of SBs */
int ll_set_opt(const char *opt, char *data, int fl);
void ll_options(char *options, char **ost, char **mds, int *flags);
void ll_lli_init(struct ll_inode_info *lli);
-int ll_fill_super(struct super_block *sb, void *data, int silent);
-int client_fill_super(struct super_block *sb);
-void client_put_super(struct super_block *sb);
+int client_fill_super(struct super_block *sb, char *profilenm);
+void client_put_super(struct super_block *sb, char *profilenm);
struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
void ll_clear_inode(struct inode *inode);
int ll_setattr_raw(struct inode *inode, struct iattr *attr);
#define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
+#define ll_s2sbi(sb) (s2sbi(sb)->lsi_llsbi)
+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
-#define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->s_fs_info))
-#define ll_s2sbi_nocast(sb) ((sb)->s_fs_info)
void __d_rehash(struct dentry * entry, int lock);
static inline __u64 ll_ts2u64(struct timespec *time)
{
return t;
}
#else /* 2.4 here */
-#define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->u.generic_sbp))
-#define ll_s2sbi_nocast(sb) ((sb)->u.generic_sbp)
static inline __u64 ll_ts2u64(time_t *time)
{
return *time;
#define log2(n) ffz(~(n))
#endif
+/* We need to have some extra twiddling here because some systems have
+ * no random state when they start up. */
+static void
+lustre_generate_random_uuid(class_uuid_t uuid)
+{
+ struct timeval t;
+ int *i, j, k;
+
+ ENTRY;
+ LASSERT(sizeof(class_uuid_t) % sizeof(*i) == 0);
+
+ j = jiffies;
+ do_gettimeofday(&t);
+ k = t.tv_usec;
+
+ generate_random_uuid(uuid);
+
+ for (i = (int *)uuid; (char *)i < (char *)uuid + sizeof(class_uuid_t); i++) {
+ *i ^= j ^ k;
+ j = ((j << 8) & 0xffffff00) | ((j >> 24) & 0x000000ff);
+ k = ((k >> 8) & 0x00ffffff) | ((k << 24) & 0xff000000);
+ }
+
+ EXIT;
+}
+
+struct ll_sb_info *ll_init_sbi(void)
+{
+ struct ll_sb_info *sbi = NULL;
+ class_uuid_t uuid;
+ ENTRY;
+
+ OBD_ALLOC(sbi, sizeof(*sbi));
+ if (!sbi)
+ RETURN(NULL);
+
+ spin_lock_init(&sbi->ll_lock);
+ INIT_LIST_HEAD(&sbi->ll_pglist);
+ sbi->ll_pglist_gen = 0;
+ if (num_physpages >> (20 - PAGE_SHIFT) < 512)
+ sbi->ll_async_page_max = num_physpages / 2;
+ else
+ sbi->ll_async_page_max = (num_physpages / 4) * 3;
+ sbi->ll_ra_info.ra_max_pages = min(num_physpages / 8,
+ SBI_DEFAULT_READAHEAD_MAX);
+
+ INIT_LIST_HEAD(&sbi->ll_conn_chain);
+ INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
+
+ lustre_generate_random_uuid(uuid);
+ class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
+ CDEBUG(D_HA, "generated uuid: %s\n", sbi->ll_sb_uuid.uuid);
+
+ spin_lock(&ll_sb_lock);
+ list_add_tail(&sbi->ll_list, &ll_super_blocks);
+ spin_unlock(&ll_sb_lock);
+ RETURN(sbi);
+}
+
+void ll_free_sbi(struct super_block *sb)
+{
+ struct ll_sb_info *sbi = ll_s2sbi(sb);
+ ENTRY;
+
+ if (sbi != NULL) {
+ spin_lock(&ll_sb_lock);
+ list_del(&sbi->ll_list);
+ spin_unlock(&ll_sb_lock);
+ OBD_FREE(sbi, sizeof(*sbi));
+ }
+ EXIT;
+}
int client_common_fill_super(struct super_block *sb, char *mdc, char *osc)
{
lli->lli_inode_magic = LLI_INODE_MAGIC;
}
-int ll_fill_super(struct super_block *sb, void *data, int silent)
+int client_fill_super(struct super_block *sb, char *profilenm)
{
+ struct lustre_profile *lprof;
+ struct lustre_sb_info *lsi = s2sbi(sb);
struct ll_sb_info *sbi;
- char *osc = NULL;
- char *mdc = NULL;
- int err;
+ char *osc;
+ char *mdc;
+ struct config_llog_instance cfg;
+ char ll_instance[sizeof(sb) * 2 + 1];
+ int err;
ENTRY;
-
+
CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
- sbi = lustre_init_sbi(sb);
- if (!sbi)
+ /* client additional sb info */
+ lsi->lsi_llsbi = sbi = ll_init_sbi();
+ if (!sbi) {
RETURN(-ENOMEM);
-
- ll_options(data, &osc, &mdc, &sbi->ll_flags);
-
- if (!osc) {
- CERROR("no osc\n");
- GOTO(out, err = -EINVAL);
}
- if (!mdc) {
- CERROR("no mdc\n");
- GOTO(out, err = -EINVAL);
+ /* generate a string unique to this super, let's try
+ the address of the super itself.*/
+ sprintf(ll_instance, "%p", sb);
+ cfg.cfg_instance = ll_instance;
+ cfg.cfg_uuid = lsi->lsi_llsbi->ll_sb_uuid;
+
+ /* set up client obds */
+ err = lustre_get_process_log(sb, profilenm, &cfg);
+ if (err < 0) {
+ CERROR("Unable to process log: %d\n", err);
+ GOTO(out_free, err);
}
- err = client_common_fill_super(sb, mdc, osc);
-out:
- if (err)
- lustre_free_sbi(sb);
-
- if (mdc)
- OBD_FREE(mdc, strlen(mdc) + 1);
- if (osc)
- OBD_FREE(osc, strlen(osc) + 1);
-
- RETURN(err);
-} /* ll_read_super */
-
-int client_fill_super(struct super_block *sb)
-{
- struct lustre_profile *lprof;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- struct lustre_mount_data *lmd = sbi->ll_lmd;
- char * osc = NULL;
- char * mdc = NULL;
- char ll_instance[sizeof(sb) * 2 + 1];
- int err;
- ENTRY;
-
- /* get the osc and mdc names for l_c_f_s */
- lprof = class_get_profile(lmd->lmd_dev);
+ lprof = class_get_profile(profilenm);
if (lprof == NULL) {
- CERROR("No profile found: %s\n", lmd->lmd_dev);
- RETURN(-EINVAL);
- }
-
- /* see lustre_fill_super */
- sprintf(ll_instance, "%p", sb);
- OBD_ALLOC(osc, strlen(lprof->lp_osc) + strlen(ll_instance) + 2);
- sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance);
- if (!osc) {
- CERROR("no osc\n");
+ CERROR("No profile found: %s\n", profilenm);
GOTO(out_free, err = -EINVAL);
}
-
- OBD_ALLOC(mdc, strlen(lprof->lp_mdc) + strlen(ll_instance) + 2);
+ CERROR("Found profile %s: mdc=%s osc=%s\n", profilenm,
+ lprof->lp_mdc, lprof->lp_osc);
+ OBD_ALLOC(osc, strlen(lprof->lp_osc) +
+ strlen(ll_instance) + 2);
+ OBD_ALLOC(mdc, strlen(lprof->lp_mdc) +
+ strlen(ll_instance) + 2);
+ if (!osc || !mdc)
+ GOTO(out_free, err = -ENOMEM);
+
+ sprintf(osc, "%s-%s", lprof->lp_osc, ll_instance);
sprintf(mdc, "%s-%s", lprof->lp_mdc, ll_instance);
- if (!mdc) {
- CERROR("no mdc\n");
- GOTO(out_free, err = -EINVAL);
- }
+ /* connections, registrations, sb setup */
err = client_common_fill_super(sb, mdc, osc);
out_free:
OBD_FREE(mdc, strlen(mdc) + 1);
if (osc)
OBD_FREE(osc, strlen(osc) + 1);
-
+ if (err) {
+ struct obd_device *obd;
+ int next = 0;
+ /* like client_put_super below */
+ while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next))
+ !=NULL) {
+ class_manual_cleanup(obd, NULL);
+ }
+ class_del_profile(profilenm);
+ ll_free_sbi(sb);
+ lsi->lsi_llsbi = NULL;
+ }
RETURN(err);
}
-void client_put_super(struct super_block *sb)
+void client_put_super(struct super_block *sb, char *profilenm)
{
struct obd_device *obd;
+ struct lustre_sb_info *lsi = s2sbi(sb);
struct ll_sb_info *sbi = ll_s2sbi(sb);
- int force_umount = 0;
+ char flags[2] = "";
+ int next = 0;
ENTRY;
- CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
+ CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm);
obd = class_exp2obd(sbi->ll_mdc_exp);
- if (obd)
- force_umount = obd->obd_no_recov;
+ if (obd && obd->obd_no_recov)
+ strcat(flags, "F");
obd = NULL;
client_common_put_super(sb);
-
- if (sbi->ll_lmd != NULL) {
- lustre_manual_cleanup(sbi);
- OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
- }
-
- lustre_free_sbi(sb);
+
+ while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) !=NULL) {
+ class_manual_cleanup(obd, flags);
+ }
+
+ /* client */
+ if (profilenm)
+ class_del_profile(profilenm);
+
+ ll_free_sbi(sb);
+ lsi->lsi_llsbi = NULL;
EXIT;
} /* client_put_super */
EXIT;
}
+int ll_remount_fs(struct super_block *sb, __u32 read_only)
+{
+ struct ll_sb_info *sbi = ll_s2sbi(sb);
+ int err;
+
+ err = obd_set_info(sbi->ll_mdc_exp,
+ strlen("read-only"), "read-only",
+ sizeof(read_only), &read_only);
+ if (err) {
+ CERROR("Failed to change the read-only flag "
+ "during remount: %d\n", err);
+ return err;
+ }
+ return 0;
+}
+
int ll_prep_inode(struct obd_export *exp, struct inode **inode,
struct ptlrpc_request *req, int offset,struct super_block *sb)
{
extern struct address_space_operations ll_aops;
extern struct address_space_operations ll_dir_aops;
-static struct super_block *ll_read_super(struct super_block *sb,
- void *data, int silent)
-{
- int err;
- ENTRY;
- err = ll_fill_super(sb, data, silent);
- if (err)
- RETURN(NULL);
- RETURN(sb);
-}
-
static struct super_block *lustre_read_super(struct super_block *sb,
void *data, int silent)
{
RETURN(sb);
}
-static struct file_system_type lustre_lite_fs_type = {
- .owner = THIS_MODULE,
- .name = "lustre_lite",
- .fs_flags = FS_NFSEXP_FSID,
- .read_super = ll_read_super,
-};
-
/* exported operations */
struct super_operations lustre_super_operations =
{
ll_register_cache(&ll_cache_definition);
- rc = register_filesystem(&lustre_lite_fs_type);
- if (rc == 0)
- rc = register_filesystem(&lustre_fs_type);
+ rc = register_filesystem(&lustre_fs_type);
if (rc) {
- /* This is safe even if lustre_lite_fs_type isn't registered */
- unregister_filesystem(&lustre_lite_fs_type);
ll_unregister_cache(&ll_cache_definition);
}
static void __exit exit_lustre_lite(void)
{
- unregister_filesystem(&lustre_lite_fs_type);
unregister_filesystem(&lustre_fs_type);
ll_unregister_cache(&ll_cache_definition);
#include <linux/lprocfs_status.h>
#include "llite_internal.h"
-struct super_block * ll_get_sb(struct file_system_type *fs_type,
- int flags, const char *devname, void * data)
-{
- /* calls back in fill super */
- return get_sb_nodev(fs_type, flags, data, ll_fill_super);
-}
-
struct super_block * lustre_get_sb(struct file_system_type *fs_type,
int flags, const char *devname, void * data)
{
.remount_fs = lustre_remount_fs,
};
-
-struct file_system_type lustre_lite_fs_type = {
- .owner = THIS_MODULE,
- .name = "lustre_lite",
- .get_sb = ll_get_sb,
- .kill_sb = kill_anon_super,
- .fs_flags = FS_BINARY_MOUNTDATA,
-};
-
struct file_system_type lustre_fs_type = {
.owner = THIS_MODULE,
.name = "lustre",
ll_register_cache(&ll_cache_definition);
- rc = register_filesystem(&lustre_lite_fs_type);
- if (rc == 0)
- rc = register_filesystem(&lustre_fs_type);
+ rc = register_filesystem(&lustre_fs_type);
if (rc) {
- /* This is safe even if lustre_lite_fs_type isn't registered */
- unregister_filesystem(&lustre_lite_fs_type);
ll_unregister_cache(&ll_cache_definition);
}
static void __exit exit_lustre_lite(void)
{
unregister_filesystem(&lustre_fs_type);
- unregister_filesystem(&lustre_lite_fs_type);
ll_unregister_cache(&ll_cache_definition);
MODULES := lvfs #quotactl_test quotacheck_test
@SERVER_TRUE@MODULES += fsfilt_@BACKINGFS@
-lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o
+lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o lvfs_mount.o
#quotactl-objs := quotactl_test.o
#quotaccheck-objs := quotacheck_test.o
#include <linux/obd.h>
#include <linux/lvfs.h>
#include <linux/lustre_disk.h>
-#include <linux/lustre_user.h>
+#include <linux/lustre_fsfilt.h>
+#include <linux/obd_class.h>
+#include <lustre/lustre_user.h>
+static int dentry_readdir(struct obd_device *obd, struct dentry *dir,
+ struct vfsmount *inmnt, struct list_head *dentry_list)
+{
+ /* see mds_cleanup_orphans */
+ struct lvfs_run_ctxt saved;
+ struct file *file;
+ struct dentry *dentry;
+ struct vfsmount *mnt;
+ int err = 0;
+ ENTRY;
+
+ push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ dentry = dget(dir);
+ if (IS_ERR(dentry))
+ GOTO(out_pop, err = PTR_ERR(dentry));
+ mnt = mntget(inmnt);
+ if (IS_ERR(mnt)) {
+ l_dput(dentry);
+ GOTO(out_pop, err = PTR_ERR(mnt));
+ }
+
+ file = dentry_open(dentry, mnt, O_RDONLY);
+ if (IS_ERR(file))
+ /* dentry_open_it() drops the dentry, mnt refs */
+ GOTO(out_pop, err = PTR_ERR(file));
+
+ INIT_LIST_HEAD(dentry_list);
+ err = l_readdir(file, dentry_list);
+ filp_close(file, 0);
+ /* filp_close->fput() drops the dentry, mnt refs */
+
+out_pop:
+ pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ RETURN(err);
+}
int parse_mount_data(struct lvfs_run_ctxt *mount_ctxt,
struct lustre_disk_data *ldd)
struct file *file;
loff_t off = 0;
unsigned long len;
+ int err;
push_ctxt(&saved, mount_ctxt, NULL);
file = filp_open(MOUNT_DATA_FILE, O_RDONLY, 0644);
if (IS_ERR(file)) {
- rc = PTR_ERR(file);
- CERROR("cannot open %s: rc = %d\n", MOUNT_DATA_FILE, rc);
+ err = PTR_ERR(file);
+ CERROR("cannot open %s: err = %d\n", MOUNT_DATA_FILE, err);
goto out;
}
len = file->f_dentry->d_inode->i_size;
- CERROR("Have last_rcvd, size %lu\n", len);
+ CERROR("Have %s, size %lu\n", MOUNT_DATA_FILE, len);
- rc = lustre_fread(file, ldd, len, &off);
- if (rc) {
- CERROR("OBD filter: error reading %s: rc %d\n",
- MOUNT_DATA_FILE, rc);
+ err = lustre_fread(file, ldd, len, &off);
+ if (err) {
+ CERROR("OBD filter: error reading %s: err %d\n",
+ MOUNT_DATA_FILE, err);
goto out_close;
}
if (ldd->ldd_magic != LDD_MAGIC) {
CERROR("Bad magic in %s: %x!=%x\n", MOUNT_DATA_FILE,
ldd->ldd_magic, LDD_MAGIC);
- rc = -EINVAL;
+ err = -EINVAL;
}
out_close:
filp_close(file, 0);
out:
pop_ctxt(&saved, mount_ctxt, NULL);
- return(rc);
+ return(err);
}
-int parse_last_rcvd(struct ll_sb_info *sbi,
- char *uuid, int *first_mount)
+int parse_last_rcvd(struct obd_device *obd, char *uuid, int *first_mount)
{
struct lvfs_run_ctxt saved;
struct file *file;
struct lr_server_data *lsd;
loff_t off = 0;
- int rc;
+ int err;
OBD_ALLOC_WAIT(lsd, sizeof(*lsd));
if (!lsd)
return -ENOMEM;
/* requires a mounted device */
- LASSERT(sbi->ll_ctxt.pwdmnt);
- push_ctxt(&saved, &sbi->ll_ctxt, NULL);
-
+ LASSERT(obd);
+ /*setup llog ctxt*/
+ push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+
/* open and test the last rcvd file */
file = filp_open(LAST_RCVD, O_RDONLY, 0644);
if (IS_ERR(file)) {
- rc = PTR_ERR(file);
- CERROR("cannot open %s file: rc = %d\n", LAST_RCVD, rc);
+ err = PTR_ERR(file);
+ CERROR("cannot open %s file: err = %d\n", LAST_RCVD, err);
goto out;
}
CERROR("Have last_rcvd, size %lu\n",
(unsigned long)file->f_dentry->d_inode->i_size);
- LASSERT(sbi->ll_fsops);
- rc = sbi->ll_fsops->fs_read_record(file, lsd, sizeof(*lsd), &off);
- //rc = fsfilt_read_record(obd, file, lsd, sizeof(*lsd), &off);
- if (rc) {
- CERROR("OBD filter: error reading %s: rc %d\n", LAST_RCVD, rc);
+ err = fsfilt_read_record(obd, file, lsd, sizeof(*lsd), &off);
+ if (err) {
+ CERROR("OBD filter: error reading %s: err %d\n", LAST_RCVD, err);
goto out_close;
}
out_close:
filp_close(file, 0);
out:
- pop_ctxt(&saved, &sbi->ll_ctxt, NULL);
+ pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
OBD_FREE(lsd, sizeof(*lsd));
- return(rc);
+ return(err);
}
static int do_lcfg(char *cfgname, ptl_nid_t nid, int cmd,
{
struct lustre_cfg_bufs bufs;
struct lustre_cfg * lcfg = NULL;
+ int err;
lustre_cfg_bufs_reset(&bufs, cfgname);
if (s1)
return(err);
}
-static int class_manual_cleanup(struct obd_device *obd, char *flags)
+int class_manual_cleanup(struct obd_device *obd, char *flags)
{
- struct lustre_cfg *lcfg;
- struct lustre_cfg_bufs bufs;
int err, rc = 0;
-
+
+ LASSERT(obd);
err = do_lcfg(obd->obd_name, 0, LCFG_CLEANUP, flags, 0, 0, 0);
if (err) {
CERROR("cleanup failed (%d): %s\n", err, obd->obd_name);
return(rc);
}
-void lustre_manual_cleanup(struct ll_sb_info *sbi)
-{
- while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
- class_manual_cleanup(obd, NULL);
-
- if (sbi->ll_lmd && lmd_is_client(sbi->ll_lmd))
- class_del_profile(sbi->ll_lmd->lmd_dev);
-}
-
-/* We need to have some extra twiddling here because some systems have
- * no random state when they start up. */
-static void
-lustre_generate_random_uuid(class_uuid_t uuid)
-{
- struct timeval t;
- int *i, j, k;
-
- ENTRY;
- LASSERT(sizeof(class_uuid_t) % sizeof(*i) == 0);
-
- j = jiffies;
- do_gettimeofday(&t);
- k = t.tv_usec;
-
- generate_random_uuid(uuid);
-
- for (i = (int *)uuid; (char *)i < (char *)uuid + sizeof(class_uuid_t); i++) {
- *i ^= j ^ k;
- j = ((j << 8) & 0xffffff00) | ((j >> 24) & 0x000000ff);
- k = ((k >> 8) & 0x00ffffff) | ((k << 24) & 0xff000000);
- }
-
- EXIT;
-}
-
-struct ll_sb_info *lustre_init_sbi(struct super_block *sb)
+struct lustre_sb_info *lustre_init_sbi(struct super_block *sb)
{
- struct ll_sb_info *sbi = NULL;
- class_uuid_t uuid;
- ENTRY;
+ struct lustre_sb_info *sbi = NULL;
OBD_ALLOC(sbi, sizeof(*sbi));
if (!sbi)
RETURN(NULL);
- spin_lock_init(&sbi->ll_lock);
- INIT_LIST_HEAD(&sbi->ll_pglist);
- sbi->ll_pglist_gen = 0;
- if (num_physpages >> (20 - PAGE_SHIFT) < 512)
- sbi->ll_async_page_max = num_physpages / 2;
- else
- sbi->ll_async_page_max = (num_physpages / 4) * 3;
- sbi->ll_ra_info.ra_max_pages = min(num_physpages / 8,
- SBI_DEFAULT_READAHEAD_MAX);
-
- INIT_LIST_HEAD(&sbi->ll_conn_chain);
- INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
- ll_s2sbi_nocast(sb) = sbi;
-
- lustre_generate_random_uuid(uuid);
- class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
- CDEBUG(D_HA, "generated uuid: %s\n", sbi->ll_sb_uuid.uuid);
-
- spin_lock(&ll_sb_lock);
- list_add_tail(&sbi->ll_list, &ll_super_blocks);
- spin_unlock(&ll_sb_lock);
- RETURN(sbi);
+ s2sbi_nocast(sb) = sbi;
+ return(sbi);
}
void lustre_free_sbi(struct super_block *sb)
{
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct lustre_sb_info *sbi = s2sbi(sb);
ENTRY;
if (sbi != NULL) {
- spin_lock(&ll_sb_lock);
- list_del(&sbi->ll_list);
- spin_unlock(&ll_sb_lock);
- if (sbi->ll_ldd != NULL)
- OBD_FREE(sbi->ll_ldd, sizeof(*sbi->ll_ldd));
+ if (sbi->lsi_ldd != NULL)
+ OBD_FREE(sbi->lsi_ldd, sizeof(*sbi->lsi_ldd));
+ if (sbi->lsi_lmd != NULL)
+ OBD_FREE(sbi->lsi_lmd, sizeof(*sbi->lsi_lmd));
+ LASSERT(sbi->lsi_llsbi == NULL);
OBD_FREE(sbi, sizeof(*sbi));
+ s2sbi_nocast(sb) = NULL;
}
- ll_s2sbi_nocast(sb) = NULL;
EXIT;
}
-static void server_put_super(struct super_block *sb)
+static int lustre_update_llog(struct obd_device *obd)
{
- struct list_head dentry_list;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- struct l_linux_dirent *dirent, *n;
- struct obd_device *obd;
- struct mgmtcli_obd *mcobd;
- char logname[LOG_NAME_MAX];
- char flags[2] = "";
- int err;
-
- //FIXME create MGC
+ int err = 0;
- CERROR("server put_super uuid %s\n", sbi->ll_sb_uuid.uuid);
-
- obd = class_uuid2obd(&sbi->ll_sb_uuid);
- if (!obd) {
- CERROR("Can't get mcobd %s\n", sbi->ll_sb_uuid.uuid);
- return;
- }
- mcobd = &obd->u.mgmtcli;
-
+ // FIXME this should be called from lov_add_obd?
+#if 0
if (mcobd->cfobd_logs_info.ost_number > 0) {
struct obd_ioctl_data ioc_data = { 0 };
CERROR("update new logs.\n");
if (err)
CERROR("Failed to Update logs. \n");
}
+#endif
+ return err;
+}
+
+static void server_put_super(struct super_block *sb)
+{
+ struct list_head dentry_list;
+ struct lustre_sb_info *sbi = s2sbi(sb);
+ struct l_linux_dirent *dirent, *n;
+ struct obd_device *obd;
+ struct mgmtcli_obd *mcobd;
+ char flags[2] = "";
+ int err;
- /* Find all the logs in the LOGS directory */
- err = dentry_readdir(obd, mcobd->cfobd_logs_dir,
- mcobd->cfobd_lvfs_ctxt->loc_mnt,
- &dentry_list);
- if (err)
- CERROR("Can't read LOGS dir, %d\n", err);
+ obd = sbi->lsi_mgc;
+ CERROR("server put_super %s\n", obd->obd_name);
+ mcobd = &obd->u.mgmtcli;
+
+ lustre_update_llog(obd);
- if (sbi->ll_flags & LL_UMOUNT_FORCE)
+ //FIXME cleanup does the mntput; we have to make sure MGS is done with
+ //it as well
+
+ if (sbi->lsi_flags & LSI_UMOUNT_FORCE)
strcat(flags, "A");
- if (sbi->ll_flags & LL_UMOUNT_FAILOVER)
+ if (sbi->lsi_flags & LSI_UMOUNT_FAILOVER)
strcat(flags, "F");
-
+
/* Clean up all the -conf obd's in the LOGS directory.
- FIXME this may not be complete / reasonable.
- Really, we should have a list of every obd we started,
- maybe an additional field to obd_device for group_uuid, then
- just use lustre_manual_cleanup.
- CRAY_MDS:
- client client-clean mdsA mdsA-clean mdsA-conf
- CRAY_OST:
- OSS-conf OST_uml2-conf
- This does clean up oss, ost, mds, but not mdt. mdt is set up
- as part of mdsA-conf.
- */
+ FIXME this may not be complete / reasonable.
+ Really, we should have a list of every obd we started,
+ maybe an additional field to obd_device for group_uuid, then
+ just use lustre_manual_cleanup.
+ CRAY_MDS:
+ client client-clean mdsA mdsA-clean mdsA-conf
+ CRAY_OST:
+ OSS-conf OST_uml2-conf
+ This does clean up oss, ost, mds, but not mdt. mdt is set up
+ as part of mdsA-conf.
+ */
+
+ /* Find all the logs in the CONFIGS directory */
+ err = dentry_readdir(obd, mcobd->mc_configs_dir,
+ mcobd->mc_vfsmnt, &dentry_list);
+ if (err)
+ CERROR("Can't read LOGS dir, %d\n", err);
+
list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
+ char *logname;
int len;
+
list_del(&dirent->lld_list);
- strncpy(logname, dirent->lld_name, sizeof(logname));
- OBD_FREE(dirent, sizeof(*dirent));
-
+
+ logname = dirent->lld_name;
/* Confobd start adds "-conf" */
len = strlen(logname) - 5;
- if ((len < 1) || strcmp(logname + len, "-conf")) {
+ if ((len < 1) || strcmp(logname, "-conf")) {
CDEBUG(D_CONFIG, "ignoring %s\n", logname);
+ OBD_FREE(dirent, sizeof(*dirent));
continue;
}
logname[len] = 0;
if (err) {
CERROR("failed to cleanup %s: %d\n", logname, err);
}
+ OBD_FREE(dirent, sizeof(*dirent));
}
/* FIXME so until we decide the above, completly evil hack
if (obd)
class_manual_cleanup(obd, flags);
- /* Cleanup the mcobd itself */
- if (sbi->ll_lmd != NULL) {
- lustre_manual_cleanup(sbi);
- OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
- }
-
- //FIXME cleanup does the mntput; we have to make sure MGS is done with
- //it as well - we should probably do it here.
-
- lustre_free_sbi(sb);
+ class_del_profile(sbi->lsi_ldd->ldd_svname);
}
static void server_umount_force(struct super_block *sb)
{
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct lustre_sb_info *sbi = s2sbi(sb);
CERROR("Umount -f\n");
// FIXME decide FORCE or FAILOVER based on mount option -o umount=failover
- sbi->ll_flags |= LL_UMOUNT_FORCE;
+ sbi->lsi_flags |= LSI_UMOUNT_FORCE;
}
static struct super_operations server_ops =
.umount_begin = server_umount_force, /* umount -f */
};
-static int server_fill_super(struct super_block *sb)
+#define log2(n) ffz(~(n))
+#define LUSTRE_SUPER_MAGIC 0x0BD00BD1
+
+static int server_fill_super_common(struct super_block *sb)
{
struct inode *root = 0;
//struct ll_sb_info *sbi = ll_s2sbi(sb);
sb->s_blocksize = 4096;
sb->s_blocksize_bits = log2(sb->s_blocksize);
- sb->s_magic = LL_SUPER_MAGIC;
- sb->s_maxbytes = PAGE_CACHE_MAXBYTES;
+ sb->s_magic = LUSTRE_SUPER_MAGIC;
+ sb->s_maxbytes = 0; //PAGE_CACHE_MAXBYTES;
sb->s_flags |= MS_RDONLY;
sb->s_op = &server_ops;
RETURN(0);
}
+#if 0
+FIXME
+
/* Get the log "profile" from a remote MGMT and process it.
FIXME If remote doesn't exist, try local
This func should work for both clients and servers */
-int lustre_get_process_log(struct lustre_mount_data *lmd, char * profile,
+int lustre_get_process_log(struct super_block *sb, char * profile,
struct config_llog_instance *cfg)
{
- char * peer = "MDS_PEER_UUID";
+ char *peer = "MDS_PEER_UUID";
struct obd_device *obd;
struct lustre_handle mdc_conn = {0, };
struct obd_export *exp;
- char * mdcname = "mdc_dev";
- char mdsname[sizeof(lmd->lmd_dev)];
+ char *mdcname = "mdc_dev";
+ char *mdsname;
class_uuid_t uuid;
struct obd_uuid mdc_uuid;
struct llog_ctxt *ctxt;
LASSERT(lmd->lmd_mgmtnid.primary != PTL_NID_ANY);
- lustre_generate_random_uuid(uuid);
+ //lustre_generate_random_uuid(uuid);
class_uuid_unparse(uuid, &mdc_uuid);
CDEBUG(D_HA, "generated uuid: %s\n", mdc_uuid.uuid);
RETURN(rc);
}
-
+#endif
/* Process all local logs.
FIXME clients and servers should use the same fn. No need to have MDS
do client and confobd do servers. MGC should do both. */
-int lustre_process_logs(struct lustre_mount_data *lmd,
+int lustre_process_logs(struct super_block *sb,
struct config_llog_instance *cfg, int allow_recov)
{
+ char lr_uuid[40];
struct obd_ioctl_data ioc_data = { 0 };
struct list_head dentry_list;
struct l_linux_dirent *dirent, *n;
struct obd_device *obd;
struct mgmtcli_obd *mcobd;
- char lr_uuid[40];
- char logname[LOG_NAME_MAX];
- char mcname[40];
+ struct lustre_sb_info *sbi = s2sbi(sb);
int is_first_mount = 0;
int err;
-
- /* We're a server, set up a mcobd to process the logs */
- sprintf(mcname, "CONF%s ", lmd->lmd_dev);
- err = do_lcfg(LCFG_ATTACH, mcname, LUSTRE_CONFOBD_NAME,
- cfg->cfg_uuid.uuid, 0, 0);
- if (err)
- return(err);
-
- /* Apparently servers mount the fs on top of the confobd mount,
- so our confobd mount options must be the same as the server?? */
- err = do_lcfg(LCFG_SETUP, mcname, lmd->u.srv.lmd_source,
- lmd->u.srv.lmd_fstype, lmd->u.srv.lmd_fsopts, 0);
- if (err) {
- CERROR("mcobd setup error %d\n", err);
- do_lcfg(LCFG_DETACH, mcname, 0, 0, 0, 0);
- return(err);
- }
-
- obd = class_name2obd(mcname);
- if (!obd) {
- CERROR("Can't find mcobd %s\n", mcname);
- return(-ENOTCONN);
- }
+ obd = sbi->lsi_mgc;
+ LASSERT(obd);
mcobd = &obd->u.mgmtcli;
err = parse_last_rcvd(obd, lr_uuid, &is_first_mount);
if ((strncmp(lr_uuid, "OST", 3) == 0) && is_first_mount) {
/* Always register with MGS. If this is the first mount
for an OST, we might have to change our name */
- err = ost_register(lmd, lr_uuid);
+ // err = ost_register(lmd, lr_uuid);
if (err) {
CERROR("OST register Failed\n");
return(err);
}
} else if (strncmp(lr_uuid, "MDS", 3) == 0) {
- #if 0
+ #if 0
//FIXME stripe count is set in the mds llog
uint32_t stripe_size;
err = get_stripe_size(obd, &stripe_size);
return(err);
}
mcobd_start_accept(obd, lmd, lr_uuid, stripe_size);
- #endif
+ #endif
}
- /* Find all the logs in the LOGS directory */
- err = dentry_readdir(obd, mcobd->cfobd_logs_dir,
- mcobd->cfobd_lvfs_ctxt->loc_mnt,
- &dentry_list);
+ /* Find all the logs in the CONFIGS directory */
+ err = dentry_readdir(obd, mcobd->mc_configs_dir,
+ mcobd->mc_vfsmnt, &dentry_list);
if (err) {
CERROR("Can't read LOGS dir\n");
return(err);
}
- /* Start up all the -conf logs in the LOGS directory */
+ /* Start up all the -conf logs in the CONFIGS directory */
list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
+ char *logname;
int len;
+
list_del(&dirent->lld_list);
- strncpy(logname, dirent->lld_name, sizeof(logname));
- OBD_FREE(dirent, sizeof(*dirent));
+ logname = dirent->lld_name;
/* Confobd start adds "-conf" */
len = strlen(logname) - 5;
if ((len < 1) || (strcmp(logname + len, "-conf") != 0)) {
CDEBUG(D_CONFIG, "ignoring %s\n", logname);
+ OBD_FREE(dirent, sizeof(*dirent));
continue;
}
logname[len] = 0;
if (err) {
CERROR("failed to start log %s: %d\n", logname, err);
}
+ OBD_FREE(dirent, sizeof(*dirent));
}
return(err);
}
/* Kernel mount using mount options in MOUNT_DATA_FILE */
-static int lustre_kern_mount(struct ll_sb_info *sbi)
+static int lustre_kern_mount(struct super_block *sb)
{
struct lvfs_run_ctxt mount_ctxt;
- struct lvfs_run_ctxt saved;
+ struct lustre_sb_info *sbi = s2sbi(sb);
struct lustre_disk_data *ldd;
- struct lustre_mount_data *lmd = sbi->ll_lmd;
+ struct lustre_mount_data *lmd = sbi->lsi_lmd;
+ struct obd_device *obd;
+ struct mgmtcli_obd *mcobd;
char *options = NULL;
struct vfsmount *mnt;
unsigned long page;
- int rc;
+ int err;
OBD_ALLOC(ldd, sizeof(*ldd));
if (!ldd)
CERROR("Pre-mount ext3 %s\n", lmd->lmd_dev);
mnt = do_kern_mount("ext3", 0, lmd->lmd_dev, 0);
if (IS_ERR(mnt)) {
- rc = PTR_ERR(mnt);
- CERROR("premount failed: rc = %d\n", rc);
+ err = PTR_ERR(mnt);
+ CERROR("premount failed: err = %d\n", err);
goto out_free;
}
mount_ctxt.fs = get_ds();
//mount_ctxt.cb_ops = mds_lvfs_ops;
- rc = parse_mount_data(&mount_ctxt, ldd);
+ err = parse_mount_data(&mount_ctxt, ldd);
//unlock_kernel();
mntput(mnt);
//lock_kernel();
- if (rc) {
- CERROR("premount parse options failed: rc = %d\n", rc);
+ if (err) {
+ CERROR("premount parse options failed: err = %d\n", err);
goto out_free;
}
/* Glom up mount options */
page = __get_free_page(GFP_KERNEL);
if (!page) {
- rc = -ENOMEM;
+ err = -ENOMEM;
goto out_free;
}
options = (char *)page;
mnt = do_kern_mount(MT_STR(ldd), 0, lmd->lmd_dev, (void *)options);
free_page(page);
if (IS_ERR(mnt)) {
- rc = PTR_ERR(mnt);
- CERROR("do_kern_mount failed: rc = %d\n", rc);
+ err = PTR_ERR(mnt);
+ CERROR("do_kern_mount failed: err = %d\n", err);
goto out_free;
}
- /* ldd freed at sbi cleanup */
- sbi->ll_ldd = ldd;
- sbi->ll_ctxt.pwdmnt = mnt;
- sbi->ll_ctxt.pwd = mnt->mnt_root;
- sbi->ll_ctxt.fs = get_ds();
- sbi->ll_fsops = fsfilt_get_ops(MT_STR(ldd));
+ obd = sbi->lsi_mgc;
+ mcobd = &obd->u.mgmtcli;
+ mcobd->mc_vfsmnt = mnt;
+ mcobd->mc_sb = mnt->mnt_root->d_inode->i_sb; // is this different than sb? */
+ fsfilt_setup(obd, mcobd->mc_sb);
+
+ OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
+ obd->obd_lvfs_ctxt.pwdmnt = mnt;
+ obd->obd_lvfs_ctxt.pwd = mnt->mnt_root;
+ obd->obd_lvfs_ctxt.fs = get_ds();
+ //obd->obd_lvfs_ctxt.cb_ops = mds_lvfs_ops;
+
+ sbi->lsi_ldd = ldd; /* freed at sbi cleanup */
CDEBUG(D_SUPER, "%s: mnt = %p\n", lmd->lmd_dev, mnt);
return(0);
out_free:
OBD_FREE(ldd, sizeof(*ldd));
- return(rc);
+ return(err);
+}
+
+static int server_fill_super(struct super_block *sb)
+{
+ struct config_llog_instance cfg;
+ struct lustre_sb_info *sbi = s2sbi(sb);
+ int err;
+
+ cfg.cfg_instance = sbi->lsi_mgc->obd_name;
+ snprintf(cfg.cfg_uuid.uuid, sizeof(cfg.cfg_uuid.uuid),
+ sbi->lsi_mgc->obd_name);
+
+ /* mount to read server info */
+ err = lustre_kern_mount(sb);
+ if (err) {
+ CERROR("Unable to mount device %s: %d\n",
+ sbi->lsi_lmd->lmd_dev, err);
+ GOTO(out_free, err);
+ }
+ CERROR("Found service %s for fs %s on device %s\n",
+ sbi->lsi_ldd->ldd_svname, sbi->lsi_ldd->ldd_fsname,
+ sbi->lsi_lmd->lmd_dev);
+
+ /* Set up all obd devices for service */
+ err = lustre_process_logs(sb, &cfg, 0);
+ if (err < 0) {
+ CERROR("Unable to process log: %d\n", err);
+ GOTO(out_free, err);
+ }
+
+ /* Finally, put something at the mount point. */
+ CERROR("Mounting server\n");
+ err = server_fill_super_common(sb);
+
+ /* FIXME overmount client here,
+ or can we just start a client log and client_fill_super on this sb?
+ have to fix up the s_ops after! */
+out_free:
+ //FIXME mntput
+ //FIXME manual_cleanup (server_put_super)
+ if (sbi->lsi_ldd)
+ class_del_profile(sbi->lsi_ldd->ldd_svname);
+ return (err);
+}
+
+/* Set up a mcobd to process startup logs */
+static int lustre_start_mgc(struct super_block *sb)
+{
+ struct config_llog_instance cfg;
+ struct lustre_sb_info *sbi = s2sbi(sb);
+ struct obd_device *obd;
+ char *mcname;
+ int err = 0;
+
+ /* Generate a string unique to this super, let's try
+ the address of the super itself.*/
+ OBD_ALLOC(mcname, sizeof(sb) * 2 + 1);
+ sprintf(mcname, "MGC_%p", sb);
+ cfg.cfg_instance = mcname;
+ snprintf(cfg.cfg_uuid.uuid, sizeof(cfg.cfg_uuid.uuid), mcname);
+
+ err = do_lcfg(mcname, 0, LCFG_ATTACH, "mgc", cfg.cfg_uuid.uuid, 0, 0);
+ if (err)
+ goto out_free;
+
+ err = do_lcfg(mcname, 0, LCFG_SETUP, 0, 0, 0, 0);
+ if (err) {
+ CERROR("mcobd setup error %d\n", err);
+ do_lcfg(mcname, 0, LCFG_DETACH, 0, 0, 0, 0);
+ goto out_free;
+ }
+
+ obd = class_name2obd(mcname);
+ if (!obd) {
+ CERROR("Can't find mcobd %s\n", mcname);
+ err = -ENOTCONN;
+ goto out_free;
+ }
+ sbi->lsi_mgc = obd;
+
+out_free:
+ OBD_FREE(mcname, sizeof(sb) * 2 + 1);
+ return err;
+}
+
+static void lustre_stop_mgc(struct super_block *sb)
+{
+ struct lustre_sb_info *sbi = s2sbi(sb);
+ struct obd_device *obd;
+
+ obd = sbi->lsi_mgc;
+ class_manual_cleanup(obd, NULL);
}
/* Common mount */
int lustre_fill_super(struct super_block *sb, void *data, int silent)
{
struct lustre_mount_data * lmd = data;
- struct ll_sb_info *sbi;
- struct config_llog_instance cfg;
- char ll_instance[sizeof(sb) * 2 + 1];
- int len;
+ struct lustre_sb_info *sbi;
int err;
ENTRY;
sbi = lustre_init_sbi(sb);
if (!sbi)
RETURN(-ENOMEM);
-
+
/* save mount data */
- OBD_ALLOC(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
- if (sbi->ll_lmd == NULL)
- GOTO(out_free, err = -ENOMEM);
- memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
-
- /* generate a string unique to this super, let's try
- the address of the super itself.*/
- sprintf(ll_instance, "%p", sb);
- cfg.cfg_instance = ll_instance;
- cfg.cfg_uuid = sbi->ll_sb_uuid;
+ OBD_ALLOC(sbi->lsi_lmd, sizeof(*sbi->lsi_lmd));
+ if (sbi->lsi_lmd == NULL) {
+ lustre_free_sbi(sb);
+ RETURN(-ENOMEM);
+ }
+ memcpy(sbi->lsi_lmd, lmd, sizeof(*lmd));
- /*FIXME mgc = create_mgc(sbi);
- name "fsname-mgc"? or 1 mgc per node?
- */
+ lustre_start_mgc(sb);
if (lmd_is_client(lmd)) {
- err = lustre_get_process_log(lmd,
- lmd->lmd_dev/* FIXME or "client"?*/,
- &cfg)
- if (err < 0) {
- CERROR("Unable to process log: %d\n", err);
- GOTO(out_free, err);
- }
+ CERROR("Mounting client\n");
/* Connect and start */
- err = client_fill_super(sb);
- if (err < 0) {
- CERROR("Unable to mount client: %s\n",
- lmd->u.cli.lmd_profile);
- GOTO(out_free, err);
- }
-
+ err = client_fill_super(sb, lmd->lmd_dev /*profile */);
} else {
- /* Server, so mount to read server info */
- err = lustre_kern_mount(sbi);
- if (err) {
- CERROR("Unable to mount device %s: %d\n",
- lmd->lmd_dev, err);
- GOTO(out_free, err);
- }
- CERROR("Found service %s for fs %s on device %s\n",
- sbi->ll_ldd->ldd_svname, sbi->ll_ldd->ldd_fsname,
- lmd->lmd_dev);
-
- /* Set up all obd devices for service */
- err = lustre_process_logs(lmd, &cfg, 0);
- if (err < 0) {
- CERROR("Unable to process log: %d\n", err);
- GOTO(out_free, err);
- }
-
- /* Finally, put something at the mount point. */
CERROR("Mounting server\n");
err = server_fill_super(sb);
- /* FIXME overmount client here,
- or can we just start a client log and client_fill_super on this sb?
- have to fix up the s_ops after! */
}
- RETURN(err);
-
-out_free:
- if (sbi->ll_lmd) {
- lustre_manual_cleanup(sbi);
- OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
+ if (err){
+ CERROR("Unable to mount %s\n", lmd->lmd_dev);
+ lustre_stop_mgc(sb);
+ lustre_free_sbi(sb);
}
- lustre_free_sbi(sb);
-
RETURN(err);
-} /* lustre_fill_super */
+}
/* Common umount */
void lustre_put_super(struct super_block *sb)
{
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- if (sbi->ll_lmd && !lmd_is_client(sbi->ll_lmd) {
+ struct lustre_sb_info *sbi = s2sbi(sb);
+ struct obd_device *obd;
+
+ LASSERT(sbi->lsi_lmd);
+ if (!lmd_is_client(sbi->lsi_lmd)) {
// FIXME unmount overmounted client first
- return server_put_super(sb);
+ //mntput?
+ server_put_super(sb);
} else {
- return client_put_super(sb);
+ client_put_super(sb, sbi->lsi_lmd->lmd_dev);
}
+
+ lustre_stop_mgc(sb);
+ lustre_free_sbi(sb);
}
/* Common remount */
int lustre_remount_fs(struct super_block *sb, int *flags, char *data)
{
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int err;
+ struct lustre_sb_info *sbi = s2sbi(sb);
+ int ret = 0;
__u32 read_only;
if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
read_only = *flags & MS_RDONLY;
- if (sbi->ll_lmd && !lmd_is_client(sbi->ll_lmd) {
- CERROR("Remount server RO %d\n", read_only);
+ if (sbi->lsi_lmd && !lmd_is_client(sbi->lsi_lmd)) {
+ // FIXME what does this mean?
+ CERROR("Remount server %s RO %d\n",
+ sbi->lsi_ldd->ldd_svname, read_only);
} else {
- err = obd_set_info(sbi->ll_mdc_exp, strlen("read-only"),
- "read-only", sizeof(read_only),
- &read_only);
- if (err) {
- CERROR("Failed to change the read-only flag "
- "during remount: %d\n", err);
- return err;
- }
+ ret = ll_remount_fs(sb, read_only);
}
-
if (read_only)
sb->s_flags |= MS_RDONLY;
else
sb->s_flags &= ~MS_RDONLY;
}
- return 0;
+ return ret;
}
-EXPORT_SYMBOL(lustre_init_sbi);
-EXPORT_SYMBOL(lustre_free_sbi);
EXPORT_SYMBOL(lustre_fill_super);
EXPORT_SYMBOL(lustre_put_super);
-EXPORT_SYMBOL(lustre_manual_cleanup);
EXPORT_SYMBOL(lustre_remount_fs);
+EXPORT_SYMBOL(class_manual_cleanup);
+
static int verbose = 1;
/* for running system() */
-static char cmd[50];
+static char cmd[128];
static char cmd_out[32][128];
static char *ret_file = "/tmp/mkfs.log";
fprintf(out, "usage: %s [options] <device>\n", progname);
fprintf(out,
- "\t-h|--help: print this usage message\n"
- "\t<device>:block device or file (e.g /dev/hda or /tmp/ost1)\n"
+ "\t<device>:block device or file (e.g /dev/sda or /tmp/ost1)\n"
"\toptions:\n"
"\t\t--ost: object storage, mutually exclusive with mdt\n"
"\t\t--mdt: metadata storage, mutually exclusive with ost\n"
exit(out != stdout);
}
+#define vprint if (verbose) printf
+
+static void fatal(void)
+{
+ verbose = 0;
+ fprintf(stderr, "\n%s FATAL: ", progname);
+}
+
inline unsigned int
dev_major (unsigned long long int __dev)
{
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
}
-#define vprint if (verbose) printf
-
int get_os_version()
{
static int version = 0;
}
//Ugly implement. FIXME
-int run_command(char *cmd, char out[32][128])
+int run_command(char *cmd)
{
int i = 0,ret = 0;
FILE *rfile = NULL;
exit(2);
}
- memset(out, 0, sizeof(out));
- while (fgets(out[i], 128, rfile) != NULL) {
- i++;
- if (i >= 32) {
- fprintf(stderr,"WARNING losing some outputs when run %s",
+ memset(cmd_out, 0, sizeof(cmd_out));
+ while (fgets(cmd_out[i], 128, rfile) != NULL) {
+ if (verbose > 2) printf(" _ %s", cmd_out[i]);
+ i++;
+ if (i >= 32) {
+ fprintf(stderr,"WARNING losing some output from %s",
cmd);
- break;
- }
+ break;
+ }
}
fclose(rfile);
return ret;
}
+static void run_command_out()
+{
+ int i;
+ for (i = 0; i < 32; i++) {
+ if (strlen(cmd_out[i]) == 0)
+ break;
+ fprintf(stderr, cmd_out[i]);
+ }
+}
+
/* Figure out the loop device names */
void init_loop_base()
{
- if (!access("/dev/loop0",F_OK|R_OK))
- strcpy(loop_base,"/dev/loop\0");
- else if (!access("/dev/loop/0",F_OK|R_OK))
- strcpy(loop_base,"/dev/loop/\0");
+ if (!access("/dev/loop0", F_OK | R_OK))
+ strcpy(loop_base, "/dev/loop\0");
+ else if (!access("/dev/loop/0", F_OK | R_OK))
+ strcpy(loop_base, "/dev/loop/\0");
else {
- fprintf(stderr,"can't access loop devices\n");
+ fprintf(stderr, "can't access loop devices\n");
exit(1);
}
return;
break;
sprintf(cmd, "losetup %s", l_device);
- ret = run_command(cmd, cmd_out);
+ ret = run_command(cmd);
/* losetup gets 1 (256?) for good non-set-up device */
if (ret) {
sprintf(cmd, "losetup %s %s", l_device, file);
- ret = run_command(cmd, cmd_out);
+ ret = run_command(cmd);
if (ret) {
fprintf(stderr, "error %d on losetup: %s\n",
ret, strerror(ret));
minor = dev_minor(st.st_rdev);
sprintf(cmd,"cat /proc/partitions ");
- ret = run_command(cmd,cmd_out);
- for (i=0; i<32; i++) {
+ ret = run_command(cmd);
+ for (i = 0; i < 32; i++) {
if (strlen(cmd_out[i]) == 0)
break;
- ma = strtok(cmd_out[i]," ");
- mi = strtok(NULL," ");
- if ( (major == atol(ma)) && (minor == atol(mi)) ) {
+ ma = strtok(cmd_out[i], " ");
+ mi = strtok(NULL, " ");
+ if ((major == atol(ma)) && (minor == atol(mi))) {
sz = strtok(NULL," ");
return atol(sz);
}
{
struct lr_server_data lsd;
char mntpt[] = "/tmp/mntXXXXXX";
- char filepnm[sizeof(mntpt) + 15];
+ char filepnm[128];
char local_mount_opts[sizeof(mop->mo_ldd.ldd_mount_opts)] = "";
FILE *filep;
int ret = 0;
+ vprint("mounting backing device\n");
/* Mount this device temporarily as ext3 in order to write this file */
if (!mkdtemp(mntpt)) {
fprintf(stderr, "Can't create temp mount point %s: %s\n",
sprintf(cmd, "mount -t ext3 %s%s %s %s",
strlen(local_mount_opts) ? "-o ": "",
local_mount_opts, mop->mo_device, mntpt);
- ret = run_command(cmd, cmd_out);
+ ret = run_command(cmd);
if (ret) {
fprintf(stderr, "Unable to mount %s\n", mop->mo_device);
+ run_command_out();
goto out_rmdir;
}
+ /* Set up initial directories */
+ sprintf(filepnm, "%s/%s", mntpt, MOUNT_CONFIGS_DIR);
+ ret = mkdir(filepnm, 0755);
+ if (ret) {
+ fprintf(stderr, "Can't make configs dir %s (%d)\n",
+ filepnm, ret);
+ goto out_umnt;
+ }
+
/* Save the persistent mount data into a file. Lustre must pre-read
this file to get the real mount options. */
+ vprint("Writing %s\n", MOUNT_DATA_FILE);
sprintf(filepnm, "%s/%s", mntpt, MOUNT_DATA_FILE);
filep = fopen(filepnm, "w");
if (!filep) {
- fprintf(stderr,"Unable to create %s file\n", filepnm);
+ fprintf(stderr, "Unable to create %s file\n", filepnm);
goto out_umnt;
}
fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
fclose(filep);
/* Create the inital last_rcvd file */
+ vprint("Writing %s\n", LAST_RCVD);
sprintf(filepnm, "%s/%s", mntpt, LAST_RCVD);
filep = fopen(filepnm, "w");
if (!filep) {
ret = 0;
fclose(filep);
out_umnt:
+ vprint("unmounting backing device\n");
sprintf(cmd, "umount %s", mntpt);
- run_command(cmd, cmd_out);
+ run_command(cmd);
out_rmdir:
rmdir(mntpt);
return ret;
}
+int create_loop_device(struct mkfs_opts *mop, char *loop_device)
+{
+ int ret = 0;
+
+ init_loop_base();
+
+ sprintf(cmd, "dd if=/dev/zero bs=1k count=0 seek=%ld of=%s",
+ mop->mo_device_sz, mop->mo_device);
+ ret = run_command(cmd);
+ if (ret != 0){
+ fprintf(stderr, "Unable to create backing store: %d\n", ret);
+ return ret;
+ }
+
+ ret = setup_loop(mop->mo_device, loop_device);
+ if (ret) {
+ fatal();
+ fprintf(stderr, "Loop device setup failed %d\n", ret);
+ }
+ return ret;
+}
+
/* Build fs according to type */
int make_lustre_backfs(struct mkfs_opts *mop)
{
- int i, ret = 0;
- int block_count = 0;
char mkfs_cmd[256];
+ char loopdev[128];
char buf[40];
+ char *dev;
+ int ret = 0;
+ int block_count = 0;
if (mop->mo_device_sz != 0) {
if (mop->mo_device_sz < 8096){
/* we really need the size */
if (device_sz == 0){
sprintf(cmd, "sfdisk -s %s", mop->mo_device);
- ret = run_command(cmd, cmd_out);
+ ret = run_command(cmd);
if (ret == 0)
device_sz = atol(cmd_out[0]);
else
return EINVAL;
}
+ dev = mop->mo_device;
+ if (mop->mo_flags & MO_IS_LOOP) {
+ /* setup a loopback file if needed */
+ ret = create_loop_device(mop, loopdev);
+ dev = loopdev;
+ if (ret)
+ return ret;
+ }
+
vprint("formatting backing filesystem %s on %s\n",
- MT_STR(&mop->mo_ldd), mop->mo_device);
- vprint("\tdevice name %s\n", mop->mo_ldd.ldd_svname);
- vprint("\t4k blocks %d\n", block_count);
- vprint("\toptions %s\n", mop->mo_mkfsopts);
+ MT_STR(&mop->mo_ldd), dev);
+ vprint("\tservice name %s\n", mop->mo_ldd.ldd_svname);
+ vprint("\t4k blocks %d\n", block_count);
+ vprint("\toptions %s\n", mop->mo_mkfsopts);
/* mkfs_cmd's trailing space is important! */
strcat(mkfs_cmd, mop->mo_mkfsopts);
strcat(mkfs_cmd, " ");
- strcat(mkfs_cmd, mop->mo_device);
+ strcat(mkfs_cmd, dev);
if (block_count != 0) {
sprintf(buf, " %d", block_count);
strcat(mkfs_cmd, buf);
}
vprint("mkfs_cmd = %s\n", mkfs_cmd);
- ret = run_command(mkfs_cmd, cmd_out);
+ ret = run_command(mkfs_cmd);
if (ret != 0) {
- fprintf(stderr, "Unable to build fs: %s \n", mop->mo_device);
- for (i = 0; i < 32; i++) {
- if (strlen(cmd_out[i]) == 0)
- break;
- fprintf(stderr, cmd_out[i]);
- }
- return EIO;
+ fatal();
+ fprintf(stderr, "Unable to build fs: %s \n", dev);
+ run_command_out();
+ goto out;
}
/* Enable hashed b-tree directory lookup in large dirs
FIXME MDT only? */
if ((mop->mo_ldd.ldd_mount_type == LDD_MT_EXT3) ||
(mop->mo_ldd.ldd_mount_type == LDD_MT_LDISKFS)) {
- sprintf(cmd, "tune2fs -O dir_index %s", mop->mo_device);
- ret = run_command(cmd, cmd_out);
+ sprintf(cmd, "tune2fs -O dir_index %s", dev);
+ ret = run_command(cmd);
if (ret) {
+ fatal();
fprintf(stderr,"Unable to enable htree: %s\n",
mop->mo_device);
- exit(4);
+ goto out;
}
}
-
- return ret;
-}
-
-int create_loop_device(struct mkfs_opts *mop)
-{
- char loop_device[20] = "";
- int ret = 0;
-
- init_loop_base();
- sprintf(cmd, "dd if=/dev/zero bs=1k count=0 seek=%ld of=%s",
- mop->mo_device_sz, mop->mo_device);
- ret = run_command(cmd, cmd_out);
- if (ret != 0){
- fprintf(stderr, "Unable to create backing store: %d\n", ret);
- return ret;
+out:
+ if (mop->mo_flags & MO_IS_LOOP) {
+ sprintf(cmd, "losetup -d %s", loopdev);
+ ret = run_command(cmd);
}
-
- ret = setup_loop(mop->mo_device, loop_device);
-
- if (ret == 0)
- /* Our device is now the loop device, not the file name */
- strcpy(mop->mo_device, loop_device);
- else
- fprintf(stderr, "Loop device setup failed %d\n", ret);
-
+
return ret;
}
return ret;
}
-#define do_jt(cmd, a...) if ((ret = _do_jt(cmd, #cmd, ## a))) goto out
+#define do_jt(cmd, a...) if ((ret = _do_jt(cmd, #cmd, ## a))) goto out_jt
#define do_jt_noret(cmd, a...) _do_jt(cmd, #cmd, ## a)
int lustre_log_setup(struct mkfs_opts *mop)
return ret;
/* FIXME can't we just write these log files ourselves? Why do we
- have to go through an obd at all? */
+ have to go through an obd at all? jt_ioc_dump()? */
/* FIXME use mgmt server obd to write logs. Can start it by mounting
I think. */
/* Set up a temporary obd for writing logs.
mop->mo_timeout, 0);
}
-out:
+out_jt:
if (ret)
/* Assume we erred while writing a record */
do_jt_noret(jt_cfg_endrecord, "endrecord", 0);
void set_defaults(struct mkfs_opts *mop)
{
- char hostname[120];
+ char hostname[128];
mop->mo_ldd.ldd_magic = LDD_MAGIC;
if (get_os_version() == 24)
memset(&mop, 0, sizeof(mop));
set_defaults(&mop);
- while ((opt = getopt_long(argc,argv,optstring,long_opt,NULL)) != EOF) {
+ while ((opt = getopt_long(argc, argv, optstring, long_opt, NULL)) !=
+ EOF) {
switch (opt) {
case 'b': {
int i = 0;
verbose++;
break;
default:
- fprintf(stderr, "%s: unknown option '%c'\n",
- progname, opt);
+ if (opt != '?') {
+ fatal();
+ fprintf(stderr, "Unknown option '%c'\n", opt);
+ }
usage(stderr);
break;
}
}//while
+ if (optind >= argc) {
+ fatal();
+ fprintf(stderr, "Bad arguments\n");
+ usage(stderr);
+ }
if (!(IS_MDT(&mop.mo_ldd) || IS_OST(&mop.mo_ldd) ||
IS_MGMT(&mop.mo_ldd))) {
- fprintf(stderr, "%s: must set server type :{mdt,ost,mgmt}\n",
- progname);
+ fatal();
+ fprintf(stderr, "must set server type :{mdt,ost,mgmt}\n");
usage(stderr);
}
}
if (mop.mo_ldd.ldd_mgmtnid.primary == PTL_NID_ANY) {
- printf("Must specify either --mgmt or --mgmtnode\n");
+ fatal();
+ fprintf(stderr, "Must specify either --mgmt or --mgmtnode\n");
usage(stderr);
}
- strcpy(mop.mo_device, argv[optind]);
-
if (IS_MDT(&mop.mo_ldd) && (mop.mo_stripe_sz == 0))
mop.mo_stripe_sz = 1024 * 1024;
+ strcpy(mop.mo_device, argv[optind]);
+
/* These are the permanent mount options. */
if ((mop.mo_ldd.ldd_mount_type == LDD_MT_EXT3) ||
(mop.mo_ldd.ldd_mount_type == LDD_MT_LDISKFS)) {
sprintf(mop.mo_ldd.ldd_mount_opts, "type=ext3,dev=%s",
mop.mo_device);
} else {
+ fatal();
fprintf(stderr, "%s: unknown fs type %d '%s'\n",
progname, mop.mo_ldd.ldd_mount_type,
MT_STR(&mop.mo_ldd));
strcat(mop.mo_ldd.ldd_mount_opts, mountopts);
}
- make_sv_name(&mop);
-
if ((mop.mo_ldd.ldd_mount_type == LDD_MT_SMFS) ||
!is_block(mop.mo_device)) {
mop.mo_flags |= MO_IS_LOOP;
- ret = create_loop_device(&mop);
- if (ret)
- return ret;
+ if (mop.mo_device_sz == 0) {
+ fatal();
+ fprintf(stderr, "loop device requires a --device_size= "
+ "param\n");
+ return EINVAL;
+ }
}
+ make_sv_name(&mop);
+
ret = make_lustre_backfs(&mop);
if (ret != 0) {
- fprintf(stderr, "mkfs failed\n");
- goto out;
+ fatal();
+ fprintf(stderr, "mkfs failed %d\n", ret);
+ return ret;
}
ret = write_local_files(&mop);
if (ret != 0) {
- fprintf(stderr, "failed to write local files\n");
- goto out;
+ fatal();
+ fprintf(stderr, "failed to write local files\n");
+ return ret;
}
ret = lustre_log_setup(&mop);
if (ret != 0) {
- fprintf(stderr, "failed to write setup logs\n");
- goto out;
- }
-
-out:
- if (mop.mo_flags & MO_IS_LOOP) {
- sprintf(cmd, "losetup -d %s", mop.mo_device);
- ret = run_command(cmd, cmd_out);
+ fatal();
+ fprintf(stderr, "failed to write setup logs\n");
+ return ret;
}
-
+
return ret;
}
--- /dev/null
+#!/bin/sh
+
+MDIR=/lib/modules/`uname -r`/lustre
+
+KVER=24
+EXT=o
+FSFLT=fsfilt_ext3
+MODFILE="/etc/modules.conf"
+if [ `uname -r | cut -c 3` -eq 6 ]; then
+ KVER=26
+ EXT=ko
+ FSFLT=fsfilt_ldiskfs
+ MODFILE="/etc/modprobe.conf"
+fi
+
+echo "Copying modules from local build dir to "$MDIR
+
+mkdir -p $MDIR
+
+cp ../../portals/libcfs/libcfs.$EXT $MDIR
+cp ../../portals/portals/portals.$EXT $MDIR
+cp ../../portals/knals/socknal/ksocknal.$EXT $MDIR
+cp ../lvfs/lvfs.$EXT $MDIR
+cp ../obdclass/obdclass.$EXT $MDIR
+cp ../ptlrpc/ptlrpc.$EXT $MDIR
+cp ../mdc/mdc.$EXT $MDIR
+cp ../osc/osc.$EXT $MDIR
+cp ../lov/lov.$EXT $MDIR
+cp ../mds/mds.$EXT $MDIR
+cp ../lvfs/$FSFLT.$EXT $MDIR
+[ $KVER == "26" ] && cp ../ldiskfs/ldiskfs.$EXT $MDIR
+cp ../ost/ost.$EXT $MDIR
+cp ../obdfilter/obdfilter.$EXT $MDIR
+cp ../llite/llite.$EXT $MDIR
+
+# prevent warnings on my uml
+rm -f /lib/modules/`uname -r`/modules.*
+echo "Depmod"
+depmod -a -e
+
+echo "Copying mount from local build dir to "$MDIR
+cp ../utils/mount.lustre /sbin/.
+
+[ -e $MODFILE ] || touch $MODFILE
+if [ `grep -c lustre $MODFILE` -eq 0 ]; then
+ echo Modifying $MODFILE
+ echo "# Lustre modules added by $0" >> $MODFILE
+ if [ $KVER -eq 24 ]; then
+ echo alias lustre null >> $MODFILE
+ echo above lustre llite osc mdc >> $MODFILE
+ echo above mds llite osc $FSFLT >> $MODFILE
+ echo alias oss ost >> $MODFILE
+ echo above ost llite obdfilter $FSFLT >> $MODFILE
+ echo below ptlrpc ksocknal >> $MODFILE
+ else
+ MP="/sbin/modprobe"
+ MPI="$MP --ignore-install"
+ echo "install kptlrouter $MP portals && $MPI kptlrouter" >> $MODFILE
+ echo "install ptlrpc $MP ksocknal && $MPI ptlrpc" >> $MODFILE
+ echo "install ost $MP obdfilter $FSFLT && $MPI ost" >> $MODFILE
+ echo "install oss $MP ost && $MPI oss" >> $MODFILE
+ echo "install mds $MP osc $FSFLT && $MPI mds" >> $MODFILE
+ echo "install llite $MP osc mdc && $MPI llite" >> $MODFILE
+ echo "alias lustre llite" >> $MODFILE
+ fi
+ echo "# end Lustre modules" >> $MODFILE
+fi
+
--- /dev/null
+#!/bin/sh
+
+rmmod llite
+rmmod mdc
+rmmod lov
+rmmod osc
+rmmod obdfilter
+rmmod fsfilt_ext3
+rmmod fsfilt_ldiskfs
+rmmod ldiskfs
+rmmod ost
+rmmod mds
+rmmod ptlrpc
+rmmod obdclass
+rmmod lvfs
+rmmod ksocknal
+rmmod portals
+rmmod libcfs