inode.c (3ad11d7ac8872b1c8da54494721fad8907ee41f7) | inode.c (694565356c2e06224d94774a42709cc8dfab49ee) |
---|---|
1/* 2 FUSE: Filesystem in Userspace 3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> 4 5 This program can be distributed under the terms of the GNU GPL. 6 See the file COPYING. 7*/ 8 --- 71 unchanged lines hidden (view full) --- 80 fi->i_time = 0; 81 fi->inval_mask = 0; 82 fi->nodeid = 0; 83 fi->nlookup = 0; 84 fi->attr_version = 0; 85 fi->orig_ino = 0; 86 fi->state = 0; 87 mutex_init(&fi->mutex); | 1/* 2 FUSE: Filesystem in Userspace 3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> 4 5 This program can be distributed under the terms of the GNU GPL. 6 See the file COPYING. 7*/ 8 --- 71 unchanged lines hidden (view full) --- 80 fi->i_time = 0; 81 fi->inval_mask = 0; 82 fi->nodeid = 0; 83 fi->nlookup = 0; 84 fi->attr_version = 0; 85 fi->orig_ino = 0; 86 fi->state = 0; 87 mutex_init(&fi->mutex); |
88 init_rwsem(&fi->i_mmap_sem); |
|
88 spin_lock_init(&fi->lock); 89 fi->forget = fuse_alloc_forget(); | 89 spin_lock_init(&fi->lock); 90 fi->forget = fuse_alloc_forget(); |
90 if (!fi->forget) { 91 kmem_cache_free(fuse_inode_cachep, fi); 92 return NULL; 93 } | 91 if (!fi->forget) 92 goto out_free; |
94 | 93 |
94 if (IS_ENABLED(CONFIG_FUSE_DAX) && !fuse_dax_inode_alloc(sb, fi)) 95 goto out_free_forget; 96 |
|
95 return &fi->inode; | 97 return &fi->inode; |
98 99out_free_forget: 100 kfree(fi->forget); 101out_free: 102 kmem_cache_free(fuse_inode_cachep, fi); 103 return NULL; |
|
96} 97 98static void fuse_free_inode(struct inode *inode) 99{ 100 struct fuse_inode *fi = get_fuse_inode(inode); 101 102 mutex_destroy(&fi->mutex); 103 kfree(fi->forget); | 104} 105 106static void fuse_free_inode(struct inode *inode) 107{ 108 struct fuse_inode *fi = get_fuse_inode(inode); 109 110 mutex_destroy(&fi->mutex); 111 kfree(fi->forget); |
112#ifdef CONFIG_FUSE_DAX 113 kfree(fi->dax); 114#endif |
|
104 kmem_cache_free(fuse_inode_cachep, fi); 105} 106 107static void fuse_evict_inode(struct inode *inode) 108{ 109 struct fuse_inode *fi = get_fuse_inode(inode); 110 111 truncate_inode_pages_final(&inode->i_data); 112 clear_inode(inode); 113 if (inode->i_sb->s_flags & SB_ACTIVE) { 114 struct fuse_conn *fc = get_fuse_conn(inode); | 115 kmem_cache_free(fuse_inode_cachep, fi); 116} 117 118static void fuse_evict_inode(struct inode *inode) 119{ 120 struct fuse_inode *fi = get_fuse_inode(inode); 121 122 truncate_inode_pages_final(&inode->i_data); 123 clear_inode(inode); 124 if (inode->i_sb->s_flags & SB_ACTIVE) { 125 struct fuse_conn *fc = get_fuse_conn(inode); |
115 fuse_queue_forget(fc, fi->forget, fi->nodeid, fi->nlookup); 116 fi->forget = NULL; | 126 127 if (FUSE_IS_DAX(inode)) 128 fuse_dax_inode_cleanup(inode); 129 if (fi->nlookup) { 130 fuse_queue_forget(fc, fi->forget, fi->nodeid, 131 fi->nlookup); 132 fi->forget = NULL; 133 } |
117 } 118 if (S_ISREG(inode->i_mode) && !is_bad_inode(inode)) { 119 WARN_ON(!list_empty(&fi->write_files)); 120 WARN_ON(!list_empty(&fi->queued_writes)); 121 } 122} 123 124static int fuse_reconfigure(struct fs_context *fc) --- 138 unchanged lines hidden (view full) --- 263 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { 264 fuse_init_common(inode); 265 init_special_inode(inode, inode->i_mode, 266 new_decode_dev(attr->rdev)); 267 } else 268 BUG(); 269} 270 | 134 } 135 if (S_ISREG(inode->i_mode) && !is_bad_inode(inode)) { 136 WARN_ON(!list_empty(&fi->write_files)); 137 WARN_ON(!list_empty(&fi->queued_writes)); 138 } 139} 140 141static int fuse_reconfigure(struct fs_context *fc) --- 138 unchanged lines hidden (view full) --- 280 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { 281 fuse_init_common(inode); 282 init_special_inode(inode, inode->i_mode, 283 new_decode_dev(attr->rdev)); 284 } else 285 BUG(); 286} 287 |
271int fuse_inode_eq(struct inode *inode, void *_nodeidp) | 288static int fuse_inode_eq(struct inode *inode, void *_nodeidp) |
272{ 273 u64 nodeid = *(u64 *) _nodeidp; 274 if (get_node_id(inode) == nodeid) 275 return 1; 276 else 277 return 0; 278} 279 --- 7 unchanged lines hidden (view full) --- 287struct inode *fuse_iget(struct super_block *sb, u64 nodeid, 288 int generation, struct fuse_attr *attr, 289 u64 attr_valid, u64 attr_version) 290{ 291 struct inode *inode; 292 struct fuse_inode *fi; 293 struct fuse_conn *fc = get_fuse_conn_super(sb); 294 | 289{ 290 u64 nodeid = *(u64 *) _nodeidp; 291 if (get_node_id(inode) == nodeid) 292 return 1; 293 else 294 return 0; 295} 296 --- 7 unchanged lines hidden (view full) --- 304struct inode *fuse_iget(struct super_block *sb, u64 nodeid, 305 int generation, struct fuse_attr *attr, 306 u64 attr_valid, u64 attr_version) 307{ 308 struct inode *inode; 309 struct fuse_inode *fi; 310 struct fuse_conn *fc = get_fuse_conn_super(sb); 311 |
295 retry: | 312 /* 313 * Auto mount points get their node id from the submount root, which is 314 * not a unique identifier within this filesystem. 315 * 316 * To avoid conflicts, do not place submount points into the inode hash 317 * table. 318 */ 319 if (fc->auto_submounts && (attr->flags & FUSE_ATTR_SUBMOUNT) && 320 S_ISDIR(attr->mode)) { 321 inode = new_inode(sb); 322 if (!inode) 323 return NULL; 324 325 fuse_init_inode(inode, attr); 326 get_fuse_inode(inode)->nodeid = nodeid; 327 inode->i_flags |= S_AUTOMOUNT; 328 goto done; 329 } 330 331retry: |
296 inode = iget5_locked(sb, nodeid, fuse_inode_eq, fuse_inode_set, &nodeid); 297 if (!inode) 298 return NULL; 299 300 if ((inode->i_state & I_NEW)) { 301 inode->i_flags |= S_NOATIME; 302 if (!fc->writeback_cache || !S_ISREG(attr->mode)) 303 inode->i_flags |= S_NOCMTIME; 304 inode->i_generation = generation; 305 fuse_init_inode(inode, attr); 306 unlock_new_inode(inode); 307 } else if ((inode->i_mode ^ attr->mode) & S_IFMT) { 308 /* Inode has changed type, any I/O on the old should fail */ 309 make_bad_inode(inode); 310 iput(inode); 311 goto retry; 312 } | 332 inode = iget5_locked(sb, nodeid, fuse_inode_eq, fuse_inode_set, &nodeid); 333 if (!inode) 334 return NULL; 335 336 if ((inode->i_state & I_NEW)) { 337 inode->i_flags |= S_NOATIME; 338 if (!fc->writeback_cache || !S_ISREG(attr->mode)) 339 inode->i_flags |= S_NOCMTIME; 340 inode->i_generation = generation; 341 fuse_init_inode(inode, attr); 342 unlock_new_inode(inode); 343 } else if ((inode->i_mode ^ attr->mode) & S_IFMT) { 344 /* Inode has changed type, any I/O on the old should fail */ 345 make_bad_inode(inode); 346 iput(inode); 347 goto retry; 348 } |
313 | 349done: |
314 fi = get_fuse_inode(inode); 315 spin_lock(&fi->lock); 316 fi->nlookup++; 317 spin_unlock(&fi->lock); 318 fuse_change_attributes(inode, attr, attr_valid, attr_version); 319 320 return inode; 321} 322 | 350 fi = get_fuse_inode(inode); 351 spin_lock(&fi->lock); 352 fi->nlookup++; 353 spin_unlock(&fi->lock); 354 fuse_change_attributes(inode, attr, attr_valid, attr_version); 355 356 return inode; 357} 358 |
323int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid, | 359struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid, 360 struct fuse_mount **fm) 361{ 362 struct fuse_mount *fm_iter; 363 struct inode *inode; 364 365 WARN_ON(!rwsem_is_locked(&fc->killsb)); 366 list_for_each_entry(fm_iter, &fc->mounts, fc_entry) { 367 if (!fm_iter->sb) 368 continue; 369 370 inode = ilookup5(fm_iter->sb, nodeid, fuse_inode_eq, &nodeid); 371 if (inode) { 372 if (fm) 373 *fm = fm_iter; 374 return inode; 375 } 376 } 377 378 return NULL; 379} 380 381int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid, |
324 loff_t offset, loff_t len) 325{ | 382 loff_t offset, loff_t len) 383{ |
326 struct fuse_conn *fc = get_fuse_conn_super(sb); | |
327 struct fuse_inode *fi; 328 struct inode *inode; 329 pgoff_t pg_start; 330 pgoff_t pg_end; 331 | 384 struct fuse_inode *fi; 385 struct inode *inode; 386 pgoff_t pg_start; 387 pgoff_t pg_end; 388 |
332 inode = ilookup5(sb, nodeid, fuse_inode_eq, &nodeid); | 389 inode = fuse_ilookup(fc, nodeid, NULL); |
333 if (!inode) 334 return -ENOENT; 335 336 fi = get_fuse_inode(inode); 337 spin_lock(&fi->lock); 338 fi->attr_version = atomic64_inc_return(&fc->attr_version); 339 spin_unlock(&fi->lock); 340 --- 33 unchanged lines hidden (view full) --- 374static void fuse_umount_begin(struct super_block *sb) 375{ 376 struct fuse_conn *fc = get_fuse_conn_super(sb); 377 378 if (!fc->no_force_umount) 379 fuse_abort_conn(fc); 380} 381 | 390 if (!inode) 391 return -ENOENT; 392 393 fi = get_fuse_inode(inode); 394 spin_lock(&fi->lock); 395 fi->attr_version = atomic64_inc_return(&fc->attr_version); 396 spin_unlock(&fi->lock); 397 --- 33 unchanged lines hidden (view full) --- 431static void fuse_umount_begin(struct super_block *sb) 432{ 433 struct fuse_conn *fc = get_fuse_conn_super(sb); 434 435 if (!fc->no_force_umount) 436 fuse_abort_conn(fc); 437} 438 |
382static void fuse_send_destroy(struct fuse_conn *fc) | 439static void fuse_send_destroy(struct fuse_mount *fm) |
383{ | 440{ |
384 if (fc->conn_init) { | 441 if (fm->fc->conn_init) { |
385 FUSE_ARGS(args); 386 387 args.opcode = FUSE_DESTROY; 388 args.force = true; 389 args.nocreds = true; | 442 FUSE_ARGS(args); 443 444 args.opcode = FUSE_DESTROY; 445 args.force = true; 446 args.nocreds = true; |
390 fuse_simple_request(fc, &args); | 447 fuse_simple_request(fm, &args); |
391 } 392} 393 394static void fuse_put_super(struct super_block *sb) 395{ | 448 } 449} 450 451static void fuse_put_super(struct super_block *sb) 452{ |
396 struct fuse_conn *fc = get_fuse_conn_super(sb); | 453 struct fuse_mount *fm = get_fuse_mount_super(sb); |
397 | 454 |
398 mutex_lock(&fuse_mutex); 399 list_del(&fc->entry); 400 fuse_ctl_remove_conn(fc); 401 mutex_unlock(&fuse_mutex); 402 403 fuse_conn_put(fc); | 455 fuse_mount_put(fm); |
404} 405 406static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr) 407{ 408 stbuf->f_type = FUSE_SUPER_MAGIC; 409 stbuf->f_bsize = attr->bsize; 410 stbuf->f_frsize = attr->frsize; 411 stbuf->f_blocks = attr->blocks; 412 stbuf->f_bfree = attr->bfree; 413 stbuf->f_bavail = attr->bavail; 414 stbuf->f_files = attr->files; 415 stbuf->f_ffree = attr->ffree; 416 stbuf->f_namelen = attr->namelen; 417 /* fsid is left zero */ 418} 419 420static int fuse_statfs(struct dentry *dentry, struct kstatfs *buf) 421{ 422 struct super_block *sb = dentry->d_sb; | 456} 457 458static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr) 459{ 460 stbuf->f_type = FUSE_SUPER_MAGIC; 461 stbuf->f_bsize = attr->bsize; 462 stbuf->f_frsize = attr->frsize; 463 stbuf->f_blocks = attr->blocks; 464 stbuf->f_bfree = attr->bfree; 465 stbuf->f_bavail = attr->bavail; 466 stbuf->f_files = attr->files; 467 stbuf->f_ffree = attr->ffree; 468 stbuf->f_namelen = attr->namelen; 469 /* fsid is left zero */ 470} 471 472static int fuse_statfs(struct dentry *dentry, struct kstatfs *buf) 473{ 474 struct super_block *sb = dentry->d_sb; |
423 struct fuse_conn *fc = get_fuse_conn_super(sb); | 475 struct fuse_mount *fm = get_fuse_mount_super(sb); |
424 FUSE_ARGS(args); 425 struct fuse_statfs_out outarg; 426 int err; 427 | 476 FUSE_ARGS(args); 477 struct fuse_statfs_out outarg; 478 int err; 479 |
428 if (!fuse_allow_current_process(fc)) { | 480 if (!fuse_allow_current_process(fm->fc)) { |
429 buf->f_type = FUSE_SUPER_MAGIC; 430 return 0; 431 } 432 433 memset(&outarg, 0, sizeof(outarg)); 434 args.in_numargs = 0; 435 args.opcode = FUSE_STATFS; 436 args.nodeid = get_node_id(d_inode(dentry)); 437 args.out_numargs = 1; 438 args.out_args[0].size = sizeof(outarg); 439 args.out_args[0].value = &outarg; | 481 buf->f_type = FUSE_SUPER_MAGIC; 482 return 0; 483 } 484 485 memset(&outarg, 0, sizeof(outarg)); 486 args.in_numargs = 0; 487 args.opcode = FUSE_STATFS; 488 args.nodeid = get_node_id(d_inode(dentry)); 489 args.out_numargs = 1; 490 args.out_args[0].size = sizeof(outarg); 491 args.out_args[0].value = &outarg; |
440 err = fuse_simple_request(fc, &args); | 492 err = fuse_simple_request(fm, &args); |
441 if (!err) 442 convert_fuse_statfs(buf, &outarg.st); 443 return err; 444} 445 446enum { 447 OPT_SOURCE, 448 OPT_SUBTYPE, --- 119 unchanged lines hidden (view full) --- 568 } 569} 570 571static int fuse_show_options(struct seq_file *m, struct dentry *root) 572{ 573 struct super_block *sb = root->d_sb; 574 struct fuse_conn *fc = get_fuse_conn_super(sb); 575 | 493 if (!err) 494 convert_fuse_statfs(buf, &outarg.st); 495 return err; 496} 497 498enum { 499 OPT_SOURCE, 500 OPT_SUBTYPE, --- 119 unchanged lines hidden (view full) --- 620 } 621} 622 623static int fuse_show_options(struct seq_file *m, struct dentry *root) 624{ 625 struct super_block *sb = root->d_sb; 626 struct fuse_conn *fc = get_fuse_conn_super(sb); 627 |
576 if (fc->no_mount_options) 577 return 0; | 628 if (fc->legacy_opts_show) { 629 seq_printf(m, ",user_id=%u", 630 from_kuid_munged(fc->user_ns, fc->user_id)); 631 seq_printf(m, ",group_id=%u", 632 from_kgid_munged(fc->user_ns, fc->group_id)); 633 if (fc->default_permissions) 634 seq_puts(m, ",default_permissions"); 635 if (fc->allow_other) 636 seq_puts(m, ",allow_other"); 637 if (fc->max_read != ~0) 638 seq_printf(m, ",max_read=%u", fc->max_read); 639 if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) 640 seq_printf(m, ",blksize=%lu", sb->s_blocksize); 641 } 642#ifdef CONFIG_FUSE_DAX 643 if (fc->dax) 644 seq_puts(m, ",dax"); 645#endif |
578 | 646 |
579 seq_printf(m, ",user_id=%u", from_kuid_munged(fc->user_ns, fc->user_id)); 580 seq_printf(m, ",group_id=%u", from_kgid_munged(fc->user_ns, fc->group_id)); 581 if (fc->default_permissions) 582 seq_puts(m, ",default_permissions"); 583 if (fc->allow_other) 584 seq_puts(m, ",allow_other"); 585 if (fc->max_read != ~0) 586 seq_printf(m, ",max_read=%u", fc->max_read); 587 if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) 588 seq_printf(m, ",blksize=%lu", sb->s_blocksize); | |
589 return 0; 590} 591 592static void fuse_iqueue_init(struct fuse_iqueue *fiq, 593 const struct fuse_iqueue_ops *ops, 594 void *priv) 595{ 596 memset(fiq, 0, sizeof(struct fuse_iqueue)); --- 13 unchanged lines hidden (view full) --- 610 611 spin_lock_init(&fpq->lock); 612 for (i = 0; i < FUSE_PQ_HASH_SIZE; i++) 613 INIT_LIST_HEAD(&fpq->processing[i]); 614 INIT_LIST_HEAD(&fpq->io); 615 fpq->connected = 1; 616} 617 | 647 return 0; 648} 649 650static void fuse_iqueue_init(struct fuse_iqueue *fiq, 651 const struct fuse_iqueue_ops *ops, 652 void *priv) 653{ 654 memset(fiq, 0, sizeof(struct fuse_iqueue)); --- 13 unchanged lines hidden (view full) --- 668 669 spin_lock_init(&fpq->lock); 670 for (i = 0; i < FUSE_PQ_HASH_SIZE; i++) 671 INIT_LIST_HEAD(&fpq->processing[i]); 672 INIT_LIST_HEAD(&fpq->io); 673 fpq->connected = 1; 674} 675 |
618void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns, | 676void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm, 677 struct user_namespace *user_ns, |
619 const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv) 620{ 621 memset(fc, 0, sizeof(*fc)); 622 spin_lock_init(&fc->lock); 623 spin_lock_init(&fc->bg_lock); 624 init_rwsem(&fc->killsb); 625 refcount_set(&fc->count, 1); 626 atomic_set(&fc->dev_count, 1); --- 10 unchanged lines hidden (view full) --- 637 fc->blocked = 0; 638 fc->initialized = 0; 639 fc->connected = 1; 640 atomic64_set(&fc->attr_version, 1); 641 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); 642 fc->pid_ns = get_pid_ns(task_active_pid_ns(current)); 643 fc->user_ns = get_user_ns(user_ns); 644 fc->max_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; | 678 const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv) 679{ 680 memset(fc, 0, sizeof(*fc)); 681 spin_lock_init(&fc->lock); 682 spin_lock_init(&fc->bg_lock); 683 init_rwsem(&fc->killsb); 684 refcount_set(&fc->count, 1); 685 atomic_set(&fc->dev_count, 1); --- 10 unchanged lines hidden (view full) --- 696 fc->blocked = 0; 697 fc->initialized = 0; 698 fc->connected = 1; 699 atomic64_set(&fc->attr_version, 1); 700 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); 701 fc->pid_ns = get_pid_ns(task_active_pid_ns(current)); 702 fc->user_ns = get_user_ns(user_ns); 703 fc->max_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; |
704 705 INIT_LIST_HEAD(&fc->mounts); 706 list_add(&fm->fc_entry, &fc->mounts); 707 fm->fc = fc; 708 refcount_set(&fm->count, 1); |
|
645} 646EXPORT_SYMBOL_GPL(fuse_conn_init); 647 648void fuse_conn_put(struct fuse_conn *fc) 649{ 650 if (refcount_dec_and_test(&fc->count)) { 651 struct fuse_iqueue *fiq = &fc->iq; 652 | 709} 710EXPORT_SYMBOL_GPL(fuse_conn_init); 711 712void fuse_conn_put(struct fuse_conn *fc) 713{ 714 if (refcount_dec_and_test(&fc->count)) { 715 struct fuse_iqueue *fiq = &fc->iq; 716 |
717 if (IS_ENABLED(CONFIG_FUSE_DAX)) 718 fuse_dax_conn_free(fc); |
|
653 if (fiq->ops->release) 654 fiq->ops->release(fiq); 655 put_pid_ns(fc->pid_ns); 656 put_user_ns(fc->user_ns); 657 fc->release(fc); 658 } 659} 660EXPORT_SYMBOL_GPL(fuse_conn_put); 661 662struct fuse_conn *fuse_conn_get(struct fuse_conn *fc) 663{ 664 refcount_inc(&fc->count); 665 return fc; 666} 667EXPORT_SYMBOL_GPL(fuse_conn_get); 668 | 719 if (fiq->ops->release) 720 fiq->ops->release(fiq); 721 put_pid_ns(fc->pid_ns); 722 put_user_ns(fc->user_ns); 723 fc->release(fc); 724 } 725} 726EXPORT_SYMBOL_GPL(fuse_conn_put); 727 728struct fuse_conn *fuse_conn_get(struct fuse_conn *fc) 729{ 730 refcount_inc(&fc->count); 731 return fc; 732} 733EXPORT_SYMBOL_GPL(fuse_conn_get); 734 |
735void fuse_mount_put(struct fuse_mount *fm) 736{ 737 if (refcount_dec_and_test(&fm->count)) { 738 if (fm->fc) 739 fuse_conn_put(fm->fc); 740 kfree(fm); 741 } 742} 743EXPORT_SYMBOL_GPL(fuse_mount_put); 744 745struct fuse_mount *fuse_mount_get(struct fuse_mount *fm) 746{ 747 refcount_inc(&fm->count); 748 return fm; 749} 750EXPORT_SYMBOL_GPL(fuse_mount_get); 751 |
|
669static struct inode *fuse_get_root_inode(struct super_block *sb, unsigned mode) 670{ 671 struct fuse_attr attr; 672 memset(&attr, 0, sizeof(attr)); 673 674 attr.mode = mode; 675 attr.ino = FUSE_ROOT_ID; 676 attr.nlink = 1; --- 213 unchanged lines hidden (view full) --- 890} 891 892struct fuse_init_args { 893 struct fuse_args args; 894 struct fuse_init_in in; 895 struct fuse_init_out out; 896}; 897 | 752static struct inode *fuse_get_root_inode(struct super_block *sb, unsigned mode) 753{ 754 struct fuse_attr attr; 755 memset(&attr, 0, sizeof(attr)); 756 757 attr.mode = mode; 758 attr.ino = FUSE_ROOT_ID; 759 attr.nlink = 1; --- 213 unchanged lines hidden (view full) --- 973} 974 975struct fuse_init_args { 976 struct fuse_args args; 977 struct fuse_init_in in; 978 struct fuse_init_out out; 979}; 980 |
898static void process_init_reply(struct fuse_conn *fc, struct fuse_args *args, | 981static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, |
899 int error) 900{ | 982 int error) 983{ |
984 struct fuse_conn *fc = fm->fc; |
|
901 struct fuse_init_args *ia = container_of(args, typeof(*ia), args); 902 struct fuse_init_out *arg = &ia->out; | 985 struct fuse_init_args *ia = container_of(args, typeof(*ia), args); 986 struct fuse_init_out *arg = &ia->out; |
987 bool ok = true; |
|
903 904 if (error || arg->major != FUSE_KERNEL_VERSION) | 988 989 if (error || arg->major != FUSE_KERNEL_VERSION) |
905 fc->conn_error = 1; | 990 ok = false; |
906 else { 907 unsigned long ra_pages; 908 909 process_init_limits(fc, arg); 910 911 if (arg->minor >= 6) { 912 ra_pages = arg->max_readahead / PAGE_SIZE; 913 if (arg->flags & FUSE_ASYNC_READ) --- 31 unchanged lines hidden (view full) --- 945 fc->async_dio = 1; 946 if (arg->flags & FUSE_WRITEBACK_CACHE) 947 fc->writeback_cache = 1; 948 if (arg->flags & FUSE_PARALLEL_DIROPS) 949 fc->parallel_dirops = 1; 950 if (arg->flags & FUSE_HANDLE_KILLPRIV) 951 fc->handle_killpriv = 1; 952 if (arg->time_gran && arg->time_gran <= 1000000000) | 991 else { 992 unsigned long ra_pages; 993 994 process_init_limits(fc, arg); 995 996 if (arg->minor >= 6) { 997 ra_pages = arg->max_readahead / PAGE_SIZE; 998 if (arg->flags & FUSE_ASYNC_READ) --- 31 unchanged lines hidden (view full) --- 1030 fc->async_dio = 1; 1031 if (arg->flags & FUSE_WRITEBACK_CACHE) 1032 fc->writeback_cache = 1; 1033 if (arg->flags & FUSE_PARALLEL_DIROPS) 1034 fc->parallel_dirops = 1; 1035 if (arg->flags & FUSE_HANDLE_KILLPRIV) 1036 fc->handle_killpriv = 1; 1037 if (arg->time_gran && arg->time_gran <= 1000000000) |
953 fc->sb->s_time_gran = arg->time_gran; | 1038 fm->sb->s_time_gran = arg->time_gran; |
954 if ((arg->flags & FUSE_POSIX_ACL)) { 955 fc->default_permissions = 1; 956 fc->posix_acl = 1; | 1039 if ((arg->flags & FUSE_POSIX_ACL)) { 1040 fc->default_permissions = 1; 1041 fc->posix_acl = 1; |
957 fc->sb->s_xattr = fuse_acl_xattr_handlers; | 1042 fm->sb->s_xattr = fuse_acl_xattr_handlers; |
958 } 959 if (arg->flags & FUSE_CACHE_SYMLINKS) 960 fc->cache_symlinks = 1; 961 if (arg->flags & FUSE_ABORT_ERROR) 962 fc->abort_err = 1; 963 if (arg->flags & FUSE_MAX_PAGES) { 964 fc->max_pages = 965 min_t(unsigned int, FUSE_MAX_MAX_PAGES, 966 max_t(unsigned int, arg->max_pages, 1)); 967 } | 1043 } 1044 if (arg->flags & FUSE_CACHE_SYMLINKS) 1045 fc->cache_symlinks = 1; 1046 if (arg->flags & FUSE_ABORT_ERROR) 1047 fc->abort_err = 1; 1048 if (arg->flags & FUSE_MAX_PAGES) { 1049 fc->max_pages = 1050 min_t(unsigned int, FUSE_MAX_MAX_PAGES, 1051 max_t(unsigned int, arg->max_pages, 1)); 1052 } |
1053 if (IS_ENABLED(CONFIG_FUSE_DAX) && 1054 arg->flags & FUSE_MAP_ALIGNMENT && 1055 !fuse_dax_check_alignment(fc, arg->map_alignment)) { 1056 ok = false; 1057 } |
|
968 } else { 969 ra_pages = fc->max_read / PAGE_SIZE; 970 fc->no_lock = 1; 971 fc->no_flock = 1; 972 } 973 | 1058 } else { 1059 ra_pages = fc->max_read / PAGE_SIZE; 1060 fc->no_lock = 1; 1061 fc->no_flock = 1; 1062 } 1063 |
974 fc->sb->s_bdi->ra_pages = 975 min(fc->sb->s_bdi->ra_pages, ra_pages); | 1064 fm->sb->s_bdi->ra_pages = 1065 min(fm->sb->s_bdi->ra_pages, ra_pages); |
976 fc->minor = arg->minor; 977 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 978 fc->max_write = max_t(unsigned, 4096, fc->max_write); 979 fc->conn_init = 1; 980 } 981 kfree(ia); 982 | 1066 fc->minor = arg->minor; 1067 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 1068 fc->max_write = max_t(unsigned, 4096, fc->max_write); 1069 fc->conn_init = 1; 1070 } 1071 kfree(ia); 1072 |
1073 if (!ok) { 1074 fc->conn_init = 0; 1075 fc->conn_error = 1; 1076 } 1077 |
|
983 fuse_set_initialized(fc); 984 wake_up_all(&fc->blocked_waitq); 985} 986 | 1078 fuse_set_initialized(fc); 1079 wake_up_all(&fc->blocked_waitq); 1080} 1081 |
987void fuse_send_init(struct fuse_conn *fc) | 1082void fuse_send_init(struct fuse_mount *fm) |
988{ 989 struct fuse_init_args *ia; 990 991 ia = kzalloc(sizeof(*ia), GFP_KERNEL | __GFP_NOFAIL); 992 993 ia->in.major = FUSE_KERNEL_VERSION; 994 ia->in.minor = FUSE_KERNEL_MINOR_VERSION; | 1083{ 1084 struct fuse_init_args *ia; 1085 1086 ia = kzalloc(sizeof(*ia), GFP_KERNEL | __GFP_NOFAIL); 1087 1088 ia->in.major = FUSE_KERNEL_VERSION; 1089 ia->in.minor = FUSE_KERNEL_MINOR_VERSION; |
995 ia->in.max_readahead = fc->sb->s_bdi->ra_pages * PAGE_SIZE; | 1090 ia->in.max_readahead = fm->sb->s_bdi->ra_pages * PAGE_SIZE; |
996 ia->in.flags |= 997 FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | 998 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK | 999 FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | 1000 FUSE_FLOCK_LOCKS | FUSE_HAS_IOCTL_DIR | FUSE_AUTO_INVAL_DATA | 1001 FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO | 1002 FUSE_WRITEBACK_CACHE | FUSE_NO_OPEN_SUPPORT | 1003 FUSE_PARALLEL_DIROPS | FUSE_HANDLE_KILLPRIV | FUSE_POSIX_ACL | 1004 FUSE_ABORT_ERROR | FUSE_MAX_PAGES | FUSE_CACHE_SYMLINKS | 1005 FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA; | 1091 ia->in.flags |= 1092 FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC | 1093 FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK | 1094 FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | 1095 FUSE_FLOCK_LOCKS | FUSE_HAS_IOCTL_DIR | FUSE_AUTO_INVAL_DATA | 1096 FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO | 1097 FUSE_WRITEBACK_CACHE | FUSE_NO_OPEN_SUPPORT | 1098 FUSE_PARALLEL_DIROPS | FUSE_HANDLE_KILLPRIV | FUSE_POSIX_ACL | 1099 FUSE_ABORT_ERROR | FUSE_MAX_PAGES | FUSE_CACHE_SYMLINKS | 1100 FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA; |
1101#ifdef CONFIG_FUSE_DAX 1102 if (fm->fc->dax) 1103 ia->in.flags |= FUSE_MAP_ALIGNMENT; 1104#endif 1105 if (fm->fc->auto_submounts) 1106 ia->in.flags |= FUSE_SUBMOUNTS; 1107 |
|
1006 ia->args.opcode = FUSE_INIT; 1007 ia->args.in_numargs = 1; 1008 ia->args.in_args[0].size = sizeof(ia->in); 1009 ia->args.in_args[0].value = &ia->in; 1010 ia->args.out_numargs = 1; 1011 /* Variable length argument used for backward compatibility 1012 with interface version < 7.5. Rest of init_out is zeroed 1013 by do_get_request(), so a short reply is not a problem */ 1014 ia->args.out_argvar = true; 1015 ia->args.out_args[0].size = sizeof(ia->out); 1016 ia->args.out_args[0].value = &ia->out; 1017 ia->args.force = true; 1018 ia->args.nocreds = true; 1019 ia->args.end = process_init_reply; 1020 | 1108 ia->args.opcode = FUSE_INIT; 1109 ia->args.in_numargs = 1; 1110 ia->args.in_args[0].size = sizeof(ia->in); 1111 ia->args.in_args[0].value = &ia->in; 1112 ia->args.out_numargs = 1; 1113 /* Variable length argument used for backward compatibility 1114 with interface version < 7.5. Rest of init_out is zeroed 1115 by do_get_request(), so a short reply is not a problem */ 1116 ia->args.out_argvar = true; 1117 ia->args.out_args[0].size = sizeof(ia->out); 1118 ia->args.out_args[0].value = &ia->out; 1119 ia->args.force = true; 1120 ia->args.nocreds = true; 1121 ia->args.end = process_init_reply; 1122 |
1021 if (fuse_simple_background(fc, &ia->args, GFP_KERNEL) != 0) 1022 process_init_reply(fc, &ia->args, -ENOTCONN); | 1123 if (fuse_simple_background(fm, &ia->args, GFP_KERNEL) != 0) 1124 process_init_reply(fm, &ia->args, -ENOTCONN); |
1023} 1024EXPORT_SYMBOL_GPL(fuse_send_init); 1025 1026void fuse_free_conn(struct fuse_conn *fc) 1027{ 1028 WARN_ON(!list_empty(&fc->devices)); 1029 kfree_rcu(fc, rcu); 1030} --- 94 unchanged lines hidden (view full) --- 1125 1126 fuse_conn_put(fc); 1127 } 1128 kfree(fud->pq.processing); 1129 kfree(fud); 1130} 1131EXPORT_SYMBOL_GPL(fuse_dev_free); 1132 | 1125} 1126EXPORT_SYMBOL_GPL(fuse_send_init); 1127 1128void fuse_free_conn(struct fuse_conn *fc) 1129{ 1130 WARN_ON(!list_empty(&fc->devices)); 1131 kfree_rcu(fc, rcu); 1132} --- 94 unchanged lines hidden (view full) --- 1227 1228 fuse_conn_put(fc); 1229 } 1230 kfree(fud->pq.processing); 1231 kfree(fud); 1232} 1233EXPORT_SYMBOL_GPL(fuse_dev_free); 1234 |
1235static void fuse_fill_attr_from_inode(struct fuse_attr *attr, 1236 const struct fuse_inode *fi) 1237{ 1238 *attr = (struct fuse_attr){ 1239 .ino = fi->inode.i_ino, 1240 .size = fi->inode.i_size, 1241 .blocks = fi->inode.i_blocks, 1242 .atime = fi->inode.i_atime.tv_sec, 1243 .mtime = fi->inode.i_mtime.tv_sec, 1244 .ctime = fi->inode.i_ctime.tv_sec, 1245 .atimensec = fi->inode.i_atime.tv_nsec, 1246 .mtimensec = fi->inode.i_mtime.tv_nsec, 1247 .ctimensec = fi->inode.i_ctime.tv_nsec, 1248 .mode = fi->inode.i_mode, 1249 .nlink = fi->inode.i_nlink, 1250 .uid = fi->inode.i_uid.val, 1251 .gid = fi->inode.i_gid.val, 1252 .rdev = fi->inode.i_rdev, 1253 .blksize = 1u << fi->inode.i_blkbits, 1254 }; 1255} 1256 1257static void fuse_sb_defaults(struct super_block *sb) 1258{ 1259 sb->s_magic = FUSE_SUPER_MAGIC; 1260 sb->s_op = &fuse_super_operations; 1261 sb->s_xattr = fuse_xattr_handlers; 1262 sb->s_maxbytes = MAX_LFS_FILESIZE; 1263 sb->s_time_gran = 1; 1264 sb->s_export_op = &fuse_export_operations; 1265 sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE; 1266 if (sb->s_user_ns != &init_user_ns) 1267 sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER; 1268 sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION); 1269 1270 /* 1271 * If we are not in the initial user namespace posix 1272 * acls must be translated. 1273 */ 1274 if (sb->s_user_ns != &init_user_ns) 1275 sb->s_xattr = fuse_no_acl_xattr_handlers; 1276} 1277 1278int fuse_fill_super_submount(struct super_block *sb, 1279 struct fuse_inode *parent_fi) 1280{ 1281 struct fuse_mount *fm = get_fuse_mount_super(sb); 1282 struct super_block *parent_sb = parent_fi->inode.i_sb; 1283 struct fuse_attr root_attr; 1284 struct inode *root; 1285 1286 fuse_sb_defaults(sb); 1287 fm->sb = sb; 1288 1289 WARN_ON(sb->s_bdi != &noop_backing_dev_info); 1290 sb->s_bdi = bdi_get(parent_sb->s_bdi); 1291 1292 sb->s_xattr = parent_sb->s_xattr; 1293 sb->s_time_gran = parent_sb->s_time_gran; 1294 sb->s_blocksize = parent_sb->s_blocksize; 1295 sb->s_blocksize_bits = parent_sb->s_blocksize_bits; 1296 sb->s_subtype = kstrdup(parent_sb->s_subtype, GFP_KERNEL); 1297 if (parent_sb->s_subtype && !sb->s_subtype) 1298 return -ENOMEM; 1299 1300 fuse_fill_attr_from_inode(&root_attr, parent_fi); 1301 root = fuse_iget(sb, parent_fi->nodeid, 0, &root_attr, 0, 0); 1302 /* 1303 * This inode is just a duplicate, so it is not looked up and 1304 * its nlookup should not be incremented. fuse_iget() does 1305 * that, though, so undo it here. 1306 */ 1307 get_fuse_inode(root)->nlookup--; 1308 sb->s_d_op = &fuse_dentry_operations; 1309 sb->s_root = d_make_root(root); 1310 if (!sb->s_root) 1311 return -ENOMEM; 1312 1313 return 0; 1314} 1315 |
|
1133int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx) 1134{ 1135 struct fuse_dev *fud = NULL; | 1316int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx) 1317{ 1318 struct fuse_dev *fud = NULL; |
1136 struct fuse_conn *fc = get_fuse_conn_super(sb); | 1319 struct fuse_mount *fm = get_fuse_mount_super(sb); 1320 struct fuse_conn *fc = fm->fc; |
1137 struct inode *root; 1138 struct dentry *root_dentry; 1139 int err; 1140 1141 err = -EINVAL; 1142 if (sb->s_flags & SB_MANDLOCK) 1143 goto err; 1144 | 1321 struct inode *root; 1322 struct dentry *root_dentry; 1323 int err; 1324 1325 err = -EINVAL; 1326 if (sb->s_flags & SB_MANDLOCK) 1327 goto err; 1328 |
1145 sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION); | 1329 fuse_sb_defaults(sb); |
1146 1147 if (ctx->is_bdev) { 1148#ifdef CONFIG_BLOCK 1149 err = -EINVAL; 1150 if (!sb_set_blocksize(sb, ctx->blksize)) 1151 goto err; 1152#endif 1153 } else { 1154 sb->s_blocksize = PAGE_SIZE; 1155 sb->s_blocksize_bits = PAGE_SHIFT; 1156 } 1157 1158 sb->s_subtype = ctx->subtype; 1159 ctx->subtype = NULL; | 1330 1331 if (ctx->is_bdev) { 1332#ifdef CONFIG_BLOCK 1333 err = -EINVAL; 1334 if (!sb_set_blocksize(sb, ctx->blksize)) 1335 goto err; 1336#endif 1337 } else { 1338 sb->s_blocksize = PAGE_SIZE; 1339 sb->s_blocksize_bits = PAGE_SHIFT; 1340 } 1341 1342 sb->s_subtype = ctx->subtype; 1343 ctx->subtype = NULL; |
1160 sb->s_magic = FUSE_SUPER_MAGIC; 1161 sb->s_op = &fuse_super_operations; 1162 sb->s_xattr = fuse_xattr_handlers; 1163 sb->s_maxbytes = MAX_LFS_FILESIZE; 1164 sb->s_time_gran = 1; 1165 sb->s_export_op = &fuse_export_operations; 1166 sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE; 1167 if (sb->s_user_ns != &init_user_ns) 1168 sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER; | 1344 if (IS_ENABLED(CONFIG_FUSE_DAX)) { 1345 err = fuse_dax_conn_alloc(fc, ctx->dax_dev); 1346 if (err) 1347 goto err; 1348 } |
1169 | 1349 |
1170 /* 1171 * If we are not in the initial user namespace posix 1172 * acls must be translated. 1173 */ 1174 if (sb->s_user_ns != &init_user_ns) 1175 sb->s_xattr = fuse_no_acl_xattr_handlers; 1176 | |
1177 if (ctx->fudptr) { 1178 err = -ENOMEM; 1179 fud = fuse_dev_alloc_install(fc); 1180 if (!fud) | 1350 if (ctx->fudptr) { 1351 err = -ENOMEM; 1352 fud = fuse_dev_alloc_install(fc); 1353 if (!fud) |
1181 goto err; | 1354 goto err_free_dax; |
1182 } 1183 1184 fc->dev = sb->s_dev; | 1355 } 1356 1357 fc->dev = sb->s_dev; |
1185 fc->sb = sb; | 1358 fm->sb = sb; |
1186 err = fuse_bdi_init(fc, sb); 1187 if (err) 1188 goto err_dev_free; 1189 1190 /* Handle umasking inside the fuse code */ 1191 if (sb->s_flags & SB_POSIXACL) 1192 fc->dont_mask = 1; 1193 sb->s_flags |= SB_POSIXACL; 1194 1195 fc->default_permissions = ctx->default_permissions; 1196 fc->allow_other = ctx->allow_other; 1197 fc->user_id = ctx->user_id; 1198 fc->group_id = ctx->group_id; | 1359 err = fuse_bdi_init(fc, sb); 1360 if (err) 1361 goto err_dev_free; 1362 1363 /* Handle umasking inside the fuse code */ 1364 if (sb->s_flags & SB_POSIXACL) 1365 fc->dont_mask = 1; 1366 sb->s_flags |= SB_POSIXACL; 1367 1368 fc->default_permissions = ctx->default_permissions; 1369 fc->allow_other = ctx->allow_other; 1370 fc->user_id = ctx->user_id; 1371 fc->group_id = ctx->group_id; |
1199 fc->max_read = max_t(unsigned, 4096, ctx->max_read); | 1372 fc->legacy_opts_show = ctx->legacy_opts_show; 1373 fc->max_read = max_t(unsigned int, 4096, ctx->max_read); |
1200 fc->destroy = ctx->destroy; 1201 fc->no_control = ctx->no_control; 1202 fc->no_force_umount = ctx->no_force_umount; | 1374 fc->destroy = ctx->destroy; 1375 fc->no_control = ctx->no_control; 1376 fc->no_force_umount = ctx->no_force_umount; |
1203 fc->no_mount_options = ctx->no_mount_options; | |
1204 1205 err = -ENOMEM; 1206 root = fuse_get_root_inode(sb, ctx->rootmode); 1207 sb->s_d_op = &fuse_root_dentry_operations; 1208 root_dentry = d_make_root(root); 1209 if (!root_dentry) 1210 goto err_dev_free; 1211 /* Root dentry doesn't have .d_revalidate */ --- 16 unchanged lines hidden (view full) --- 1228 return 0; 1229 1230 err_unlock: 1231 mutex_unlock(&fuse_mutex); 1232 dput(root_dentry); 1233 err_dev_free: 1234 if (fud) 1235 fuse_dev_free(fud); | 1377 1378 err = -ENOMEM; 1379 root = fuse_get_root_inode(sb, ctx->rootmode); 1380 sb->s_d_op = &fuse_root_dentry_operations; 1381 root_dentry = d_make_root(root); 1382 if (!root_dentry) 1383 goto err_dev_free; 1384 /* Root dentry doesn't have .d_revalidate */ --- 16 unchanged lines hidden (view full) --- 1401 return 0; 1402 1403 err_unlock: 1404 mutex_unlock(&fuse_mutex); 1405 dput(root_dentry); 1406 err_dev_free: 1407 if (fud) 1408 fuse_dev_free(fud); |
1409 err_free_dax: 1410 if (IS_ENABLED(CONFIG_FUSE_DAX)) 1411 fuse_dax_conn_free(fc); |
|
1236 err: 1237 return err; 1238} 1239EXPORT_SYMBOL_GPL(fuse_fill_super_common); 1240 1241static int fuse_fill_super(struct super_block *sb, struct fs_context *fsc) 1242{ 1243 struct fuse_fs_context *ctx = fsc->fs_private; 1244 struct file *file; 1245 int err; 1246 struct fuse_conn *fc; | 1412 err: 1413 return err; 1414} 1415EXPORT_SYMBOL_GPL(fuse_fill_super_common); 1416 1417static int fuse_fill_super(struct super_block *sb, struct fs_context *fsc) 1418{ 1419 struct fuse_fs_context *ctx = fsc->fs_private; 1420 struct file *file; 1421 int err; 1422 struct fuse_conn *fc; |
1423 struct fuse_mount *fm; |
|
1247 1248 err = -EINVAL; 1249 file = fget(ctx->fd); 1250 if (!file) 1251 goto err; 1252 1253 /* 1254 * Require mount to happen from the same user namespace which --- 4 unchanged lines hidden (view full) --- 1259 goto err_fput; 1260 ctx->fudptr = &file->private_data; 1261 1262 fc = kmalloc(sizeof(*fc), GFP_KERNEL); 1263 err = -ENOMEM; 1264 if (!fc) 1265 goto err_fput; 1266 | 1424 1425 err = -EINVAL; 1426 file = fget(ctx->fd); 1427 if (!file) 1428 goto err; 1429 1430 /* 1431 * Require mount to happen from the same user namespace which --- 4 unchanged lines hidden (view full) --- 1436 goto err_fput; 1437 ctx->fudptr = &file->private_data; 1438 1439 fc = kmalloc(sizeof(*fc), GFP_KERNEL); 1440 err = -ENOMEM; 1441 if (!fc) 1442 goto err_fput; 1443 |
1267 fuse_conn_init(fc, sb->s_user_ns, &fuse_dev_fiq_ops, NULL); | 1444 fm = kzalloc(sizeof(*fm), GFP_KERNEL); 1445 if (!fm) { 1446 kfree(fc); 1447 goto err_fput; 1448 } 1449 1450 fuse_conn_init(fc, fm, sb->s_user_ns, &fuse_dev_fiq_ops, NULL); |
1268 fc->release = fuse_free_conn; | 1451 fc->release = fuse_free_conn; |
1269 sb->s_fs_info = fc; | |
1270 | 1452 |
1453 sb->s_fs_info = fm; 1454 |
|
1271 err = fuse_fill_super_common(sb, ctx); 1272 if (err) 1273 goto err_put_conn; 1274 /* 1275 * atomic_dec_and_test() in fput() provides the necessary 1276 * memory barrier for file->private_data to be visible on all 1277 * CPUs after this 1278 */ 1279 fput(file); | 1455 err = fuse_fill_super_common(sb, ctx); 1456 if (err) 1457 goto err_put_conn; 1458 /* 1459 * atomic_dec_and_test() in fput() provides the necessary 1460 * memory barrier for file->private_data to be visible on all 1461 * CPUs after this 1462 */ 1463 fput(file); |
1280 fuse_send_init(get_fuse_conn_super(sb)); | 1464 fuse_send_init(get_fuse_mount_super(sb)); |
1281 return 0; 1282 1283 err_put_conn: | 1465 return 0; 1466 1467 err_put_conn: |
1284 fuse_conn_put(fc); | 1468 fuse_mount_put(fm); |
1285 sb->s_fs_info = NULL; 1286 err_fput: 1287 fput(file); 1288 err: 1289 return err; 1290} 1291 1292static int fuse_get_tree(struct fs_context *fc) --- 27 unchanged lines hidden (view full) --- 1320 struct fuse_fs_context *ctx; 1321 1322 ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL); 1323 if (!ctx) 1324 return -ENOMEM; 1325 1326 ctx->max_read = ~0; 1327 ctx->blksize = FUSE_DEFAULT_BLKSIZE; | 1469 sb->s_fs_info = NULL; 1470 err_fput: 1471 fput(file); 1472 err: 1473 return err; 1474} 1475 1476static int fuse_get_tree(struct fs_context *fc) --- 27 unchanged lines hidden (view full) --- 1504 struct fuse_fs_context *ctx; 1505 1506 ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL); 1507 if (!ctx) 1508 return -ENOMEM; 1509 1510 ctx->max_read = ~0; 1511 ctx->blksize = FUSE_DEFAULT_BLKSIZE; |
1512 ctx->legacy_opts_show = true; |
|
1328 1329#ifdef CONFIG_BLOCK 1330 if (fc->fs_type == &fuseblk_fs_type) { 1331 ctx->is_bdev = true; 1332 ctx->destroy = true; 1333 } 1334#endif 1335 1336 fc->fs_private = ctx; 1337 fc->ops = &fuse_context_ops; 1338 return 0; 1339} 1340 | 1513 1514#ifdef CONFIG_BLOCK 1515 if (fc->fs_type == &fuseblk_fs_type) { 1516 ctx->is_bdev = true; 1517 ctx->destroy = true; 1518 } 1519#endif 1520 1521 fc->fs_private = ctx; 1522 fc->ops = &fuse_context_ops; 1523 return 0; 1524} 1525 |
1341static void fuse_sb_destroy(struct super_block *sb) | 1526bool fuse_mount_remove(struct fuse_mount *fm) |
1342{ | 1527{ |
1343 struct fuse_conn *fc = get_fuse_conn_super(sb); | 1528 struct fuse_conn *fc = fm->fc; 1529 bool last = false; |
1344 | 1530 |
1345 if (fc) { 1346 if (fc->destroy) 1347 fuse_send_destroy(fc); | 1531 down_write(&fc->killsb); 1532 list_del_init(&fm->fc_entry); 1533 if (list_empty(&fc->mounts)) 1534 last = true; 1535 up_write(&fc->killsb); |
1348 | 1536 |
1349 fuse_abort_conn(fc); 1350 fuse_wait_aborted(fc); | 1537 return last; 1538} 1539EXPORT_SYMBOL_GPL(fuse_mount_remove); |
1351 | 1540 |
1352 down_write(&fc->killsb); 1353 fc->sb = NULL; 1354 up_write(&fc->killsb); | 1541void fuse_conn_destroy(struct fuse_mount *fm) 1542{ 1543 struct fuse_conn *fc = fm->fc; 1544 1545 if (fc->destroy) 1546 fuse_send_destroy(fm); 1547 1548 fuse_abort_conn(fc); 1549 fuse_wait_aborted(fc); 1550 1551 if (!list_empty(&fc->entry)) { 1552 mutex_lock(&fuse_mutex); 1553 list_del(&fc->entry); 1554 fuse_ctl_remove_conn(fc); 1555 mutex_unlock(&fuse_mutex); |
1355 } 1356} | 1556 } 1557} |
1558EXPORT_SYMBOL_GPL(fuse_conn_destroy); |
|
1357 | 1559 |
1358void fuse_kill_sb_anon(struct super_block *sb) | 1560static void fuse_kill_sb_anon(struct super_block *sb) |
1359{ | 1561{ |
1360 fuse_sb_destroy(sb); | 1562 struct fuse_mount *fm = get_fuse_mount_super(sb); 1563 bool last; 1564 1565 if (fm) { 1566 last = fuse_mount_remove(fm); 1567 if (last) 1568 fuse_conn_destroy(fm); 1569 } |
1361 kill_anon_super(sb); 1362} | 1570 kill_anon_super(sb); 1571} |
1363EXPORT_SYMBOL_GPL(fuse_kill_sb_anon); | |
1364 1365static struct file_system_type fuse_fs_type = { 1366 .owner = THIS_MODULE, 1367 .name = "fuse", 1368 .fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT, 1369 .init_fs_context = fuse_init_fs_context, 1370 .parameters = fuse_fs_parameters, 1371 .kill_sb = fuse_kill_sb_anon, 1372}; 1373MODULE_ALIAS_FS("fuse"); 1374 1375#ifdef CONFIG_BLOCK 1376static void fuse_kill_sb_blk(struct super_block *sb) 1377{ | 1572 1573static struct file_system_type fuse_fs_type = { 1574 .owner = THIS_MODULE, 1575 .name = "fuse", 1576 .fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT, 1577 .init_fs_context = fuse_init_fs_context, 1578 .parameters = fuse_fs_parameters, 1579 .kill_sb = fuse_kill_sb_anon, 1580}; 1581MODULE_ALIAS_FS("fuse"); 1582 1583#ifdef CONFIG_BLOCK 1584static void fuse_kill_sb_blk(struct super_block *sb) 1585{ |
1378 fuse_sb_destroy(sb); | 1586 struct fuse_mount *fm = get_fuse_mount_super(sb); 1587 bool last; 1588 1589 if (fm) { 1590 last = fuse_mount_remove(fm); 1591 if (last) 1592 fuse_conn_destroy(fm); 1593 } |
1379 kill_block_super(sb); 1380} 1381 1382static struct file_system_type fuseblk_fs_type = { 1383 .owner = THIS_MODULE, 1384 .name = "fuseblk", 1385 .init_fs_context = fuse_init_fs_context, 1386 .parameters = fuse_fs_parameters, --- 156 unchanged lines hidden --- | 1594 kill_block_super(sb); 1595} 1596 1597static struct file_system_type fuseblk_fs_type = { 1598 .owner = THIS_MODULE, 1599 .name = "fuseblk", 1600 .init_fs_context = fuse_init_fs_context, 1601 .parameters = fuse_fs_parameters, --- 156 unchanged lines hidden --- |