-
-struct lustre_mount_data2 {
- void *lmd2_data;
- struct vfsmount *lmd2_mnt;
-};
-
-/** This is the entry point for the mount call into Lustre.
- * This is called when a server or client is mounted,
- * and this is where we start setting things up.
- * @param data Mount options (e.g. -o flock,abort_recov)
- */
-static int lustre_fill_super(struct super_block *sb, void *data, int silent)
-{
- struct lustre_mount_data *lmd;
- struct lustre_mount_data2 *lmd2 = data;
- struct lustre_sb_info *lsi;
- int rc;
- ENTRY;
-
- CDEBUG(D_MOUNT|D_VFSTRACE, "VFS Op: sb %p\n", sb);
-
- lsi = lustre_init_lsi(sb);
- if (!lsi)
- RETURN(-ENOMEM);
- lmd = lsi->lsi_lmd;
-
- /*
- * Disable lockdep during mount, because mount locking patterns are
- * `special'.
- */
- lockdep_off();
-
- /*
- * LU-639: the obd cleanup of last mount may not finish yet, wait here.
- */
- obd_zombie_barrier();
-
- /* Figure out the lmd from the mount options */
- if (lmd_parse((char *)(lmd2->lmd2_data), lmd)) {
- lustre_put_lsi(sb);
- GOTO(out, rc = -EINVAL);
- }
-
- if (lmd_is_client(lmd)) {
- CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile);
- if (client_fill_super == NULL)
- request_module("lustre");
- if (client_fill_super == NULL) {
- LCONSOLE_ERROR_MSG(0x165, "Nothing registered for "
- "client mount! Is the 'lustre' "
- "module loaded?\n");
- lustre_put_lsi(sb);
- rc = -ENODEV;
- } else {
- rc = lustre_start_mgc(sb);
- if (rc) {
- lustre_common_put_super(sb);
- GOTO(out, rc);
- }
- /* Connect and start */
- /* (should always be ll_fill_super) */
- rc = (*client_fill_super)(sb, lmd2->lmd2_mnt);
- /* c_f_s will call lustre_common_put_super on failure */
- }
- } else {
-#ifdef HAVE_SERVER_SUPPORT
- CDEBUG(D_MOUNT, "Mounting server from %s\n", lmd->lmd_dev);
- rc = server_fill_super(sb);
- /* s_f_s calls lustre_start_mgc after the mount because we need
- the MGS nids which are stored on disk. Plus, we may
- need to start the MGS first. */
- /* s_f_s will call server_put_super on failure */
-#else
- CERROR("This is client-side-only module, "
- "cannot handle server mount.\n");
- rc = -EINVAL;
-#endif
- }
-
- /* If error happens in fill_super() call, @lsi will be killed there.
- * This is why we do not put it here. */
- GOTO(out, rc);
-out:
- if (rc) {
- CERROR("Unable to mount %s (%d)\n",
- s2lsi(sb) ? lmd->lmd_dev : "", rc);
- } else {
- CDEBUG(D_SUPER, "Mount %s complete\n",
- lmd->lmd_dev);
- }
- lockdep_on();
- return rc;
-}
-
-
-/* We can't call ll_fill_super by name because it lives in a module that
- must be loaded after this one. */
-void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb,
- struct vfsmount *mnt))
-{
- client_fill_super = cfs;
-}
-EXPORT_SYMBOL(lustre_register_client_fill_super);
-
-void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb))
-{
- kill_super_cb = cfs;
-}
-EXPORT_SYMBOL(lustre_register_kill_super_cb);
-
-/***************** FS registration ******************/
-#ifdef HAVE_FSTYPE_MOUNT
-static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags,
- const char *devname, void *data)
-{
- struct lustre_mount_data2 lmd2 = {
- .lmd2_data = data,
- };
-
- return mount_nodev(fs_type, flags, &lmd2, lustre_fill_super);
-}
-#else
-static int lustre_get_sb(struct file_system_type *fs_type, int flags,
- const char *devname, void *data, struct vfsmount *mnt)
-{
- struct lustre_mount_data2 lmd2 = {
- .lmd2_data = data,
- .lmd2_mnt = mnt,
- };
-
- return get_sb_nodev(fs_type, flags, &lmd2, lustre_fill_super, mnt);
-}
-#endif
-
-static void lustre_kill_super(struct super_block *sb)
-{
- struct lustre_sb_info *lsi = s2lsi(sb);
-
- if (kill_super_cb && lsi && !IS_SERVER(lsi))
- (*kill_super_cb)(sb);
-
- kill_anon_super(sb);
-}
-
-/** Register the "lustre" fs type
- */
-static struct file_system_type lustre_fs_type = {
- .owner = THIS_MODULE,
- .name = "lustre",
-#ifdef HAVE_FSTYPE_MOUNT
- .mount = lustre_mount,
-#else
- .get_sb = lustre_get_sb,
-#endif
- .kill_sb = lustre_kill_super,
- .fs_flags = FS_REQUIRES_DEV | FS_HAS_FIEMAP | FS_RENAME_DOES_D_MOVE,
-};
-MODULE_ALIAS_FS("lustre");
-
-int lustre_register_fs(void)
-{
- return register_filesystem(&lustre_fs_type);
-}
-
-int lustre_unregister_fs(void)
-{
- return unregister_filesystem(&lustre_fs_type);
-}