1 // SPDX-License-Identifier: GPL-2.0-or-later 2 3 /* 4 * SPU file system 5 * 6 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 7 * 8 * Author: Arnd Bergmann <arndb@de.ibm.com> 9 */ 10 11 #include <linux/file.h> 12 #include <linux/fs.h> 13 #include <linux/fs_context.h> 14 #include <linux/fs_parser.h> 15 #include <linux/fsnotify.h> 16 #include <linux/backing-dev.h> 17 #include <linux/init.h> 18 #include <linux/ioctl.h> 19 #include <linux/module.h> 20 #include <linux/mount.h> 21 #include <linux/namei.h> 22 #include <linux/pagemap.h> 23 #include <linux/poll.h> 24 #include <linux/of.h> 25 #include <linux/seq_file.h> 26 #include <linux/slab.h> 27 28 #include <asm/spu.h> 29 #include <asm/spu_priv1.h> 30 #include <linux/uaccess.h> 31 32 #include "spufs.h" 33 34 struct spufs_sb_info { 35 bool debug; 36 }; 37 38 static struct kmem_cache *spufs_inode_cache; 39 char *isolated_loader; 40 static int isolated_loader_size; 41 42 static struct spufs_sb_info *spufs_get_sb_info(struct super_block *sb) 43 { 44 return sb->s_fs_info; 45 } 46 47 static struct inode * 48 spufs_alloc_inode(struct super_block *sb) 49 { 50 struct spufs_inode_info *ei; 51 52 ei = kmem_cache_alloc(spufs_inode_cache, GFP_KERNEL); 53 if (!ei) 54 return NULL; 55 56 ei->i_gang = NULL; 57 ei->i_ctx = NULL; 58 ei->i_openers = 0; 59 60 return &ei->vfs_inode; 61 } 62 63 static void spufs_free_inode(struct inode *inode) 64 { 65 kmem_cache_free(spufs_inode_cache, SPUFS_I(inode)); 66 } 67 68 static void 69 spufs_init_once(void *p) 70 { 71 struct spufs_inode_info *ei = p; 72 73 inode_init_once(&ei->vfs_inode); 74 } 75 76 static struct inode * 77 spufs_new_inode(struct super_block *sb, umode_t mode) 78 { 79 struct inode *inode; 80 81 inode = new_inode(sb); 82 if (!inode) 83 goto out; 84 85 inode->i_ino = get_next_ino(); 86 inode->i_mode = mode; 87 inode->i_uid = current_fsuid(); 88 inode->i_gid = current_fsgid(); 89 simple_inode_init_ts(inode); 90 out: 91 return inode; 92 } 93 94 static int 95 spufs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, 96 struct iattr *attr) 97 { 98 struct inode *inode = d_inode(dentry); 99 100 if ((attr->ia_valid & ATTR_SIZE) && 101 (attr->ia_size != inode->i_size)) 102 return -EINVAL; 103 setattr_copy(&nop_mnt_idmap, inode, attr); 104 mark_inode_dirty(inode); 105 return 0; 106 } 107 108 109 static int 110 spufs_new_file(struct super_block *sb, struct dentry *dentry, 111 const struct file_operations *fops, umode_t mode, 112 size_t size, struct spu_context *ctx) 113 { 114 static const struct inode_operations spufs_file_iops = { 115 .setattr = spufs_setattr, 116 }; 117 struct inode *inode; 118 int ret; 119 120 ret = -ENOSPC; 121 inode = spufs_new_inode(sb, S_IFREG | mode); 122 if (!inode) 123 goto out; 124 125 ret = 0; 126 inode->i_op = &spufs_file_iops; 127 inode->i_fop = fops; 128 inode->i_size = size; 129 inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx); 130 d_add(dentry, inode); 131 out: 132 return ret; 133 } 134 135 static void 136 spufs_evict_inode(struct inode *inode) 137 { 138 struct spufs_inode_info *ei = SPUFS_I(inode); 139 clear_inode(inode); 140 if (ei->i_ctx) 141 put_spu_context(ei->i_ctx); 142 if (ei->i_gang) 143 put_spu_gang(ei->i_gang); 144 } 145 146 /* Caller must hold parent->i_mutex */ 147 static void spufs_rmdir(struct inode *parent, struct dentry *dir) 148 { 149 struct spu_context *ctx = SPUFS_I(d_inode(dir))->i_ctx; 150 151 locked_recursive_removal(dir, NULL); 152 spu_forget(ctx); 153 } 154 155 static int spufs_fill_dir(struct dentry *dir, 156 const struct spufs_tree_descr *files, umode_t mode, 157 struct spu_context *ctx) 158 { 159 while (files->name && files->name[0]) { 160 int ret; 161 struct dentry *dentry = d_alloc_name(dir, files->name); 162 if (!dentry) 163 return -ENOMEM; 164 ret = spufs_new_file(dir->d_sb, dentry, files->ops, 165 files->mode & mode, files->size, ctx); 166 if (ret) { 167 dput(dentry); 168 return ret; 169 } 170 files++; 171 } 172 return 0; 173 } 174 175 static void unuse_gang(struct dentry *dir) 176 { 177 struct inode *inode = dir->d_inode; 178 struct spu_gang *gang = SPUFS_I(inode)->i_gang; 179 180 if (gang) { 181 bool dead; 182 183 inode_lock(inode); // exclusion with spufs_create_context() 184 dead = !--gang->alive; 185 inode_unlock(inode); 186 187 if (dead) 188 simple_recursive_removal(dir, NULL); 189 } 190 } 191 192 static int spufs_dir_close(struct inode *inode, struct file *file) 193 { 194 struct inode *parent; 195 struct dentry *dir; 196 197 dir = file->f_path.dentry; 198 parent = d_inode(dir->d_parent); 199 200 inode_lock_nested(parent, I_MUTEX_PARENT); 201 spufs_rmdir(parent, dir); 202 inode_unlock(parent); 203 204 unuse_gang(dir->d_parent); 205 return dcache_dir_close(inode, file); 206 } 207 208 const struct file_operations spufs_context_fops = { 209 .open = dcache_dir_open, 210 .release = spufs_dir_close, 211 .llseek = dcache_dir_lseek, 212 .read = generic_read_dir, 213 .iterate_shared = dcache_readdir, 214 .fsync = noop_fsync, 215 }; 216 EXPORT_SYMBOL_GPL(spufs_context_fops); 217 218 static int 219 spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags, 220 umode_t mode) 221 { 222 int ret; 223 struct inode *inode; 224 struct spu_context *ctx; 225 226 inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR); 227 if (!inode) 228 return -ENOSPC; 229 230 inode_init_owner(&nop_mnt_idmap, inode, dir, mode | S_IFDIR); 231 ctx = alloc_spu_context(SPUFS_I(dir)->i_gang); /* XXX gang */ 232 SPUFS_I(inode)->i_ctx = ctx; 233 if (!ctx) { 234 iput(inode); 235 return -ENOSPC; 236 } 237 238 ctx->flags = flags; 239 inode->i_op = &simple_dir_inode_operations; 240 inode->i_fop = &simple_dir_operations; 241 242 inode_lock(inode); 243 244 dget(dentry); 245 inc_nlink(dir); 246 inc_nlink(inode); 247 248 d_instantiate(dentry, inode); 249 250 if (flags & SPU_CREATE_NOSCHED) 251 ret = spufs_fill_dir(dentry, spufs_dir_nosched_contents, 252 mode, ctx); 253 else 254 ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx); 255 256 if (!ret && spufs_get_sb_info(dir->i_sb)->debug) 257 ret = spufs_fill_dir(dentry, spufs_dir_debug_contents, 258 mode, ctx); 259 260 inode_unlock(inode); 261 262 if (ret) 263 spufs_rmdir(dir, dentry); 264 265 return ret; 266 } 267 268 static int spufs_context_open(const struct path *path) 269 { 270 FD_PREPARE(fdf, 0, dentry_open(path, O_RDONLY, current_cred())); 271 if (fdf.err) 272 return fdf.err; 273 fd_prepare_file(fdf)->f_op = &spufs_context_fops; 274 return fd_publish(fdf); 275 } 276 277 static struct spu_context * 278 spufs_assert_affinity(unsigned int flags, struct spu_gang *gang, 279 struct file *filp) 280 { 281 struct spu_context *tmp, *neighbor, *err; 282 int count, node; 283 int aff_supp; 284 285 aff_supp = !list_empty(&(list_entry(cbe_spu_info[0].spus.next, 286 struct spu, cbe_list))->aff_list); 287 288 if (!aff_supp) 289 return ERR_PTR(-EINVAL); 290 291 if (flags & SPU_CREATE_GANG) 292 return ERR_PTR(-EINVAL); 293 294 if (flags & SPU_CREATE_AFFINITY_MEM && 295 gang->aff_ref_ctx && 296 gang->aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM) 297 return ERR_PTR(-EEXIST); 298 299 if (gang->aff_flags & AFF_MERGED) 300 return ERR_PTR(-EBUSY); 301 302 neighbor = NULL; 303 if (flags & SPU_CREATE_AFFINITY_SPU) { 304 if (!filp || filp->f_op != &spufs_context_fops) 305 return ERR_PTR(-EINVAL); 306 307 neighbor = get_spu_context( 308 SPUFS_I(file_inode(filp))->i_ctx); 309 310 if (!list_empty(&neighbor->aff_list) && !(neighbor->aff_head) && 311 !list_is_last(&neighbor->aff_list, &gang->aff_list_head) && 312 !list_entry(neighbor->aff_list.next, struct spu_context, 313 aff_list)->aff_head) { 314 err = ERR_PTR(-EEXIST); 315 goto out_put_neighbor; 316 } 317 318 if (gang != neighbor->gang) { 319 err = ERR_PTR(-EINVAL); 320 goto out_put_neighbor; 321 } 322 323 count = 1; 324 list_for_each_entry(tmp, &gang->aff_list_head, aff_list) 325 count++; 326 if (list_empty(&neighbor->aff_list)) 327 count++; 328 329 for (node = 0; node < MAX_NUMNODES; node++) { 330 if ((cbe_spu_info[node].n_spus - atomic_read( 331 &cbe_spu_info[node].reserved_spus)) >= count) 332 break; 333 } 334 335 if (node == MAX_NUMNODES) { 336 err = ERR_PTR(-EEXIST); 337 goto out_put_neighbor; 338 } 339 } 340 341 return neighbor; 342 343 out_put_neighbor: 344 put_spu_context(neighbor); 345 return err; 346 } 347 348 static void 349 spufs_set_affinity(unsigned int flags, struct spu_context *ctx, 350 struct spu_context *neighbor) 351 { 352 if (flags & SPU_CREATE_AFFINITY_MEM) 353 ctx->gang->aff_ref_ctx = ctx; 354 355 if (flags & SPU_CREATE_AFFINITY_SPU) { 356 if (list_empty(&neighbor->aff_list)) { 357 list_add_tail(&neighbor->aff_list, 358 &ctx->gang->aff_list_head); 359 neighbor->aff_head = 1; 360 } 361 362 if (list_is_last(&neighbor->aff_list, &ctx->gang->aff_list_head) 363 || list_entry(neighbor->aff_list.next, struct spu_context, 364 aff_list)->aff_head) { 365 list_add(&ctx->aff_list, &neighbor->aff_list); 366 } else { 367 list_add_tail(&ctx->aff_list, &neighbor->aff_list); 368 if (neighbor->aff_head) { 369 neighbor->aff_head = 0; 370 ctx->aff_head = 1; 371 } 372 } 373 374 if (!ctx->gang->aff_ref_ctx) 375 ctx->gang->aff_ref_ctx = ctx; 376 } 377 } 378 379 static int 380 spufs_create_context(struct inode *inode, struct dentry *dentry, 381 struct vfsmount *mnt, int flags, umode_t mode, 382 struct file *aff_filp) 383 { 384 int ret; 385 int affinity; 386 struct spu_gang *gang = SPUFS_I(inode)->i_gang; 387 struct spu_context *neighbor; 388 struct path path = {.mnt = mnt, .dentry = dentry}; 389 390 if ((flags & SPU_CREATE_NOSCHED) && 391 !capable(CAP_SYS_NICE)) 392 return -EPERM; 393 394 if ((flags & (SPU_CREATE_NOSCHED | SPU_CREATE_ISOLATE)) 395 == SPU_CREATE_ISOLATE) 396 return -EINVAL; 397 398 if ((flags & SPU_CREATE_ISOLATE) && !isolated_loader) 399 return -ENODEV; 400 401 if (gang) { 402 if (!gang->alive) 403 return -ENOENT; 404 gang->alive++; 405 } 406 407 neighbor = NULL; 408 affinity = flags & (SPU_CREATE_AFFINITY_MEM | SPU_CREATE_AFFINITY_SPU); 409 if (affinity) { 410 if (!gang) 411 return -EINVAL; 412 mutex_lock(&gang->aff_mutex); 413 neighbor = spufs_assert_affinity(flags, gang, aff_filp); 414 if (IS_ERR(neighbor)) { 415 ret = PTR_ERR(neighbor); 416 goto out_aff_unlock; 417 } 418 } 419 420 ret = spufs_mkdir(inode, dentry, flags, mode & 0777); 421 if (ret) { 422 if (neighbor) 423 put_spu_context(neighbor); 424 goto out_aff_unlock; 425 } 426 427 if (affinity) { 428 spufs_set_affinity(flags, SPUFS_I(d_inode(dentry))->i_ctx, 429 neighbor); 430 if (neighbor) 431 put_spu_context(neighbor); 432 } 433 434 ret = spufs_context_open(&path); 435 if (ret < 0) 436 spufs_rmdir(inode, dentry); 437 438 out_aff_unlock: 439 if (affinity) 440 mutex_unlock(&gang->aff_mutex); 441 if (ret && gang) 442 gang->alive--; // can't reach 0 443 return ret; 444 } 445 446 static int 447 spufs_mkgang(struct inode *dir, struct dentry *dentry, umode_t mode) 448 { 449 int ret; 450 struct inode *inode; 451 struct spu_gang *gang; 452 453 ret = -ENOSPC; 454 inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR); 455 if (!inode) 456 goto out; 457 458 ret = 0; 459 inode_init_owner(&nop_mnt_idmap, inode, dir, mode | S_IFDIR); 460 gang = alloc_spu_gang(); 461 SPUFS_I(inode)->i_ctx = NULL; 462 SPUFS_I(inode)->i_gang = gang; 463 if (!gang) { 464 ret = -ENOMEM; 465 goto out_iput; 466 } 467 468 inode->i_op = &simple_dir_inode_operations; 469 inode->i_fop = &simple_dir_operations; 470 471 d_instantiate(dentry, inode); 472 dget(dentry); 473 inc_nlink(dir); 474 inc_nlink(d_inode(dentry)); 475 return ret; 476 477 out_iput: 478 iput(inode); 479 out: 480 return ret; 481 } 482 483 static int spufs_gang_close(struct inode *inode, struct file *file) 484 { 485 unuse_gang(file->f_path.dentry); 486 return dcache_dir_close(inode, file); 487 } 488 489 static const struct file_operations spufs_gang_fops = { 490 .open = dcache_dir_open, 491 .release = spufs_gang_close, 492 .llseek = dcache_dir_lseek, 493 .read = generic_read_dir, 494 .iterate_shared = dcache_readdir, 495 .fsync = noop_fsync, 496 }; 497 498 static int spufs_gang_open(const struct path *path) 499 { 500 /* 501 * get references for dget and mntget, will be released 502 * in error path of *_open(). 503 */ 504 FD_PREPARE(fdf, 0, dentry_open(path, O_RDONLY, current_cred())); 505 if (fdf.err) 506 return fdf.err; 507 fd_prepare_file(fdf)->f_op = &spufs_gang_fops; 508 return fd_publish(fdf); 509 } 510 511 static int spufs_create_gang(struct inode *inode, 512 struct dentry *dentry, 513 struct vfsmount *mnt, umode_t mode) 514 { 515 struct path path = {.mnt = mnt, .dentry = dentry}; 516 int ret; 517 518 ret = spufs_mkgang(inode, dentry, mode & 0777); 519 if (!ret) { 520 ret = spufs_gang_open(&path); 521 if (ret < 0) 522 unuse_gang(dentry); 523 } 524 return ret; 525 } 526 527 528 static struct file_system_type spufs_type; 529 530 long spufs_create(const struct path *path, struct dentry *dentry, 531 unsigned int flags, umode_t mode, struct file *filp) 532 { 533 struct inode *dir = d_inode(path->dentry); 534 int ret; 535 536 /* check if we are on spufs */ 537 if (path->dentry->d_sb->s_type != &spufs_type) 538 return -EINVAL; 539 540 /* don't accept undefined flags */ 541 if (flags & (~SPU_CREATE_FLAG_ALL)) 542 return -EINVAL; 543 544 /* only threads can be underneath a gang */ 545 if (path->dentry != path->dentry->d_sb->s_root) 546 if ((flags & SPU_CREATE_GANG) || !SPUFS_I(dir)->i_gang) 547 return -EINVAL; 548 549 mode &= ~current_umask(); 550 551 if (flags & SPU_CREATE_GANG) 552 ret = spufs_create_gang(dir, dentry, path->mnt, mode); 553 else 554 ret = spufs_create_context(dir, dentry, path->mnt, flags, mode, 555 filp); 556 if (ret >= 0) 557 fsnotify_mkdir(dir, dentry); 558 559 return ret; 560 } 561 562 /* File system initialization */ 563 struct spufs_fs_context { 564 kuid_t uid; 565 kgid_t gid; 566 umode_t mode; 567 }; 568 569 enum { 570 Opt_uid, Opt_gid, Opt_mode, Opt_debug, 571 }; 572 573 static const struct fs_parameter_spec spufs_fs_parameters[] = { 574 fsparam_u32 ("gid", Opt_gid), 575 fsparam_u32oct ("mode", Opt_mode), 576 fsparam_u32 ("uid", Opt_uid), 577 fsparam_flag ("debug", Opt_debug), 578 {} 579 }; 580 581 static int spufs_show_options(struct seq_file *m, struct dentry *root) 582 { 583 struct spufs_sb_info *sbi = spufs_get_sb_info(root->d_sb); 584 struct inode *inode = root->d_inode; 585 586 if (!uid_eq(inode->i_uid, GLOBAL_ROOT_UID)) 587 seq_printf(m, ",uid=%u", 588 from_kuid_munged(&init_user_ns, inode->i_uid)); 589 if (!gid_eq(inode->i_gid, GLOBAL_ROOT_GID)) 590 seq_printf(m, ",gid=%u", 591 from_kgid_munged(&init_user_ns, inode->i_gid)); 592 if ((inode->i_mode & S_IALLUGO) != 0775) 593 seq_printf(m, ",mode=%o", inode->i_mode); 594 if (sbi->debug) 595 seq_puts(m, ",debug"); 596 return 0; 597 } 598 599 static int spufs_parse_param(struct fs_context *fc, struct fs_parameter *param) 600 { 601 struct spufs_fs_context *ctx = fc->fs_private; 602 struct spufs_sb_info *sbi = fc->s_fs_info; 603 struct fs_parse_result result; 604 kuid_t uid; 605 kgid_t gid; 606 int opt; 607 608 opt = fs_parse(fc, spufs_fs_parameters, param, &result); 609 if (opt < 0) 610 return opt; 611 612 switch (opt) { 613 case Opt_uid: 614 uid = make_kuid(current_user_ns(), result.uint_32); 615 if (!uid_valid(uid)) 616 return invalf(fc, "Unknown uid"); 617 ctx->uid = uid; 618 break; 619 case Opt_gid: 620 gid = make_kgid(current_user_ns(), result.uint_32); 621 if (!gid_valid(gid)) 622 return invalf(fc, "Unknown gid"); 623 ctx->gid = gid; 624 break; 625 case Opt_mode: 626 ctx->mode = result.uint_32 & S_IALLUGO; 627 break; 628 case Opt_debug: 629 sbi->debug = true; 630 break; 631 } 632 633 return 0; 634 } 635 636 static void spufs_exit_isolated_loader(void) 637 { 638 free_pages((unsigned long) isolated_loader, 639 get_order(isolated_loader_size)); 640 } 641 642 static void __init 643 spufs_init_isolated_loader(void) 644 { 645 struct device_node *dn; 646 const char *loader; 647 int size; 648 649 dn = of_find_node_by_path("/spu-isolation"); 650 if (!dn) 651 return; 652 653 loader = of_get_property(dn, "loader", &size); 654 of_node_put(dn); 655 if (!loader) 656 return; 657 658 /* the loader must be align on a 16 byte boundary */ 659 isolated_loader = (char *)__get_free_pages(GFP_KERNEL, get_order(size)); 660 if (!isolated_loader) 661 return; 662 663 isolated_loader_size = size; 664 memcpy(isolated_loader, loader, size); 665 printk(KERN_INFO "spufs: SPU isolation mode enabled\n"); 666 } 667 668 static int spufs_create_root(struct super_block *sb, struct fs_context *fc) 669 { 670 struct spufs_fs_context *ctx = fc->fs_private; 671 struct inode *inode; 672 673 if (!spu_management_ops) 674 return -ENODEV; 675 676 inode = spufs_new_inode(sb, S_IFDIR | ctx->mode); 677 if (!inode) 678 return -ENOMEM; 679 680 inode->i_uid = ctx->uid; 681 inode->i_gid = ctx->gid; 682 inode->i_op = &simple_dir_inode_operations; 683 inode->i_fop = &simple_dir_operations; 684 SPUFS_I(inode)->i_ctx = NULL; 685 inc_nlink(inode); 686 687 sb->s_root = d_make_root(inode); 688 if (!sb->s_root) 689 return -ENOMEM; 690 return 0; 691 } 692 693 static const struct super_operations spufs_ops = { 694 .alloc_inode = spufs_alloc_inode, 695 .free_inode = spufs_free_inode, 696 .statfs = simple_statfs, 697 .evict_inode = spufs_evict_inode, 698 .show_options = spufs_show_options, 699 }; 700 701 static int spufs_fill_super(struct super_block *sb, struct fs_context *fc) 702 { 703 sb->s_maxbytes = MAX_LFS_FILESIZE; 704 sb->s_blocksize = PAGE_SIZE; 705 sb->s_blocksize_bits = PAGE_SHIFT; 706 sb->s_magic = SPUFS_MAGIC; 707 sb->s_op = &spufs_ops; 708 709 return spufs_create_root(sb, fc); 710 } 711 712 static int spufs_get_tree(struct fs_context *fc) 713 { 714 return get_tree_single(fc, spufs_fill_super); 715 } 716 717 static void spufs_free_fc(struct fs_context *fc) 718 { 719 kfree(fc->s_fs_info); 720 } 721 722 static const struct fs_context_operations spufs_context_ops = { 723 .free = spufs_free_fc, 724 .parse_param = spufs_parse_param, 725 .get_tree = spufs_get_tree, 726 }; 727 728 static int spufs_init_fs_context(struct fs_context *fc) 729 { 730 struct spufs_fs_context *ctx; 731 struct spufs_sb_info *sbi; 732 733 ctx = kzalloc(sizeof(struct spufs_fs_context), GFP_KERNEL); 734 if (!ctx) 735 goto nomem; 736 737 sbi = kzalloc(sizeof(struct spufs_sb_info), GFP_KERNEL); 738 if (!sbi) 739 goto nomem_ctx; 740 741 ctx->uid = current_uid(); 742 ctx->gid = current_gid(); 743 ctx->mode = 0755; 744 745 fc->fs_private = ctx; 746 fc->s_fs_info = sbi; 747 fc->ops = &spufs_context_ops; 748 return 0; 749 750 nomem_ctx: 751 kfree(ctx); 752 nomem: 753 return -ENOMEM; 754 } 755 756 static struct file_system_type spufs_type = { 757 .owner = THIS_MODULE, 758 .name = "spufs", 759 .init_fs_context = spufs_init_fs_context, 760 .parameters = spufs_fs_parameters, 761 .kill_sb = kill_litter_super, 762 }; 763 MODULE_ALIAS_FS("spufs"); 764 765 static int __init spufs_init(void) 766 { 767 int ret; 768 769 ret = -ENODEV; 770 if (!spu_management_ops) 771 goto out; 772 773 ret = -ENOMEM; 774 spufs_inode_cache = kmem_cache_create("spufs_inode_cache", 775 sizeof(struct spufs_inode_info), 0, 776 SLAB_HWCACHE_ALIGN|SLAB_ACCOUNT, spufs_init_once); 777 778 if (!spufs_inode_cache) 779 goto out; 780 ret = spu_sched_init(); 781 if (ret) 782 goto out_cache; 783 ret = register_spu_syscalls(&spufs_calls); 784 if (ret) 785 goto out_sched; 786 ret = register_filesystem(&spufs_type); 787 if (ret) 788 goto out_syscalls; 789 790 spufs_init_isolated_loader(); 791 792 return 0; 793 794 out_syscalls: 795 unregister_spu_syscalls(&spufs_calls); 796 out_sched: 797 spu_sched_exit(); 798 out_cache: 799 kmem_cache_destroy(spufs_inode_cache); 800 out: 801 return ret; 802 } 803 module_init(spufs_init); 804 805 static void __exit spufs_exit(void) 806 { 807 spu_sched_exit(); 808 spufs_exit_isolated_loader(); 809 unregister_spu_syscalls(&spufs_calls); 810 unregister_filesystem(&spufs_type); 811 kmem_cache_destroy(spufs_inode_cache); 812 } 813 module_exit(spufs_exit); 814 815 MODULE_DESCRIPTION("SPU file system"); 816 MODULE_LICENSE("GPL"); 817 MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>"); 818 819