Lines Matching +full:fiq +full:- +full:based
3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
79 fi->i_time = 0; in fuse_alloc_inode()
80 fi->inval_mask = 0; in fuse_alloc_inode()
81 fi->nodeid = 0; in fuse_alloc_inode()
82 fi->nlookup = 0; in fuse_alloc_inode()
83 fi->attr_version = 0; in fuse_alloc_inode()
84 fi->orig_ino = 0; in fuse_alloc_inode()
85 fi->state = 0; in fuse_alloc_inode()
86 mutex_init(&fi->mutex); in fuse_alloc_inode()
87 spin_lock_init(&fi->lock); in fuse_alloc_inode()
88 fi->forget = fuse_alloc_forget(); in fuse_alloc_inode()
89 if (!fi->forget) in fuse_alloc_inode()
95 return &fi->inode; in fuse_alloc_inode()
98 kfree(fi->forget); in fuse_alloc_inode()
108 mutex_destroy(&fi->mutex); in fuse_free_inode()
109 kfree(fi->forget); in fuse_free_inode()
111 kfree(fi->dax); in fuse_free_inode()
121 WARN_ON(inode->i_state & I_DIRTY_INODE); in fuse_evict_inode()
123 truncate_inode_pages_final(&inode->i_data); in fuse_evict_inode()
125 if (inode->i_sb->s_flags & SB_ACTIVE) { in fuse_evict_inode()
130 if (fi->nlookup) { in fuse_evict_inode()
131 fuse_queue_forget(fc, fi->forget, fi->nodeid, in fuse_evict_inode()
132 fi->nlookup); in fuse_evict_inode()
133 fi->forget = NULL; in fuse_evict_inode()
136 if (S_ISREG(inode->i_mode) && !fuse_is_bad(inode)) { in fuse_evict_inode()
137 WARN_ON(!list_empty(&fi->write_files)); in fuse_evict_inode()
138 WARN_ON(!list_empty(&fi->queued_writes)); in fuse_evict_inode()
144 struct super_block *sb = fsc->root->d_sb; in fuse_reconfigure()
147 if (fsc->sb_flags & SB_MANDLOCK) in fuse_reconfigure()
148 return -EINVAL; in fuse_reconfigure()
154 * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down
161 ino ^= ino64 >> (sizeof(u64) - sizeof(ino_t)) * 8; in fuse_squash_ino()
171 lockdep_assert_held(&fi->lock); in fuse_change_attributes_common()
173 fi->attr_version = atomic64_inc_return(&fc->attr_version); in fuse_change_attributes_common()
174 fi->i_time = attr_valid; in fuse_change_attributes_common()
175 WRITE_ONCE(fi->inval_mask, 0); in fuse_change_attributes_common()
177 inode->i_ino = fuse_squash_ino(attr->ino); in fuse_change_attributes_common()
178 inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777); in fuse_change_attributes_common()
179 set_nlink(inode, attr->nlink); in fuse_change_attributes_common()
180 inode->i_uid = make_kuid(fc->user_ns, attr->uid); in fuse_change_attributes_common()
181 inode->i_gid = make_kgid(fc->user_ns, attr->gid); in fuse_change_attributes_common()
182 inode->i_blocks = attr->blocks; in fuse_change_attributes_common()
185 attr->atimensec = min_t(u32, attr->atimensec, NSEC_PER_SEC - 1); in fuse_change_attributes_common()
186 attr->mtimensec = min_t(u32, attr->mtimensec, NSEC_PER_SEC - 1); in fuse_change_attributes_common()
187 attr->ctimensec = min_t(u32, attr->ctimensec, NSEC_PER_SEC - 1); in fuse_change_attributes_common()
189 inode->i_atime.tv_sec = attr->atime; in fuse_change_attributes_common()
190 inode->i_atime.tv_nsec = attr->atimensec; in fuse_change_attributes_common()
193 inode->i_mtime.tv_sec = attr->mtime; in fuse_change_attributes_common()
194 inode->i_mtime.tv_nsec = attr->mtimensec; in fuse_change_attributes_common()
197 inode->i_ctime.tv_sec = attr->ctime; in fuse_change_attributes_common()
198 inode->i_ctime.tv_nsec = attr->ctimensec; in fuse_change_attributes_common()
201 if (attr->blksize != 0) in fuse_change_attributes_common()
202 inode->i_blkbits = ilog2(attr->blksize); in fuse_change_attributes_common()
204 inode->i_blkbits = inode->i_sb->s_blocksize_bits; in fuse_change_attributes_common()
211 fi->orig_i_mode = inode->i_mode; in fuse_change_attributes_common()
212 if (!fc->default_permissions) in fuse_change_attributes_common()
213 inode->i_mode &= ~S_ISVTX; in fuse_change_attributes_common()
215 fi->orig_ino = attr->ino; in fuse_change_attributes_common()
225 inode->i_flags &= ~S_NOSEC; in fuse_change_attributes_common()
232 if (!fc->writeback_cache || !S_ISREG(inode->i_mode)) in fuse_get_cache_mask()
247 spin_lock(&fi->lock); in fuse_change_attributes()
255 attr->size = i_size_read(inode); in fuse_change_attributes()
258 attr->mtime = inode->i_mtime.tv_sec; in fuse_change_attributes()
259 attr->mtimensec = inode->i_mtime.tv_nsec; in fuse_change_attributes()
262 attr->ctime = inode->i_ctime.tv_sec; in fuse_change_attributes()
263 attr->ctimensec = inode->i_ctime.tv_nsec; in fuse_change_attributes()
266 if ((attr_version != 0 && fi->attr_version > attr_version) || in fuse_change_attributes()
267 test_bit(FUSE_I_SIZE_UNSTABLE, &fi->state)) { in fuse_change_attributes()
268 spin_unlock(&fi->lock); in fuse_change_attributes()
272 old_mtime = inode->i_mtime; in fuse_change_attributes()
275 oldsize = inode->i_size; in fuse_change_attributes()
279 * attr->size coming from server can be stale. We cannot trust it. in fuse_change_attributes()
282 i_size_write(inode, attr->size); in fuse_change_attributes()
283 spin_unlock(&fi->lock); in fuse_change_attributes()
285 if (!cache_mask && S_ISREG(inode->i_mode)) { in fuse_change_attributes()
288 if (oldsize != attr->size) { in fuse_change_attributes()
289 truncate_pagecache(inode, attr->size); in fuse_change_attributes()
290 if (!fc->explicit_inval_data) in fuse_change_attributes()
292 } else if (fc->auto_inval_data) { in fuse_change_attributes()
294 .tv_sec = attr->mtime, in fuse_change_attributes()
295 .tv_nsec = attr->mtimensec, in fuse_change_attributes()
307 invalidate_inode_pages2(inode->i_mapping); in fuse_change_attributes()
311 fuse_dax_dontcache(inode, attr->flags); in fuse_change_attributes()
316 inode->i_mode = attr->mode & S_IFMT; in fuse_init_inode()
317 inode->i_size = attr->size; in fuse_init_inode()
318 inode->i_mtime.tv_sec = attr->mtime; in fuse_init_inode()
319 inode->i_mtime.tv_nsec = attr->mtimensec; in fuse_init_inode()
320 inode->i_ctime.tv_sec = attr->ctime; in fuse_init_inode()
321 inode->i_ctime.tv_nsec = attr->ctimensec; in fuse_init_inode()
322 if (S_ISREG(inode->i_mode)) { in fuse_init_inode()
324 fuse_init_file_inode(inode, attr->flags); in fuse_init_inode()
325 } else if (S_ISDIR(inode->i_mode)) in fuse_init_inode()
327 else if (S_ISLNK(inode->i_mode)) in fuse_init_inode()
329 else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || in fuse_init_inode()
330 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { in fuse_init_inode()
332 init_special_inode(inode, inode->i_mode, in fuse_init_inode()
333 new_decode_dev(attr->rdev)); in fuse_init_inode()
350 get_fuse_inode(inode)->nodeid = nodeid; in fuse_inode_set()
369 if (fc->auto_submounts && (attr->flags & FUSE_ATTR_SUBMOUNT) && in fuse_iget()
370 S_ISDIR(attr->mode)) { in fuse_iget()
376 get_fuse_inode(inode)->nodeid = nodeid; in fuse_iget()
377 inode->i_flags |= S_AUTOMOUNT; in fuse_iget()
386 if ((inode->i_state & I_NEW)) { in fuse_iget()
387 inode->i_flags |= S_NOATIME; in fuse_iget()
388 if (!fc->writeback_cache || !S_ISREG(attr->mode)) in fuse_iget()
389 inode->i_flags |= S_NOCMTIME; in fuse_iget()
390 inode->i_generation = generation; in fuse_iget()
401 spin_lock(&fi->lock); in fuse_iget()
402 fi->nlookup++; in fuse_iget()
403 spin_unlock(&fi->lock); in fuse_iget()
415 WARN_ON(!rwsem_is_locked(&fc->killsb)); in fuse_ilookup()
416 list_for_each_entry(fm_iter, &fc->mounts, fc_entry) { in fuse_ilookup()
417 if (!fm_iter->sb) in fuse_ilookup()
420 inode = ilookup5(fm_iter->sb, nodeid, fuse_inode_eq, &nodeid); in fuse_ilookup()
441 return -ENOENT; in fuse_reverse_inval_inode()
444 spin_lock(&fi->lock); in fuse_reverse_inval_inode()
445 fi->attr_version = atomic64_inc_return(&fc->attr_version); in fuse_reverse_inval_inode()
446 spin_unlock(&fi->lock); in fuse_reverse_inval_inode()
453 pg_end = -1; in fuse_reverse_inval_inode()
455 pg_end = (offset + len - 1) >> PAGE_SHIFT; in fuse_reverse_inval_inode()
456 invalidate_inode_pages2_range(inode->i_mapping, in fuse_reverse_inval_inode()
467 if (!get_fuse_conn(inode)->parallel_dirops) { in fuse_lock_inode()
468 mutex_lock(&get_fuse_inode(inode)->mutex); in fuse_lock_inode()
478 mutex_unlock(&get_fuse_inode(inode)->mutex); in fuse_unlock_inode()
485 if (fc->no_force_umount) in fuse_umount_begin()
490 // Only retire block-device-based superblocks. in fuse_umount_begin()
491 if (sb->s_bdev != NULL) in fuse_umount_begin()
497 if (fm->fc->conn_init) { in fuse_send_destroy()
509 stbuf->f_type = FUSE_SUPER_MAGIC; in convert_fuse_statfs()
510 stbuf->f_bsize = attr->bsize; in convert_fuse_statfs()
511 stbuf->f_frsize = attr->frsize; in convert_fuse_statfs()
512 stbuf->f_blocks = attr->blocks; in convert_fuse_statfs()
513 stbuf->f_bfree = attr->bfree; in convert_fuse_statfs()
514 stbuf->f_bavail = attr->bavail; in convert_fuse_statfs()
515 stbuf->f_files = attr->files; in convert_fuse_statfs()
516 stbuf->f_ffree = attr->ffree; in convert_fuse_statfs()
517 stbuf->f_namelen = attr->namelen; in convert_fuse_statfs()
523 struct super_block *sb = dentry->d_sb; in fuse_statfs()
529 if (!fuse_allow_current_process(fm->fc)) { in fuse_statfs()
530 buf->f_type = FUSE_SUPER_MAGIC; in fuse_statfs()
553 init_waitqueue_head(&bucket->waitq); in fuse_sync_bucket_alloc()
555 atomic_set(&bucket->count, 1); in fuse_sync_bucket_alloc()
566 spin_lock(&fc->lock); in fuse_sync_fs_writes()
567 bucket = rcu_dereference_protected(fc->curr_bucket, 1); in fuse_sync_fs_writes()
568 count = atomic_read(&bucket->count); in fuse_sync_fs_writes()
572 spin_unlock(&fc->lock); in fuse_sync_fs_writes()
581 atomic_inc(&new_bucket->count); in fuse_sync_fs_writes()
582 rcu_assign_pointer(fc->curr_bucket, new_bucket); in fuse_sync_fs_writes()
583 spin_unlock(&fc->lock); in fuse_sync_fs_writes()
589 atomic_dec(&bucket->count); in fuse_sync_fs_writes()
591 wait_event(bucket->waitq, atomic_read(&bucket->count) == 0); in fuse_sync_fs_writes()
601 struct fuse_conn *fc = fm->fc; in fuse_sync_fs()
614 if (!sb->s_root) in fuse_sync_fs()
617 if (!fc->sync_fs) in fuse_sync_fs()
627 args.nodeid = get_node_id(sb->s_root->d_inode); in fuse_sync_fs()
631 if (err == -ENOSYS) { in fuse_sync_fs()
632 fc->sync_fs = 0; in fuse_sync_fs()
670 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_parse_param()
673 if (fsc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { in fuse_parse_param()
678 if (fsc->oldapi) in fuse_parse_param()
690 if (fsc->source) in fuse_parse_param()
692 fsc->source = param->string; in fuse_parse_param()
693 param->string = NULL; in fuse_parse_param()
697 if (ctx->subtype) in fuse_parse_param()
699 ctx->subtype = param->string; in fuse_parse_param()
700 param->string = NULL; in fuse_parse_param()
704 ctx->fd = result.uint_32; in fuse_parse_param()
705 ctx->fd_present = true; in fuse_parse_param()
711 ctx->rootmode = result.uint_32; in fuse_parse_param()
712 ctx->rootmode_present = true; in fuse_parse_param()
716 ctx->user_id = make_kuid(fsc->user_ns, result.uint_32); in fuse_parse_param()
717 if (!uid_valid(ctx->user_id)) in fuse_parse_param()
719 ctx->user_id_present = true; in fuse_parse_param()
723 ctx->group_id = make_kgid(fsc->user_ns, result.uint_32); in fuse_parse_param()
724 if (!gid_valid(ctx->group_id)) in fuse_parse_param()
726 ctx->group_id_present = true; in fuse_parse_param()
730 ctx->default_permissions = true; in fuse_parse_param()
734 ctx->allow_other = true; in fuse_parse_param()
738 ctx->max_read = result.uint_32; in fuse_parse_param()
742 if (!ctx->is_bdev) in fuse_parse_param()
744 ctx->blksize = result.uint_32; in fuse_parse_param()
748 return -EINVAL; in fuse_parse_param()
756 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_free_fsc()
759 kfree(ctx->subtype); in fuse_free_fsc()
766 struct super_block *sb = root->d_sb; in fuse_show_options()
769 if (fc->legacy_opts_show) { in fuse_show_options()
771 from_kuid_munged(fc->user_ns, fc->user_id)); in fuse_show_options()
773 from_kgid_munged(fc->user_ns, fc->group_id)); in fuse_show_options()
774 if (fc->default_permissions) in fuse_show_options()
776 if (fc->allow_other) in fuse_show_options()
778 if (fc->max_read != ~0) in fuse_show_options()
779 seq_printf(m, ",max_read=%u", fc->max_read); in fuse_show_options()
780 if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) in fuse_show_options()
781 seq_printf(m, ",blksize=%lu", sb->s_blocksize); in fuse_show_options()
784 if (fc->dax_mode == FUSE_DAX_ALWAYS) in fuse_show_options()
786 else if (fc->dax_mode == FUSE_DAX_NEVER) in fuse_show_options()
788 else if (fc->dax_mode == FUSE_DAX_INODE_USER) in fuse_show_options()
795 static void fuse_iqueue_init(struct fuse_iqueue *fiq, in fuse_iqueue_init() argument
799 memset(fiq, 0, sizeof(struct fuse_iqueue)); in fuse_iqueue_init()
800 spin_lock_init(&fiq->lock); in fuse_iqueue_init()
801 init_waitqueue_head(&fiq->waitq); in fuse_iqueue_init()
802 INIT_LIST_HEAD(&fiq->pending); in fuse_iqueue_init()
803 INIT_LIST_HEAD(&fiq->interrupts); in fuse_iqueue_init()
804 fiq->forget_list_tail = &fiq->forget_list_head; in fuse_iqueue_init()
805 fiq->connected = 1; in fuse_iqueue_init()
806 fiq->ops = ops; in fuse_iqueue_init()
807 fiq->priv = priv; in fuse_iqueue_init()
814 spin_lock_init(&fpq->lock); in fuse_pqueue_init()
816 INIT_LIST_HEAD(&fpq->processing[i]); in fuse_pqueue_init()
817 INIT_LIST_HEAD(&fpq->io); in fuse_pqueue_init()
818 fpq->connected = 1; in fuse_pqueue_init()
826 spin_lock_init(&fc->lock); in fuse_conn_init()
827 spin_lock_init(&fc->bg_lock); in fuse_conn_init()
828 init_rwsem(&fc->killsb); in fuse_conn_init()
829 refcount_set(&fc->count, 1); in fuse_conn_init()
830 atomic_set(&fc->dev_count, 1); in fuse_conn_init()
831 init_waitqueue_head(&fc->blocked_waitq); in fuse_conn_init()
832 fuse_iqueue_init(&fc->iq, fiq_ops, fiq_priv); in fuse_conn_init()
833 INIT_LIST_HEAD(&fc->bg_queue); in fuse_conn_init()
834 INIT_LIST_HEAD(&fc->entry); in fuse_conn_init()
835 INIT_LIST_HEAD(&fc->devices); in fuse_conn_init()
836 atomic_set(&fc->num_waiting, 0); in fuse_conn_init()
837 fc->max_background = FUSE_DEFAULT_MAX_BACKGROUND; in fuse_conn_init()
838 fc->congestion_threshold = FUSE_DEFAULT_CONGESTION_THRESHOLD; in fuse_conn_init()
839 atomic64_set(&fc->khctr, 0); in fuse_conn_init()
840 fc->polled_files = RB_ROOT; in fuse_conn_init()
841 fc->blocked = 0; in fuse_conn_init()
842 fc->initialized = 0; in fuse_conn_init()
843 fc->connected = 1; in fuse_conn_init()
844 atomic64_set(&fc->attr_version, 1); in fuse_conn_init()
845 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); in fuse_conn_init()
846 fc->pid_ns = get_pid_ns(task_active_pid_ns(current)); in fuse_conn_init()
847 fc->user_ns = get_user_ns(user_ns); in fuse_conn_init()
848 fc->max_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; in fuse_conn_init()
849 fc->max_pages_limit = FUSE_MAX_MAX_PAGES; in fuse_conn_init()
851 INIT_LIST_HEAD(&fc->mounts); in fuse_conn_init()
852 list_add(&fm->fc_entry, &fc->mounts); in fuse_conn_init()
853 fm->fc = fc; in fuse_conn_init()
859 if (refcount_dec_and_test(&fc->count)) { in fuse_conn_put()
860 struct fuse_iqueue *fiq = &fc->iq; in fuse_conn_put() local
865 if (fiq->ops->release) in fuse_conn_put()
866 fiq->ops->release(fiq); in fuse_conn_put()
867 put_pid_ns(fc->pid_ns); in fuse_conn_put()
868 put_user_ns(fc->user_ns); in fuse_conn_put()
869 bucket = rcu_dereference_protected(fc->curr_bucket, 1); in fuse_conn_put()
871 WARN_ON(atomic_read(&bucket->count) != 1); in fuse_conn_put()
874 fc->release(fc); in fuse_conn_put()
881 refcount_inc(&fc->count); in fuse_conn_get()
908 int err = -ESTALE; in fuse_get_dentry()
910 if (handle->nodeid == 0) in fuse_get_dentry()
913 inode = ilookup5(sb, handle->nodeid, fuse_inode_eq, &handle->nodeid); in fuse_get_dentry()
918 if (!fc->export_support) in fuse_get_dentry()
921 err = fuse_lookup_name(sb, handle->nodeid, &name, &outarg, in fuse_get_dentry()
923 if (err && err != -ENOENT) in fuse_get_dentry()
926 err = -ESTALE; in fuse_get_dentry()
929 err = -EIO; in fuse_get_dentry()
930 if (get_node_id(inode) != handle->nodeid) in fuse_get_dentry()
933 err = -ESTALE; in fuse_get_dentry()
934 if (inode->i_generation != handle->generation) in fuse_get_dentry()
961 nodeid = get_fuse_inode(inode)->nodeid; in fuse_encode_fh()
962 generation = inode->i_generation; in fuse_encode_fh()
969 nodeid = get_fuse_inode(parent)->nodeid; in fuse_encode_fh()
970 generation = parent->i_generation; in fuse_encode_fh()
989 handle.nodeid = (u64) fid->raw[0] << 32; in fuse_fh_to_dentry()
990 handle.nodeid |= (u64) fid->raw[1]; in fuse_fh_to_dentry()
991 handle.generation = fid->raw[2]; in fuse_fh_to_dentry()
1003 parent.nodeid = (u64) fid->raw[3] << 32; in fuse_fh_to_parent()
1004 parent.nodeid |= (u64) fid->raw[4]; in fuse_fh_to_parent()
1005 parent.generation = fid->raw[5]; in fuse_fh_to_parent()
1018 if (!fc->export_support) in fuse_get_parent()
1019 return ERR_PTR(-ESTALE); in fuse_get_parent()
1021 err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode), in fuse_get_parent()
1024 if (err == -ENOENT) in fuse_get_parent()
1025 return ERR_PTR(-ESTALE); in fuse_get_parent()
1065 *limit = (1 << 16) - 1; in sanitize_global_limit()
1076 sanitize_global_limit((unsigned *)kp->arg); in set_global_limit()
1085 if (arg->minor < 13) in process_init_limits()
1091 spin_lock(&fc->bg_lock); in process_init_limits()
1092 if (arg->max_background) { in process_init_limits()
1093 fc->max_background = arg->max_background; in process_init_limits()
1095 if (!cap_sys_admin && fc->max_background > max_user_bgreq) in process_init_limits()
1096 fc->max_background = max_user_bgreq; in process_init_limits()
1098 if (arg->congestion_threshold) { in process_init_limits()
1099 fc->congestion_threshold = arg->congestion_threshold; in process_init_limits()
1102 fc->congestion_threshold > max_user_congthresh) in process_init_limits()
1103 fc->congestion_threshold = max_user_congthresh; in process_init_limits()
1105 spin_unlock(&fc->bg_lock); in process_init_limits()
1117 struct fuse_conn *fc = fm->fc; in process_init_reply()
1119 struct fuse_init_out *arg = &ia->out; in process_init_reply()
1122 if (error || arg->major != FUSE_KERNEL_VERSION) in process_init_reply()
1129 if (arg->minor >= 6) { in process_init_reply()
1130 u64 flags = arg->flags | (u64) arg->flags2 << 32; in process_init_reply()
1132 ra_pages = arg->max_readahead / PAGE_SIZE; in process_init_reply()
1134 fc->async_read = 1; in process_init_reply()
1136 fc->no_lock = 1; in process_init_reply()
1137 if (arg->minor >= 17) { in process_init_reply()
1139 fc->no_flock = 1; in process_init_reply()
1142 fc->no_flock = 1; in process_init_reply()
1145 fc->atomic_o_trunc = 1; in process_init_reply()
1146 if (arg->minor >= 9) { in process_init_reply()
1149 fc->export_support = 1; in process_init_reply()
1152 fc->big_writes = 1; in process_init_reply()
1154 fc->dont_mask = 1; in process_init_reply()
1156 fc->auto_inval_data = 1; in process_init_reply()
1158 fc->explicit_inval_data = 1; in process_init_reply()
1160 fc->do_readdirplus = 1; in process_init_reply()
1162 fc->readdirplus_auto = 1; in process_init_reply()
1165 fc->async_dio = 1; in process_init_reply()
1167 fc->writeback_cache = 1; in process_init_reply()
1169 fc->parallel_dirops = 1; in process_init_reply()
1171 fc->handle_killpriv = 1; in process_init_reply()
1172 if (arg->time_gran && arg->time_gran <= 1000000000) in process_init_reply()
1173 fm->sb->s_time_gran = arg->time_gran; in process_init_reply()
1175 fc->default_permissions = 1; in process_init_reply()
1176 fc->posix_acl = 1; in process_init_reply()
1177 fm->sb->s_xattr = fuse_acl_xattr_handlers; in process_init_reply()
1180 fc->cache_symlinks = 1; in process_init_reply()
1182 fc->abort_err = 1; in process_init_reply()
1184 fc->max_pages = in process_init_reply()
1185 min_t(unsigned int, fc->max_pages_limit, in process_init_reply()
1186 max_t(unsigned int, arg->max_pages, 1)); in process_init_reply()
1190 !fuse_dax_check_alignment(fc, arg->map_alignment)) { in process_init_reply()
1194 fc->inode_dax = 1; in process_init_reply()
1197 fc->handle_killpriv_v2 = 1; in process_init_reply()
1198 fm->sb->s_flags |= SB_NOSEC; in process_init_reply()
1201 fc->setxattr_ext = 1; in process_init_reply()
1203 fc->init_security = 1; in process_init_reply()
1205 ra_pages = fc->max_read / PAGE_SIZE; in process_init_reply()
1206 fc->no_lock = 1; in process_init_reply()
1207 fc->no_flock = 1; in process_init_reply()
1210 fm->sb->s_bdi->ra_pages = in process_init_reply()
1211 min(fm->sb->s_bdi->ra_pages, ra_pages); in process_init_reply()
1212 fc->minor = arg->minor; in process_init_reply()
1213 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; in process_init_reply()
1214 fc->max_write = max_t(unsigned, 4096, fc->max_write); in process_init_reply()
1215 fc->conn_init = 1; in process_init_reply()
1220 fc->conn_init = 0; in process_init_reply()
1221 fc->conn_error = 1; in process_init_reply()
1225 wake_up_all(&fc->blocked_waitq); in process_init_reply()
1235 ia->in.major = FUSE_KERNEL_VERSION; in fuse_send_init()
1236 ia->in.minor = FUSE_KERNEL_MINOR_VERSION; in fuse_send_init()
1237 ia->in.max_readahead = fm->sb->s_bdi->ra_pages * PAGE_SIZE; in fuse_send_init()
1251 if (fm->fc->dax) in fuse_send_init()
1253 if (fuse_is_inode_dax_mode(fm->fc->dax_mode)) in fuse_send_init()
1256 if (fm->fc->auto_submounts) in fuse_send_init()
1259 ia->in.flags = flags; in fuse_send_init()
1260 ia->in.flags2 = flags >> 32; in fuse_send_init()
1262 ia->args.opcode = FUSE_INIT; in fuse_send_init()
1263 ia->args.in_numargs = 1; in fuse_send_init()
1264 ia->args.in_args[0].size = sizeof(ia->in); in fuse_send_init()
1265 ia->args.in_args[0].value = &ia->in; in fuse_send_init()
1266 ia->args.out_numargs = 1; in fuse_send_init()
1270 ia->args.out_argvar = true; in fuse_send_init()
1271 ia->args.out_args[0].size = sizeof(ia->out); in fuse_send_init()
1272 ia->args.out_args[0].value = &ia->out; in fuse_send_init()
1273 ia->args.force = true; in fuse_send_init()
1274 ia->args.nocreds = true; in fuse_send_init()
1275 ia->args.end = process_init_reply; in fuse_send_init()
1277 if (fuse_simple_background(fm, &ia->args, GFP_KERNEL) != 0) in fuse_send_init()
1278 process_init_reply(fm, &ia->args, -ENOTCONN); in fuse_send_init()
1284 WARN_ON(!list_empty(&fc->devices)); in fuse_free_conn()
1294 if (sb->s_bdev) { in fuse_bdi_init()
1295 suffix = "-fuseblk"; in fuse_bdi_init()
1297 * sb->s_bdi points to blkdev's bdi however we want to redirect in fuse_bdi_init()
1300 bdi_put(sb->s_bdi); in fuse_bdi_init()
1301 sb->s_bdi = &noop_backing_dev_info; in fuse_bdi_init()
1303 err = super_setup_bdi_name(sb, "%u:%u%s", MAJOR(fc->dev), in fuse_bdi_init()
1304 MINOR(fc->dev), suffix); in fuse_bdi_init()
1309 sb->s_bdi->capabilities &= ~BDI_CAP_WRITEBACK_ACCT; in fuse_bdi_init()
1310 sb->s_bdi->capabilities |= BDI_CAP_STRICTLIMIT; in fuse_bdi_init()
1324 bdi_set_max_ratio(sb->s_bdi, 1); in fuse_bdi_init()
1344 fud->pq.processing = pq; in fuse_dev_alloc()
1345 fuse_pqueue_init(&fud->pq); in fuse_dev_alloc()
1353 fud->fc = fuse_conn_get(fc); in fuse_dev_install()
1354 spin_lock(&fc->lock); in fuse_dev_install()
1355 list_add_tail(&fud->entry, &fc->devices); in fuse_dev_install()
1356 spin_unlock(&fc->lock); in fuse_dev_install()
1375 struct fuse_conn *fc = fud->fc; in fuse_dev_free()
1378 spin_lock(&fc->lock); in fuse_dev_free()
1379 list_del(&fud->entry); in fuse_dev_free()
1380 spin_unlock(&fc->lock); in fuse_dev_free()
1384 kfree(fud->pq.processing); in fuse_dev_free()
1393 .ino = fi->inode.i_ino, in fuse_fill_attr_from_inode()
1394 .size = fi->inode.i_size, in fuse_fill_attr_from_inode()
1395 .blocks = fi->inode.i_blocks, in fuse_fill_attr_from_inode()
1396 .atime = fi->inode.i_atime.tv_sec, in fuse_fill_attr_from_inode()
1397 .mtime = fi->inode.i_mtime.tv_sec, in fuse_fill_attr_from_inode()
1398 .ctime = fi->inode.i_ctime.tv_sec, in fuse_fill_attr_from_inode()
1399 .atimensec = fi->inode.i_atime.tv_nsec, in fuse_fill_attr_from_inode()
1400 .mtimensec = fi->inode.i_mtime.tv_nsec, in fuse_fill_attr_from_inode()
1401 .ctimensec = fi->inode.i_ctime.tv_nsec, in fuse_fill_attr_from_inode()
1402 .mode = fi->inode.i_mode, in fuse_fill_attr_from_inode()
1403 .nlink = fi->inode.i_nlink, in fuse_fill_attr_from_inode()
1404 .uid = fi->inode.i_uid.val, in fuse_fill_attr_from_inode()
1405 .gid = fi->inode.i_gid.val, in fuse_fill_attr_from_inode()
1406 .rdev = fi->inode.i_rdev, in fuse_fill_attr_from_inode()
1407 .blksize = 1u << fi->inode.i_blkbits, in fuse_fill_attr_from_inode()
1413 sb->s_magic = FUSE_SUPER_MAGIC; in fuse_sb_defaults()
1414 sb->s_op = &fuse_super_operations; in fuse_sb_defaults()
1415 sb->s_xattr = fuse_xattr_handlers; in fuse_sb_defaults()
1416 sb->s_maxbytes = MAX_LFS_FILESIZE; in fuse_sb_defaults()
1417 sb->s_time_gran = 1; in fuse_sb_defaults()
1418 sb->s_export_op = &fuse_export_operations; in fuse_sb_defaults()
1419 sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE; in fuse_sb_defaults()
1420 if (sb->s_user_ns != &init_user_ns) in fuse_sb_defaults()
1421 sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER; in fuse_sb_defaults()
1422 sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION); in fuse_sb_defaults()
1428 if (sb->s_user_ns != &init_user_ns) in fuse_sb_defaults()
1429 sb->s_xattr = fuse_no_acl_xattr_handlers; in fuse_sb_defaults()
1436 struct super_block *parent_sb = parent_fi->inode.i_sb; in fuse_fill_super_submount()
1441 fm->sb = sb; in fuse_fill_super_submount()
1443 WARN_ON(sb->s_bdi != &noop_backing_dev_info); in fuse_fill_super_submount()
1444 sb->s_bdi = bdi_get(parent_sb->s_bdi); in fuse_fill_super_submount()
1446 sb->s_xattr = parent_sb->s_xattr; in fuse_fill_super_submount()
1447 sb->s_time_gran = parent_sb->s_time_gran; in fuse_fill_super_submount()
1448 sb->s_blocksize = parent_sb->s_blocksize; in fuse_fill_super_submount()
1449 sb->s_blocksize_bits = parent_sb->s_blocksize_bits; in fuse_fill_super_submount()
1450 sb->s_subtype = kstrdup(parent_sb->s_subtype, GFP_KERNEL); in fuse_fill_super_submount()
1451 if (parent_sb->s_subtype && !sb->s_subtype) in fuse_fill_super_submount()
1452 return -ENOMEM; in fuse_fill_super_submount()
1455 root = fuse_iget(sb, parent_fi->nodeid, 0, &root_attr, 0, 0); in fuse_fill_super_submount()
1461 get_fuse_inode(root)->nlookup--; in fuse_fill_super_submount()
1462 sb->s_d_op = &fuse_dentry_operations; in fuse_fill_super_submount()
1463 sb->s_root = d_make_root(root); in fuse_fill_super_submount()
1464 if (!sb->s_root) in fuse_fill_super_submount()
1465 return -ENOMEM; in fuse_fill_super_submount()
1474 struct fuse_inode *mp_fi = fsc->fs_private; in fuse_get_tree_submount()
1475 struct fuse_conn *fc = get_fuse_conn(&mp_fi->inode); in fuse_get_tree_submount()
1481 return -ENOMEM; in fuse_get_tree_submount()
1483 fm->fc = fuse_conn_get(fc); in fuse_get_tree_submount()
1484 fsc->s_fs_info = fm; in fuse_get_tree_submount()
1486 if (fsc->s_fs_info) in fuse_get_tree_submount()
1498 down_write(&fc->killsb); in fuse_get_tree_submount()
1499 list_add_tail(&fm->fc_entry, &fc->mounts); in fuse_get_tree_submount()
1500 up_write(&fc->killsb); in fuse_get_tree_submount()
1502 sb->s_flags |= SB_ACTIVE; in fuse_get_tree_submount()
1503 fsc->root = dget(sb->s_root); in fuse_get_tree_submount()
1514 fsc->ops = &fuse_context_submount_ops; in fuse_init_fs_context_submount()
1523 struct fuse_conn *fc = fm->fc; in fuse_fill_super_common()
1528 err = -EINVAL; in fuse_fill_super_common()
1529 if (sb->s_flags & SB_MANDLOCK) in fuse_fill_super_common()
1532 rcu_assign_pointer(fc->curr_bucket, fuse_sync_bucket_alloc()); in fuse_fill_super_common()
1535 if (ctx->is_bdev) { in fuse_fill_super_common()
1537 err = -EINVAL; in fuse_fill_super_common()
1538 if (!sb_set_blocksize(sb, ctx->blksize)) in fuse_fill_super_common()
1542 sb->s_blocksize = PAGE_SIZE; in fuse_fill_super_common()
1543 sb->s_blocksize_bits = PAGE_SHIFT; in fuse_fill_super_common()
1546 sb->s_subtype = ctx->subtype; in fuse_fill_super_common()
1547 ctx->subtype = NULL; in fuse_fill_super_common()
1549 err = fuse_dax_conn_alloc(fc, ctx->dax_mode, ctx->dax_dev); in fuse_fill_super_common()
1554 if (ctx->fudptr) { in fuse_fill_super_common()
1555 err = -ENOMEM; in fuse_fill_super_common()
1561 fc->dev = sb->s_dev; in fuse_fill_super_common()
1562 fm->sb = sb; in fuse_fill_super_common()
1568 if (sb->s_flags & SB_POSIXACL) in fuse_fill_super_common()
1569 fc->dont_mask = 1; in fuse_fill_super_common()
1570 sb->s_flags |= SB_POSIXACL; in fuse_fill_super_common()
1572 fc->default_permissions = ctx->default_permissions; in fuse_fill_super_common()
1573 fc->allow_other = ctx->allow_other; in fuse_fill_super_common()
1574 fc->user_id = ctx->user_id; in fuse_fill_super_common()
1575 fc->group_id = ctx->group_id; in fuse_fill_super_common()
1576 fc->legacy_opts_show = ctx->legacy_opts_show; in fuse_fill_super_common()
1577 fc->max_read = max_t(unsigned int, 4096, ctx->max_read); in fuse_fill_super_common()
1578 fc->destroy = ctx->destroy; in fuse_fill_super_common()
1579 fc->no_control = ctx->no_control; in fuse_fill_super_common()
1580 fc->no_force_umount = ctx->no_force_umount; in fuse_fill_super_common()
1582 err = -ENOMEM; in fuse_fill_super_common()
1583 root = fuse_get_root_inode(sb, ctx->rootmode); in fuse_fill_super_common()
1584 sb->s_d_op = &fuse_root_dentry_operations; in fuse_fill_super_common()
1589 sb->s_d_op = &fuse_dentry_operations; in fuse_fill_super_common()
1592 err = -EINVAL; in fuse_fill_super_common()
1593 if (ctx->fudptr && *ctx->fudptr) in fuse_fill_super_common()
1600 list_add_tail(&fc->entry, &fuse_conn_list); in fuse_fill_super_common()
1601 sb->s_root = root_dentry; in fuse_fill_super_common()
1602 if (ctx->fudptr) in fuse_fill_super_common()
1603 *ctx->fudptr = fud; in fuse_fill_super_common()
1623 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_fill_super()
1626 if (!ctx->file || !ctx->rootmode_present || in fuse_fill_super()
1627 !ctx->user_id_present || !ctx->group_id_present) in fuse_fill_super()
1628 return -EINVAL; in fuse_fill_super()
1634 if ((ctx->file->f_op != &fuse_dev_operations) || in fuse_fill_super()
1635 (ctx->file->f_cred->user_ns != sb->s_user_ns)) in fuse_fill_super()
1636 return -EINVAL; in fuse_fill_super()
1637 ctx->fudptr = &ctx->file->private_data; in fuse_fill_super()
1642 /* file->private_data shall be visible on all CPUs after this */ in fuse_fill_super()
1654 return -ENOTCONN; in fuse_set_no_super()
1660 return fsc->sget_key == get_fuse_conn_super(sb); in fuse_test_super()
1665 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_get_tree()
1674 return -ENOMEM; in fuse_get_tree()
1679 return -ENOMEM; in fuse_get_tree()
1682 fuse_conn_init(fc, fm, fsc->user_ns, &fuse_dev_fiq_ops, NULL); in fuse_get_tree()
1683 fc->release = fuse_free_conn; in fuse_get_tree()
1685 fsc->s_fs_info = fm; in fuse_get_tree()
1687 if (ctx->fd_present) in fuse_get_tree()
1688 ctx->file = fget(ctx->fd); in fuse_get_tree()
1690 if (IS_ENABLED(CONFIG_BLOCK) && ctx->is_bdev) { in fuse_get_tree()
1698 err = -EINVAL; in fuse_get_tree()
1699 if (!ctx->file) in fuse_get_tree()
1706 fud = READ_ONCE(ctx->file->private_data); in fuse_get_tree()
1707 if (ctx->file->f_op == &fuse_dev_operations && fud) { in fuse_get_tree()
1708 fsc->sget_key = fud->fc; in fuse_get_tree()
1712 fsc->root = dget(sb->s_root); in fuse_get_tree()
1717 if (fsc->s_fs_info) in fuse_get_tree()
1719 if (ctx->file) in fuse_get_tree()
1720 fput(ctx->file); in fuse_get_tree()
1740 return -ENOMEM; in fuse_init_fs_context()
1742 ctx->max_read = ~0; in fuse_init_fs_context()
1743 ctx->blksize = FUSE_DEFAULT_BLKSIZE; in fuse_init_fs_context()
1744 ctx->legacy_opts_show = true; in fuse_init_fs_context()
1747 if (fsc->fs_type == &fuseblk_fs_type) { in fuse_init_fs_context()
1748 ctx->is_bdev = true; in fuse_init_fs_context()
1749 ctx->destroy = true; in fuse_init_fs_context()
1753 fsc->fs_private = ctx; in fuse_init_fs_context()
1754 fsc->ops = &fuse_context_ops; in fuse_init_fs_context()
1760 struct fuse_conn *fc = fm->fc; in fuse_mount_remove()
1763 down_write(&fc->killsb); in fuse_mount_remove()
1764 list_del_init(&fm->fc_entry); in fuse_mount_remove()
1765 if (list_empty(&fc->mounts)) in fuse_mount_remove()
1767 up_write(&fc->killsb); in fuse_mount_remove()
1775 struct fuse_conn *fc = fm->fc; in fuse_conn_destroy()
1777 if (fc->destroy) in fuse_conn_destroy()
1783 if (!list_empty(&fc->entry)) { in fuse_conn_destroy()
1785 list_del(&fc->entry); in fuse_conn_destroy()
1797 if (sb->s_root) { in fuse_sb_destroy()
1806 fuse_conn_put(fm->fc); in fuse_mount_destroy()
1881 err = -ENOMEM; in fuse_fs_init()
1924 err = -ENOMEM; in fuse_sysfs_init()