Lines Matching +full:fiq +full:- +full:device
3 Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
78 sl->forget = fuse_alloc_forget(); in fuse_alloc_submount_lookup()
79 if (!sl->forget) in fuse_alloc_submount_lookup()
97 fi->i_time = 0; in fuse_alloc_inode()
98 fi->inval_mask = ~0; in fuse_alloc_inode()
99 fi->nodeid = 0; in fuse_alloc_inode()
100 fi->nlookup = 0; in fuse_alloc_inode()
101 fi->attr_version = 0; in fuse_alloc_inode()
102 fi->orig_ino = 0; in fuse_alloc_inode()
103 fi->state = 0; in fuse_alloc_inode()
104 fi->submount_lookup = NULL; in fuse_alloc_inode()
105 mutex_init(&fi->mutex); in fuse_alloc_inode()
106 spin_lock_init(&fi->lock); in fuse_alloc_inode()
107 fi->forget = fuse_alloc_forget(); in fuse_alloc_inode()
108 if (!fi->forget) in fuse_alloc_inode()
117 return &fi->inode; in fuse_alloc_inode()
120 kfree(fi->forget); in fuse_alloc_inode()
130 mutex_destroy(&fi->mutex); in fuse_free_inode()
131 kfree(fi->forget); in fuse_free_inode()
133 kfree(fi->dax); in fuse_free_inode()
144 if (!refcount_dec_and_test(&sl->count)) in fuse_cleanup_submount_lookup()
147 fuse_queue_forget(fc, sl->forget, sl->nodeid, 1); in fuse_cleanup_submount_lookup()
148 sl->forget = NULL; in fuse_cleanup_submount_lookup()
157 WARN_ON(inode->i_state & I_DIRTY_INODE); in fuse_evict_inode()
159 truncate_inode_pages_final(&inode->i_data); in fuse_evict_inode()
161 if (inode->i_sb->s_flags & SB_ACTIVE) { in fuse_evict_inode()
166 if (fi->nlookup) { in fuse_evict_inode()
167 fuse_queue_forget(fc, fi->forget, fi->nodeid, in fuse_evict_inode()
168 fi->nlookup); in fuse_evict_inode()
169 fi->forget = NULL; in fuse_evict_inode()
172 if (fi->submount_lookup) { in fuse_evict_inode()
173 fuse_cleanup_submount_lookup(fc, fi->submount_lookup); in fuse_evict_inode()
174 fi->submount_lookup = NULL; in fuse_evict_inode()
177 if (S_ISREG(inode->i_mode) && !fuse_is_bad(inode)) { in fuse_evict_inode()
178 WARN_ON(fi->iocachectr != 0); in fuse_evict_inode()
179 WARN_ON(!list_empty(&fi->write_files)); in fuse_evict_inode()
180 WARN_ON(!list_empty(&fi->queued_writes)); in fuse_evict_inode()
186 struct super_block *sb = fsc->root->d_sb; in fuse_reconfigure()
189 if (fsc->sb_flags & SB_MANDLOCK) in fuse_reconfigure()
190 return -EINVAL; in fuse_reconfigure()
196 * ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down
203 ino ^= ino64 >> (sizeof(u64) - sizeof(ino_t)) * 8; in fuse_squash_ino()
214 lockdep_assert_held(&fi->lock); in fuse_change_attributes_common()
216 fi->attr_version = atomic64_inc_return(&fc->attr_version); in fuse_change_attributes_common()
217 fi->i_time = attr_valid; in fuse_change_attributes_common()
219 set_mask_bits(&fi->inval_mask, STATX_BASIC_STATS, 0); in fuse_change_attributes_common()
221 inode->i_ino = fuse_squash_ino(attr->ino); in fuse_change_attributes_common()
222 inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777); in fuse_change_attributes_common()
223 set_nlink(inode, attr->nlink); in fuse_change_attributes_common()
224 inode->i_uid = make_kuid(fc->user_ns, attr->uid); in fuse_change_attributes_common()
225 inode->i_gid = make_kgid(fc->user_ns, attr->gid); in fuse_change_attributes_common()
226 inode->i_blocks = attr->blocks; in fuse_change_attributes_common()
229 attr->atimensec = min_t(u32, attr->atimensec, NSEC_PER_SEC - 1); in fuse_change_attributes_common()
230 attr->mtimensec = min_t(u32, attr->mtimensec, NSEC_PER_SEC - 1); in fuse_change_attributes_common()
231 attr->ctimensec = min_t(u32, attr->ctimensec, NSEC_PER_SEC - 1); in fuse_change_attributes_common()
233 inode_set_atime(inode, attr->atime, attr->atimensec); in fuse_change_attributes_common()
236 inode_set_mtime(inode, attr->mtime, attr->mtimensec); in fuse_change_attributes_common()
239 inode_set_ctime(inode, attr->ctime, attr->ctimensec); in fuse_change_attributes_common()
243 sx->btime.tv_nsec = in fuse_change_attributes_common()
244 min_t(u32, sx->btime.tv_nsec, NSEC_PER_SEC - 1); in fuse_change_attributes_common()
253 set_mask_bits(&fi->inval_mask, STATX_BTIME, 0); in fuse_change_attributes_common()
254 if (sx->mask & STATX_BTIME) { in fuse_change_attributes_common()
255 set_bit(FUSE_I_BTIME, &fi->state); in fuse_change_attributes_common()
256 fi->i_btime.tv_sec = sx->btime.tv_sec; in fuse_change_attributes_common()
257 fi->i_btime.tv_nsec = sx->btime.tv_nsec; in fuse_change_attributes_common()
261 if (attr->blksize != 0) in fuse_change_attributes_common()
262 inode->i_blkbits = ilog2(attr->blksize); in fuse_change_attributes_common()
264 inode->i_blkbits = inode->i_sb->s_blocksize_bits; in fuse_change_attributes_common()
271 fi->orig_i_mode = inode->i_mode; in fuse_change_attributes_common()
272 if (!fc->default_permissions) in fuse_change_attributes_common()
273 inode->i_mode &= ~S_ISVTX; in fuse_change_attributes_common()
275 fi->orig_ino = attr->ino; in fuse_change_attributes_common()
285 inode->i_flags &= ~S_NOSEC; in fuse_change_attributes_common()
292 if (!fc->writeback_cache || !S_ISREG(inode->i_mode)) in fuse_get_cache_mask()
308 spin_lock(&fi->lock); in fuse_change_attributes()
316 attr->size = i_size_read(inode); in fuse_change_attributes()
319 attr->mtime = inode_get_mtime_sec(inode); in fuse_change_attributes()
320 attr->mtimensec = inode_get_mtime_nsec(inode); in fuse_change_attributes()
323 attr->ctime = inode_get_ctime_sec(inode); in fuse_change_attributes()
324 attr->ctimensec = inode_get_ctime_nsec(inode); in fuse_change_attributes()
327 if ((attr_version != 0 && fi->attr_version > attr_version) || in fuse_change_attributes()
328 test_bit(FUSE_I_SIZE_UNSTABLE, &fi->state)) { in fuse_change_attributes()
329 spin_unlock(&fi->lock); in fuse_change_attributes()
336 oldsize = inode->i_size; in fuse_change_attributes()
340 * attr->size coming from server can be stale. We cannot trust it. in fuse_change_attributes()
343 i_size_write(inode, attr->size); in fuse_change_attributes()
344 spin_unlock(&fi->lock); in fuse_change_attributes()
346 if (!cache_mask && S_ISREG(inode->i_mode)) { in fuse_change_attributes()
349 if (oldsize != attr->size) { in fuse_change_attributes()
350 truncate_pagecache(inode, attr->size); in fuse_change_attributes()
351 if (!fc->explicit_inval_data) in fuse_change_attributes()
353 } else if (fc->auto_inval_data) { in fuse_change_attributes()
355 .tv_sec = attr->mtime, in fuse_change_attributes()
356 .tv_nsec = attr->mtimensec, in fuse_change_attributes()
368 invalidate_inode_pages2(inode->i_mapping); in fuse_change_attributes()
372 fuse_dax_dontcache(inode, attr->flags); in fuse_change_attributes()
378 sl->nodeid = nodeid; in fuse_init_submount_lookup()
379 refcount_set(&sl->count, 1); in fuse_init_submount_lookup()
385 inode->i_mode = attr->mode & S_IFMT; in fuse_init_inode()
386 inode->i_size = attr->size; in fuse_init_inode()
387 inode_set_mtime(inode, attr->mtime, attr->mtimensec); in fuse_init_inode()
388 inode_set_ctime(inode, attr->ctime, attr->ctimensec); in fuse_init_inode()
389 if (S_ISREG(inode->i_mode)) { in fuse_init_inode()
391 fuse_init_file_inode(inode, attr->flags); in fuse_init_inode()
392 } else if (S_ISDIR(inode->i_mode)) in fuse_init_inode()
394 else if (S_ISLNK(inode->i_mode)) in fuse_init_inode()
396 else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || in fuse_init_inode()
397 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { in fuse_init_inode()
399 init_special_inode(inode, inode->i_mode, in fuse_init_inode()
400 new_decode_dev(attr->rdev)); in fuse_init_inode()
407 if (!fc->posix_acl) in fuse_init_inode()
408 inode->i_acl = inode->i_default_acl = ACL_DONT_CACHE; in fuse_init_inode()
423 get_fuse_inode(inode)->nodeid = nodeid; in fuse_inode_set()
442 if (fc->auto_submounts && (attr->flags & FUSE_ATTR_SUBMOUNT) && in fuse_iget()
443 S_ISDIR(attr->mode)) { in fuse_iget()
452 fi->nodeid = nodeid; in fuse_iget()
453 fi->submount_lookup = fuse_alloc_submount_lookup(); in fuse_iget()
454 if (!fi->submount_lookup) { in fuse_iget()
458 /* Sets nlookup = 1 on fi->submount_lookup->nlookup */ in fuse_iget()
459 fuse_init_submount_lookup(fi->submount_lookup, nodeid); in fuse_iget()
460 inode->i_flags |= S_AUTOMOUNT; in fuse_iget()
469 if ((inode->i_state & I_NEW)) { in fuse_iget()
470 inode->i_flags |= S_NOATIME; in fuse_iget()
471 if (!fc->writeback_cache || !S_ISREG(attr->mode)) in fuse_iget()
472 inode->i_flags |= S_NOCMTIME; in fuse_iget()
473 inode->i_generation = generation; in fuse_iget()
479 if (inode != d_inode(sb->s_root)) { in fuse_iget()
486 spin_lock(&fi->lock); in fuse_iget()
487 fi->nlookup++; in fuse_iget()
488 spin_unlock(&fi->lock); in fuse_iget()
501 WARN_ON(!rwsem_is_locked(&fc->killsb)); in fuse_ilookup()
502 list_for_each_entry(fm_iter, &fc->mounts, fc_entry) { in fuse_ilookup()
503 if (!fm_iter->sb) in fuse_ilookup()
506 inode = ilookup5(fm_iter->sb, nodeid, fuse_inode_eq, &nodeid); in fuse_ilookup()
527 return -ENOENT; in fuse_reverse_inval_inode()
530 spin_lock(&fi->lock); in fuse_reverse_inval_inode()
531 fi->attr_version = atomic64_inc_return(&fc->attr_version); in fuse_reverse_inval_inode()
532 spin_unlock(&fi->lock); in fuse_reverse_inval_inode()
539 pg_end = -1; in fuse_reverse_inval_inode()
541 pg_end = (offset + len - 1) >> PAGE_SHIFT; in fuse_reverse_inval_inode()
542 invalidate_inode_pages2_range(inode->i_mapping, in fuse_reverse_inval_inode()
553 if (!get_fuse_conn(inode)->parallel_dirops) { in fuse_lock_inode()
554 mutex_lock(&get_fuse_inode(inode)->mutex); in fuse_lock_inode()
564 mutex_unlock(&get_fuse_inode(inode)->mutex); in fuse_unlock_inode()
571 if (fc->no_force_umount) in fuse_umount_begin()
576 // Only retire block-device-based superblocks. in fuse_umount_begin()
577 if (sb->s_bdev != NULL) in fuse_umount_begin()
583 if (fm->fc->conn_init) { in fuse_send_destroy()
595 stbuf->f_type = FUSE_SUPER_MAGIC; in convert_fuse_statfs()
596 stbuf->f_bsize = attr->bsize; in convert_fuse_statfs()
597 stbuf->f_frsize = attr->frsize; in convert_fuse_statfs()
598 stbuf->f_blocks = attr->blocks; in convert_fuse_statfs()
599 stbuf->f_bfree = attr->bfree; in convert_fuse_statfs()
600 stbuf->f_bavail = attr->bavail; in convert_fuse_statfs()
601 stbuf->f_files = attr->files; in convert_fuse_statfs()
602 stbuf->f_ffree = attr->ffree; in convert_fuse_statfs()
603 stbuf->f_namelen = attr->namelen; in convert_fuse_statfs()
609 struct super_block *sb = dentry->d_sb; in fuse_statfs()
615 if (!fuse_allow_current_process(fm->fc)) { in fuse_statfs()
616 buf->f_type = FUSE_SUPER_MAGIC; in fuse_statfs()
639 init_waitqueue_head(&bucket->waitq); in fuse_sync_bucket_alloc()
641 atomic_set(&bucket->count, 1); in fuse_sync_bucket_alloc()
652 spin_lock(&fc->lock); in fuse_sync_fs_writes()
653 bucket = rcu_dereference_protected(fc->curr_bucket, 1); in fuse_sync_fs_writes()
654 count = atomic_read(&bucket->count); in fuse_sync_fs_writes()
658 spin_unlock(&fc->lock); in fuse_sync_fs_writes()
667 atomic_inc(&new_bucket->count); in fuse_sync_fs_writes()
668 rcu_assign_pointer(fc->curr_bucket, new_bucket); in fuse_sync_fs_writes()
669 spin_unlock(&fc->lock); in fuse_sync_fs_writes()
675 atomic_dec(&bucket->count); in fuse_sync_fs_writes()
677 wait_event(bucket->waitq, atomic_read(&bucket->count) == 0); in fuse_sync_fs_writes()
687 struct fuse_conn *fc = fm->fc; in fuse_sync_fs()
700 if (!sb->s_root) in fuse_sync_fs()
703 if (!fc->sync_fs) in fuse_sync_fs()
713 args.nodeid = get_node_id(sb->s_root->d_inode); in fuse_sync_fs()
717 if (err == -ENOSYS) { in fuse_sync_fs()
718 fc->sync_fs = 0; in fuse_sync_fs()
756 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_parse_param()
761 if (fsc->purpose == FS_CONTEXT_FOR_RECONFIGURE) { in fuse_parse_param()
766 if (fsc->oldapi) in fuse_parse_param()
778 if (fsc->source) in fuse_parse_param()
780 fsc->source = param->string; in fuse_parse_param()
781 param->string = NULL; in fuse_parse_param()
785 if (ctx->subtype) in fuse_parse_param()
787 ctx->subtype = param->string; in fuse_parse_param()
788 param->string = NULL; in fuse_parse_param()
792 ctx->fd = result.uint_32; in fuse_parse_param()
793 ctx->fd_present = true; in fuse_parse_param()
799 ctx->rootmode = result.uint_32; in fuse_parse_param()
800 ctx->rootmode_present = true; in fuse_parse_param()
809 if (!kuid_has_mapping(fsc->user_ns, kuid)) in fuse_parse_param()
811 ctx->user_id = kuid; in fuse_parse_param()
812 ctx->user_id_present = true; in fuse_parse_param()
821 if (!kgid_has_mapping(fsc->user_ns, kgid)) in fuse_parse_param()
823 ctx->group_id = kgid; in fuse_parse_param()
824 ctx->group_id_present = true; in fuse_parse_param()
828 ctx->default_permissions = true; in fuse_parse_param()
832 ctx->allow_other = true; in fuse_parse_param()
836 ctx->max_read = result.uint_32; in fuse_parse_param()
840 if (!ctx->is_bdev) in fuse_parse_param()
842 ctx->blksize = result.uint_32; in fuse_parse_param()
846 return -EINVAL; in fuse_parse_param()
854 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_free_fsc()
857 kfree(ctx->subtype); in fuse_free_fsc()
864 struct super_block *sb = root->d_sb; in fuse_show_options()
867 if (fc->legacy_opts_show) { in fuse_show_options()
869 from_kuid_munged(fc->user_ns, fc->user_id)); in fuse_show_options()
871 from_kgid_munged(fc->user_ns, fc->group_id)); in fuse_show_options()
872 if (fc->default_permissions) in fuse_show_options()
874 if (fc->allow_other) in fuse_show_options()
876 if (fc->max_read != ~0) in fuse_show_options()
877 seq_printf(m, ",max_read=%u", fc->max_read); in fuse_show_options()
878 if (sb->s_bdev && sb->s_blocksize != FUSE_DEFAULT_BLKSIZE) in fuse_show_options()
879 seq_printf(m, ",blksize=%lu", sb->s_blocksize); in fuse_show_options()
882 if (fc->dax_mode == FUSE_DAX_ALWAYS) in fuse_show_options()
884 else if (fc->dax_mode == FUSE_DAX_NEVER) in fuse_show_options()
886 else if (fc->dax_mode == FUSE_DAX_INODE_USER) in fuse_show_options()
893 static void fuse_iqueue_init(struct fuse_iqueue *fiq, in fuse_iqueue_init() argument
897 memset(fiq, 0, sizeof(struct fuse_iqueue)); in fuse_iqueue_init()
898 spin_lock_init(&fiq->lock); in fuse_iqueue_init()
899 init_waitqueue_head(&fiq->waitq); in fuse_iqueue_init()
900 INIT_LIST_HEAD(&fiq->pending); in fuse_iqueue_init()
901 INIT_LIST_HEAD(&fiq->interrupts); in fuse_iqueue_init()
902 fiq->forget_list_tail = &fiq->forget_list_head; in fuse_iqueue_init()
903 fiq->connected = 1; in fuse_iqueue_init()
904 fiq->ops = ops; in fuse_iqueue_init()
905 fiq->priv = priv; in fuse_iqueue_init()
912 spin_lock_init(&fpq->lock); in fuse_pqueue_init()
914 INIT_LIST_HEAD(&fpq->processing[i]); in fuse_pqueue_init()
915 INIT_LIST_HEAD(&fpq->io); in fuse_pqueue_init()
916 fpq->connected = 1; in fuse_pqueue_init()
924 spin_lock_init(&fc->lock); in fuse_conn_init()
925 spin_lock_init(&fc->bg_lock); in fuse_conn_init()
926 init_rwsem(&fc->killsb); in fuse_conn_init()
927 refcount_set(&fc->count, 1); in fuse_conn_init()
928 atomic_set(&fc->dev_count, 1); in fuse_conn_init()
929 init_waitqueue_head(&fc->blocked_waitq); in fuse_conn_init()
930 fuse_iqueue_init(&fc->iq, fiq_ops, fiq_priv); in fuse_conn_init()
931 INIT_LIST_HEAD(&fc->bg_queue); in fuse_conn_init()
932 INIT_LIST_HEAD(&fc->entry); in fuse_conn_init()
933 INIT_LIST_HEAD(&fc->devices); in fuse_conn_init()
934 atomic_set(&fc->num_waiting, 0); in fuse_conn_init()
935 fc->max_background = FUSE_DEFAULT_MAX_BACKGROUND; in fuse_conn_init()
936 fc->congestion_threshold = FUSE_DEFAULT_CONGESTION_THRESHOLD; in fuse_conn_init()
937 atomic64_set(&fc->khctr, 0); in fuse_conn_init()
938 fc->polled_files = RB_ROOT; in fuse_conn_init()
939 fc->blocked = 0; in fuse_conn_init()
940 fc->initialized = 0; in fuse_conn_init()
941 fc->connected = 1; in fuse_conn_init()
942 atomic64_set(&fc->attr_version, 1); in fuse_conn_init()
943 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); in fuse_conn_init()
944 fc->pid_ns = get_pid_ns(task_active_pid_ns(current)); in fuse_conn_init()
945 fc->user_ns = get_user_ns(user_ns); in fuse_conn_init()
946 fc->max_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; in fuse_conn_init()
947 fc->max_pages_limit = FUSE_MAX_MAX_PAGES; in fuse_conn_init()
952 INIT_LIST_HEAD(&fc->mounts); in fuse_conn_init()
953 list_add(&fm->fc_entry, &fc->mounts); in fuse_conn_init()
954 fm->fc = fc; in fuse_conn_init()
962 put_user_ns(fc->user_ns); in delayed_release()
963 fc->release(fc); in delayed_release()
968 if (refcount_dec_and_test(&fc->count)) { in fuse_conn_put()
969 struct fuse_iqueue *fiq = &fc->iq; in fuse_conn_put() local
974 if (fiq->ops->release) in fuse_conn_put()
975 fiq->ops->release(fiq); in fuse_conn_put()
976 put_pid_ns(fc->pid_ns); in fuse_conn_put()
977 bucket = rcu_dereference_protected(fc->curr_bucket, 1); in fuse_conn_put()
979 WARN_ON(atomic_read(&bucket->count) != 1); in fuse_conn_put()
984 call_rcu(&fc->rcu, delayed_release); in fuse_conn_put()
991 refcount_inc(&fc->count); in fuse_conn_get()
1018 int err = -ESTALE; in fuse_get_dentry()
1020 if (handle->nodeid == 0) in fuse_get_dentry()
1023 inode = ilookup5(sb, handle->nodeid, fuse_inode_eq, &handle->nodeid); in fuse_get_dentry()
1028 if (!fc->export_support) in fuse_get_dentry()
1031 err = fuse_lookup_name(sb, handle->nodeid, &name, &outarg, in fuse_get_dentry()
1033 if (err && err != -ENOENT) in fuse_get_dentry()
1036 err = -ESTALE; in fuse_get_dentry()
1039 err = -EIO; in fuse_get_dentry()
1040 if (get_node_id(inode) != handle->nodeid) in fuse_get_dentry()
1043 err = -ESTALE; in fuse_get_dentry()
1044 if (inode->i_generation != handle->generation) in fuse_get_dentry()
1071 nodeid = get_fuse_inode(inode)->nodeid; in fuse_encode_fh()
1072 generation = inode->i_generation; in fuse_encode_fh()
1079 nodeid = get_fuse_inode(parent)->nodeid; in fuse_encode_fh()
1080 generation = parent->i_generation; in fuse_encode_fh()
1100 handle.nodeid = (u64) fid->raw[0] << 32; in fuse_fh_to_dentry()
1101 handle.nodeid |= (u64) fid->raw[1]; in fuse_fh_to_dentry()
1102 handle.generation = fid->raw[2]; in fuse_fh_to_dentry()
1114 parent.nodeid = (u64) fid->raw[3] << 32; in fuse_fh_to_parent()
1115 parent.nodeid |= (u64) fid->raw[4]; in fuse_fh_to_parent()
1116 parent.generation = fid->raw[5]; in fuse_fh_to_parent()
1129 if (!fc->export_support) in fuse_get_parent()
1130 return ERR_PTR(-ESTALE); in fuse_get_parent()
1132 err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode), in fuse_get_parent()
1135 if (err == -ENOENT) in fuse_get_parent()
1136 return ERR_PTR(-ESTALE); in fuse_get_parent()
1181 *limit = (1 << 16) - 1; in sanitize_global_limit()
1192 sanitize_global_limit((unsigned *)kp->arg); in set_global_limit()
1201 if (arg->minor < 13) in process_init_limits()
1207 spin_lock(&fc->bg_lock); in process_init_limits()
1208 if (arg->max_background) { in process_init_limits()
1209 fc->max_background = arg->max_background; in process_init_limits()
1211 if (!cap_sys_admin && fc->max_background > max_user_bgreq) in process_init_limits()
1212 fc->max_background = max_user_bgreq; in process_init_limits()
1214 if (arg->congestion_threshold) { in process_init_limits()
1215 fc->congestion_threshold = arg->congestion_threshold; in process_init_limits()
1218 fc->congestion_threshold > max_user_congthresh) in process_init_limits()
1219 fc->congestion_threshold = max_user_congthresh; in process_init_limits()
1221 spin_unlock(&fc->bg_lock); in process_init_limits()
1233 struct fuse_conn *fc = fm->fc; in process_init_reply()
1235 struct fuse_init_out *arg = &ia->out; in process_init_reply()
1238 if (error || arg->major != FUSE_KERNEL_VERSION) in process_init_reply()
1245 if (arg->minor >= 6) { in process_init_reply()
1246 u64 flags = arg->flags; in process_init_reply()
1249 flags |= (u64) arg->flags2 << 32; in process_init_reply()
1251 ra_pages = arg->max_readahead / PAGE_SIZE; in process_init_reply()
1253 fc->async_read = 1; in process_init_reply()
1255 fc->no_lock = 1; in process_init_reply()
1256 if (arg->minor >= 17) { in process_init_reply()
1258 fc->no_flock = 1; in process_init_reply()
1261 fc->no_flock = 1; in process_init_reply()
1264 fc->atomic_o_trunc = 1; in process_init_reply()
1265 if (arg->minor >= 9) { in process_init_reply()
1268 fc->export_support = 1; in process_init_reply()
1271 fc->big_writes = 1; in process_init_reply()
1273 fc->dont_mask = 1; in process_init_reply()
1275 fc->auto_inval_data = 1; in process_init_reply()
1277 fc->explicit_inval_data = 1; in process_init_reply()
1279 fc->do_readdirplus = 1; in process_init_reply()
1281 fc->readdirplus_auto = 1; in process_init_reply()
1284 fc->async_dio = 1; in process_init_reply()
1286 fc->writeback_cache = 1; in process_init_reply()
1288 fc->parallel_dirops = 1; in process_init_reply()
1290 fc->handle_killpriv = 1; in process_init_reply()
1291 if (arg->time_gran && arg->time_gran <= 1000000000) in process_init_reply()
1292 fm->sb->s_time_gran = arg->time_gran; in process_init_reply()
1294 fc->default_permissions = 1; in process_init_reply()
1295 fc->posix_acl = 1; in process_init_reply()
1298 fc->cache_symlinks = 1; in process_init_reply()
1300 fc->abort_err = 1; in process_init_reply()
1302 fc->max_pages = in process_init_reply()
1303 min_t(unsigned int, fc->max_pages_limit, in process_init_reply()
1304 max_t(unsigned int, arg->max_pages, 1)); in process_init_reply()
1308 !fuse_dax_check_alignment(fc, arg->map_alignment)) { in process_init_reply()
1312 fc->inode_dax = 1; in process_init_reply()
1315 fc->handle_killpriv_v2 = 1; in process_init_reply()
1316 fm->sb->s_flags |= SB_NOSEC; in process_init_reply()
1319 fc->setxattr_ext = 1; in process_init_reply()
1321 fc->init_security = 1; in process_init_reply()
1323 fc->create_supp_group = 1; in process_init_reply()
1325 fc->direct_io_allow_mmap = 1; in process_init_reply()
1342 arg->max_stack_depth > 0 && in process_init_reply()
1343 arg->max_stack_depth <= FILESYSTEM_MAX_STACK_DEPTH && in process_init_reply()
1345 fc->passthrough = 1; in process_init_reply()
1346 fc->max_stack_depth = arg->max_stack_depth; in process_init_reply()
1347 fm->sb->s_stack_depth = arg->max_stack_depth; in process_init_reply()
1350 fm->sb->s_export_op = &fuse_export_fid_operations; in process_init_reply()
1352 if (fc->default_permissions) in process_init_reply()
1353 fm->sb->s_iflags &= ~SB_I_NOIDMAP; in process_init_reply()
1358 ra_pages = fc->max_read / PAGE_SIZE; in process_init_reply()
1359 fc->no_lock = 1; in process_init_reply()
1360 fc->no_flock = 1; in process_init_reply()
1363 fm->sb->s_bdi->ra_pages = in process_init_reply()
1364 min(fm->sb->s_bdi->ra_pages, ra_pages); in process_init_reply()
1365 fc->minor = arg->minor; in process_init_reply()
1366 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; in process_init_reply()
1367 fc->max_write = max_t(unsigned, 4096, fc->max_write); in process_init_reply()
1368 fc->conn_init = 1; in process_init_reply()
1373 fc->conn_init = 0; in process_init_reply()
1374 fc->conn_error = 1; in process_init_reply()
1378 wake_up_all(&fc->blocked_waitq); in process_init_reply()
1388 ia->in.major = FUSE_KERNEL_VERSION; in fuse_send_init()
1389 ia->in.minor = FUSE_KERNEL_MINOR_VERSION; in fuse_send_init()
1390 ia->in.max_readahead = fm->sb->s_bdi->ra_pages * PAGE_SIZE; in fuse_send_init()
1406 if (fm->fc->dax) in fuse_send_init()
1408 if (fuse_is_inode_dax_mode(fm->fc->dax_mode)) in fuse_send_init()
1411 if (fm->fc->auto_submounts) in fuse_send_init()
1416 ia->in.flags = flags; in fuse_send_init()
1417 ia->in.flags2 = flags >> 32; in fuse_send_init()
1419 ia->args.opcode = FUSE_INIT; in fuse_send_init()
1420 ia->args.in_numargs = 1; in fuse_send_init()
1421 ia->args.in_args[0].size = sizeof(ia->in); in fuse_send_init()
1422 ia->args.in_args[0].value = &ia->in; in fuse_send_init()
1423 ia->args.out_numargs = 1; in fuse_send_init()
1427 ia->args.out_argvar = true; in fuse_send_init()
1428 ia->args.out_args[0].size = sizeof(ia->out); in fuse_send_init()
1429 ia->args.out_args[0].value = &ia->out; in fuse_send_init()
1430 ia->args.force = true; in fuse_send_init()
1431 ia->args.nocreds = true; in fuse_send_init()
1432 ia->args.end = process_init_reply; in fuse_send_init()
1434 if (fuse_simple_background(fm, &ia->args, GFP_KERNEL) != 0) in fuse_send_init()
1435 process_init_reply(fm, &ia->args, -ENOTCONN); in fuse_send_init()
1441 WARN_ON(!list_empty(&fc->devices)); in fuse_free_conn()
1451 if (sb->s_bdev) { in fuse_bdi_init()
1452 suffix = "-fuseblk"; in fuse_bdi_init()
1454 * sb->s_bdi points to blkdev's bdi however we want to redirect in fuse_bdi_init()
1457 bdi_put(sb->s_bdi); in fuse_bdi_init()
1458 sb->s_bdi = &noop_backing_dev_info; in fuse_bdi_init()
1460 err = super_setup_bdi_name(sb, "%u:%u%s", MAJOR(fc->dev), in fuse_bdi_init()
1461 MINOR(fc->dev), suffix); in fuse_bdi_init()
1466 sb->s_bdi->capabilities &= ~BDI_CAP_WRITEBACK_ACCT; in fuse_bdi_init()
1467 sb->s_bdi->capabilities |= BDI_CAP_STRICTLIMIT; in fuse_bdi_init()
1481 bdi_set_max_ratio(sb->s_bdi, 1); in fuse_bdi_init()
1501 fud->pq.processing = pq; in fuse_dev_alloc()
1502 fuse_pqueue_init(&fud->pq); in fuse_dev_alloc()
1510 fud->fc = fuse_conn_get(fc); in fuse_dev_install()
1511 spin_lock(&fc->lock); in fuse_dev_install()
1512 list_add_tail(&fud->entry, &fc->devices); in fuse_dev_install()
1513 spin_unlock(&fc->lock); in fuse_dev_install()
1532 struct fuse_conn *fc = fud->fc; in fuse_dev_free()
1535 spin_lock(&fc->lock); in fuse_dev_free()
1536 list_del(&fud->entry); in fuse_dev_free()
1537 spin_unlock(&fc->lock); in fuse_dev_free()
1541 kfree(fud->pq.processing); in fuse_dev_free()
1549 struct timespec64 atime = inode_get_atime(&fi->inode); in fuse_fill_attr_from_inode()
1550 struct timespec64 mtime = inode_get_mtime(&fi->inode); in fuse_fill_attr_from_inode()
1551 struct timespec64 ctime = inode_get_ctime(&fi->inode); in fuse_fill_attr_from_inode()
1554 .ino = fi->inode.i_ino, in fuse_fill_attr_from_inode()
1555 .size = fi->inode.i_size, in fuse_fill_attr_from_inode()
1556 .blocks = fi->inode.i_blocks, in fuse_fill_attr_from_inode()
1563 .mode = fi->inode.i_mode, in fuse_fill_attr_from_inode()
1564 .nlink = fi->inode.i_nlink, in fuse_fill_attr_from_inode()
1565 .uid = __kuid_val(fi->inode.i_uid), in fuse_fill_attr_from_inode()
1566 .gid = __kgid_val(fi->inode.i_gid), in fuse_fill_attr_from_inode()
1567 .rdev = fi->inode.i_rdev, in fuse_fill_attr_from_inode()
1568 .blksize = 1u << fi->inode.i_blkbits, in fuse_fill_attr_from_inode()
1574 sb->s_magic = FUSE_SUPER_MAGIC; in fuse_sb_defaults()
1575 sb->s_op = &fuse_super_operations; in fuse_sb_defaults()
1576 sb->s_xattr = fuse_xattr_handlers; in fuse_sb_defaults()
1577 sb->s_maxbytes = MAX_LFS_FILESIZE; in fuse_sb_defaults()
1578 sb->s_time_gran = 1; in fuse_sb_defaults()
1579 sb->s_export_op = &fuse_export_operations; in fuse_sb_defaults()
1580 sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE; in fuse_sb_defaults()
1581 sb->s_iflags |= SB_I_NOIDMAP; in fuse_sb_defaults()
1582 if (sb->s_user_ns != &init_user_ns) in fuse_sb_defaults()
1583 sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER; in fuse_sb_defaults()
1584 sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION); in fuse_sb_defaults()
1591 struct super_block *parent_sb = parent_fi->inode.i_sb; in fuse_fill_super_submount()
1598 fm->sb = sb; in fuse_fill_super_submount()
1600 WARN_ON(sb->s_bdi != &noop_backing_dev_info); in fuse_fill_super_submount()
1601 sb->s_bdi = bdi_get(parent_sb->s_bdi); in fuse_fill_super_submount()
1603 sb->s_xattr = parent_sb->s_xattr; in fuse_fill_super_submount()
1604 sb->s_export_op = parent_sb->s_export_op; in fuse_fill_super_submount()
1605 sb->s_time_gran = parent_sb->s_time_gran; in fuse_fill_super_submount()
1606 sb->s_blocksize = parent_sb->s_blocksize; in fuse_fill_super_submount()
1607 sb->s_blocksize_bits = parent_sb->s_blocksize_bits; in fuse_fill_super_submount()
1608 sb->s_subtype = kstrdup(parent_sb->s_subtype, GFP_KERNEL); in fuse_fill_super_submount()
1609 if (parent_sb->s_subtype && !sb->s_subtype) in fuse_fill_super_submount()
1610 return -ENOMEM; in fuse_fill_super_submount()
1613 root = fuse_iget(sb, parent_fi->nodeid, 0, &root_attr, 0, 0); in fuse_fill_super_submount()
1620 fi->nlookup--; in fuse_fill_super_submount()
1622 sb->s_d_op = &fuse_dentry_operations; in fuse_fill_super_submount()
1623 sb->s_root = d_make_root(root); in fuse_fill_super_submount()
1624 if (!sb->s_root) in fuse_fill_super_submount()
1625 return -ENOMEM; in fuse_fill_super_submount()
1633 sl = parent_fi->submount_lookup; in fuse_fill_super_submount()
1636 refcount_inc(&sl->count); in fuse_fill_super_submount()
1637 fi->submount_lookup = sl; in fuse_fill_super_submount()
1647 struct fuse_inode *mp_fi = fsc->fs_private; in fuse_get_tree_submount()
1648 struct fuse_conn *fc = get_fuse_conn(&mp_fi->inode); in fuse_get_tree_submount()
1654 return -ENOMEM; in fuse_get_tree_submount()
1656 fm->fc = fuse_conn_get(fc); in fuse_get_tree_submount()
1657 fsc->s_fs_info = fm; in fuse_get_tree_submount()
1659 if (fsc->s_fs_info) in fuse_get_tree_submount()
1671 down_write(&fc->killsb); in fuse_get_tree_submount()
1672 list_add_tail(&fm->fc_entry, &fc->mounts); in fuse_get_tree_submount()
1673 up_write(&fc->killsb); in fuse_get_tree_submount()
1675 sb->s_flags |= SB_ACTIVE; in fuse_get_tree_submount()
1676 fsc->root = dget(sb->s_root); in fuse_get_tree_submount()
1687 fsc->ops = &fuse_context_submount_ops; in fuse_init_fs_context_submount()
1696 struct fuse_conn *fc = fm->fc; in fuse_fill_super_common()
1701 err = -EINVAL; in fuse_fill_super_common()
1702 if (sb->s_flags & SB_MANDLOCK) in fuse_fill_super_common()
1705 rcu_assign_pointer(fc->curr_bucket, fuse_sync_bucket_alloc()); in fuse_fill_super_common()
1708 if (ctx->is_bdev) { in fuse_fill_super_common()
1710 err = -EINVAL; in fuse_fill_super_common()
1711 if (!sb_set_blocksize(sb, ctx->blksize)) in fuse_fill_super_common()
1715 sb->s_blocksize = PAGE_SIZE; in fuse_fill_super_common()
1716 sb->s_blocksize_bits = PAGE_SHIFT; in fuse_fill_super_common()
1719 sb->s_subtype = ctx->subtype; in fuse_fill_super_common()
1720 ctx->subtype = NULL; in fuse_fill_super_common()
1722 err = fuse_dax_conn_alloc(fc, ctx->dax_mode, ctx->dax_dev); in fuse_fill_super_common()
1727 if (ctx->fudptr) { in fuse_fill_super_common()
1728 err = -ENOMEM; in fuse_fill_super_common()
1734 fc->dev = sb->s_dev; in fuse_fill_super_common()
1735 fm->sb = sb; in fuse_fill_super_common()
1741 if (sb->s_flags & SB_POSIXACL) in fuse_fill_super_common()
1742 fc->dont_mask = 1; in fuse_fill_super_common()
1743 sb->s_flags |= SB_POSIXACL; in fuse_fill_super_common()
1745 fc->default_permissions = ctx->default_permissions; in fuse_fill_super_common()
1746 fc->allow_other = ctx->allow_other; in fuse_fill_super_common()
1747 fc->user_id = ctx->user_id; in fuse_fill_super_common()
1748 fc->group_id = ctx->group_id; in fuse_fill_super_common()
1749 fc->legacy_opts_show = ctx->legacy_opts_show; in fuse_fill_super_common()
1750 fc->max_read = max_t(unsigned int, 4096, ctx->max_read); in fuse_fill_super_common()
1751 fc->destroy = ctx->destroy; in fuse_fill_super_common()
1752 fc->no_control = ctx->no_control; in fuse_fill_super_common()
1753 fc->no_force_umount = ctx->no_force_umount; in fuse_fill_super_common()
1755 err = -ENOMEM; in fuse_fill_super_common()
1756 root = fuse_get_root_inode(sb, ctx->rootmode); in fuse_fill_super_common()
1757 sb->s_d_op = &fuse_root_dentry_operations; in fuse_fill_super_common()
1762 sb->s_d_op = &fuse_dentry_operations; in fuse_fill_super_common()
1765 err = -EINVAL; in fuse_fill_super_common()
1766 if (ctx->fudptr && *ctx->fudptr) in fuse_fill_super_common()
1773 list_add_tail(&fc->entry, &fuse_conn_list); in fuse_fill_super_common()
1774 sb->s_root = root_dentry; in fuse_fill_super_common()
1775 if (ctx->fudptr) in fuse_fill_super_common()
1776 *ctx->fudptr = fud; in fuse_fill_super_common()
1796 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_fill_super()
1799 if (!ctx->file || !ctx->rootmode_present || in fuse_fill_super()
1800 !ctx->user_id_present || !ctx->group_id_present) in fuse_fill_super()
1801 return -EINVAL; in fuse_fill_super()
1807 if ((ctx->file->f_op != &fuse_dev_operations) || in fuse_fill_super()
1808 (ctx->file->f_cred->user_ns != sb->s_user_ns)) in fuse_fill_super()
1809 return -EINVAL; in fuse_fill_super()
1810 ctx->fudptr = &ctx->file->private_data; in fuse_fill_super()
1815 /* file->private_data shall be visible on all CPUs after this */ in fuse_fill_super()
1827 return -ENOTCONN; in fuse_set_no_super()
1833 return fsc->sget_key == get_fuse_conn_super(sb); in fuse_test_super()
1838 struct fuse_fs_context *ctx = fsc->fs_private; in fuse_get_tree()
1847 return -ENOMEM; in fuse_get_tree()
1852 return -ENOMEM; in fuse_get_tree()
1855 fuse_conn_init(fc, fm, fsc->user_ns, &fuse_dev_fiq_ops, NULL); in fuse_get_tree()
1856 fc->release = fuse_free_conn; in fuse_get_tree()
1858 fsc->s_fs_info = fm; in fuse_get_tree()
1860 if (ctx->fd_present) in fuse_get_tree()
1861 ctx->file = fget(ctx->fd); in fuse_get_tree()
1863 if (IS_ENABLED(CONFIG_BLOCK) && ctx->is_bdev) { in fuse_get_tree()
1868 * While block dev mount can be initialized with a dummy device fd in fuse_get_tree()
1869 * (found by device name), normal fuse mounts can't in fuse_get_tree()
1871 err = -EINVAL; in fuse_get_tree()
1872 if (!ctx->file) in fuse_get_tree()
1879 fud = READ_ONCE(ctx->file->private_data); in fuse_get_tree()
1880 if (ctx->file->f_op == &fuse_dev_operations && fud) { in fuse_get_tree()
1881 fsc->sget_key = fud->fc; in fuse_get_tree()
1885 fsc->root = dget(sb->s_root); in fuse_get_tree()
1890 if (fsc->s_fs_info) in fuse_get_tree()
1892 if (ctx->file) in fuse_get_tree()
1893 fput(ctx->file); in fuse_get_tree()
1913 return -ENOMEM; in fuse_init_fs_context()
1915 ctx->max_read = ~0; in fuse_init_fs_context()
1916 ctx->blksize = FUSE_DEFAULT_BLKSIZE; in fuse_init_fs_context()
1917 ctx->legacy_opts_show = true; in fuse_init_fs_context()
1920 if (fsc->fs_type == &fuseblk_fs_type) { in fuse_init_fs_context()
1921 ctx->is_bdev = true; in fuse_init_fs_context()
1922 ctx->destroy = true; in fuse_init_fs_context()
1926 fsc->fs_private = ctx; in fuse_init_fs_context()
1927 fsc->ops = &fuse_context_ops; in fuse_init_fs_context()
1933 struct fuse_conn *fc = fm->fc; in fuse_mount_remove()
1936 down_write(&fc->killsb); in fuse_mount_remove()
1937 list_del_init(&fm->fc_entry); in fuse_mount_remove()
1938 if (list_empty(&fc->mounts)) in fuse_mount_remove()
1940 up_write(&fc->killsb); in fuse_mount_remove()
1948 struct fuse_conn *fc = fm->fc; in fuse_conn_destroy()
1950 if (fc->destroy) in fuse_conn_destroy()
1956 if (!list_empty(&fc->entry)) { in fuse_conn_destroy()
1958 list_del(&fc->entry); in fuse_conn_destroy()
1970 if (sb->s_root) { in fuse_sb_destroy()
1979 fuse_conn_put(fm->fc); in fuse_mount_destroy()
2054 err = -ENOMEM; in fuse_fs_init()
2097 err = -ENOMEM; in fuse_sysfs_init()