0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _FS_FUSE_I_H
0010 #define _FS_FUSE_I_H
0011
0012 #ifndef pr_fmt
0013 # define pr_fmt(fmt) "fuse: " fmt
0014 #endif
0015
0016 #include <linux/fuse.h>
0017 #include <linux/fs.h>
0018 #include <linux/mount.h>
0019 #include <linux/wait.h>
0020 #include <linux/list.h>
0021 #include <linux/spinlock.h>
0022 #include <linux/mm.h>
0023 #include <linux/backing-dev.h>
0024 #include <linux/mutex.h>
0025 #include <linux/rwsem.h>
0026 #include <linux/rbtree.h>
0027 #include <linux/poll.h>
0028 #include <linux/workqueue.h>
0029 #include <linux/kref.h>
0030 #include <linux/xattr.h>
0031 #include <linux/pid_namespace.h>
0032 #include <linux/refcount.h>
0033 #include <linux/user_namespace.h>
0034
0035
0036 #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
0037
0038
0039 #define FUSE_MAX_MAX_PAGES 256
0040
0041
0042 #define FUSE_NOWRITE INT_MIN
0043
0044
0045 #define FUSE_NAME_MAX 1024
0046
0047
0048 #define FUSE_CTL_NUM_DENTRIES 5
0049
0050
0051 extern struct list_head fuse_conn_list;
0052
0053
0054 extern struct mutex fuse_mutex;
0055
0056
0057 extern unsigned max_user_bgreq;
0058 extern unsigned max_user_congthresh;
0059
0060
0061 struct fuse_forget_link {
0062 struct fuse_forget_one forget_one;
0063 struct fuse_forget_link *next;
0064 };
0065
0066
0067 struct fuse_inode {
0068
0069 struct inode inode;
0070
0071
0072
0073 u64 nodeid;
0074
0075
0076 u64 nlookup;
0077
0078
0079 struct fuse_forget_link *forget;
0080
0081
0082 u64 i_time;
0083
0084
0085 u32 inval_mask;
0086
0087
0088
0089 umode_t orig_i_mode;
0090
0091
0092 u64 orig_ino;
0093
0094
0095 u64 attr_version;
0096
0097 union {
0098
0099 struct {
0100
0101 struct list_head write_files;
0102
0103
0104 struct list_head queued_writes;
0105
0106
0107
0108 int writectr;
0109
0110
0111 wait_queue_head_t page_waitq;
0112
0113
0114 struct rb_root writepages;
0115 };
0116
0117
0118 struct {
0119
0120 bool cached;
0121
0122
0123 loff_t size;
0124
0125
0126 loff_t pos;
0127
0128
0129 u64 version;
0130
0131
0132
0133 struct timespec64 mtime;
0134
0135
0136 u64 iversion;
0137
0138
0139 spinlock_t lock;
0140 } rdc;
0141 };
0142
0143
0144 unsigned long state;
0145
0146
0147 struct mutex mutex;
0148
0149
0150 spinlock_t lock;
0151
0152 #ifdef CONFIG_FUSE_DAX
0153
0154
0155
0156 struct fuse_inode_dax *dax;
0157 #endif
0158 };
0159
0160
0161 enum {
0162
0163 FUSE_I_ADVISE_RDPLUS,
0164
0165 FUSE_I_INIT_RDPLUS,
0166
0167 FUSE_I_SIZE_UNSTABLE,
0168
0169 FUSE_I_BAD,
0170 };
0171
0172 struct fuse_conn;
0173 struct fuse_mount;
0174 struct fuse_release_args;
0175
0176
0177 struct fuse_file {
0178
0179 struct fuse_mount *fm;
0180
0181
0182 struct fuse_release_args *release_args;
0183
0184
0185 u64 kh;
0186
0187
0188 u64 fh;
0189
0190
0191 u64 nodeid;
0192
0193
0194 refcount_t count;
0195
0196
0197 u32 open_flags;
0198
0199
0200 struct list_head write_entry;
0201
0202
0203 struct {
0204
0205
0206
0207
0208 struct mutex lock;
0209
0210
0211 loff_t pos;
0212
0213
0214 loff_t cache_off;
0215
0216
0217 u64 version;
0218
0219 } readdir;
0220
0221
0222 struct rb_node polled_node;
0223
0224
0225 wait_queue_head_t poll_wait;
0226
0227
0228 bool flock:1;
0229 };
0230
0231
0232 struct fuse_in_arg {
0233 unsigned size;
0234 const void *value;
0235 };
0236
0237
0238 struct fuse_arg {
0239 unsigned size;
0240 void *value;
0241 };
0242
0243
0244 struct fuse_page_desc {
0245 unsigned int length;
0246 unsigned int offset;
0247 };
0248
0249 struct fuse_args {
0250 uint64_t nodeid;
0251 uint32_t opcode;
0252 unsigned short in_numargs;
0253 unsigned short out_numargs;
0254 bool force:1;
0255 bool noreply:1;
0256 bool nocreds:1;
0257 bool in_pages:1;
0258 bool out_pages:1;
0259 bool user_pages:1;
0260 bool out_argvar:1;
0261 bool page_zeroing:1;
0262 bool page_replace:1;
0263 bool may_block:1;
0264 struct fuse_in_arg in_args[3];
0265 struct fuse_arg out_args[2];
0266 void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error);
0267 };
0268
0269 struct fuse_args_pages {
0270 struct fuse_args args;
0271 struct page **pages;
0272 struct fuse_page_desc *descs;
0273 unsigned int num_pages;
0274 };
0275
0276 #define FUSE_ARGS(args) struct fuse_args args = {}
0277
0278
0279 struct fuse_io_priv {
0280 struct kref refcnt;
0281 int async;
0282 spinlock_t lock;
0283 unsigned reqs;
0284 ssize_t bytes;
0285 size_t size;
0286 __u64 offset;
0287 bool write;
0288 bool should_dirty;
0289 int err;
0290 struct kiocb *iocb;
0291 struct completion *done;
0292 bool blocking;
0293 };
0294
0295 #define FUSE_IO_PRIV_SYNC(i) \
0296 { \
0297 .refcnt = KREF_INIT(1), \
0298 .async = 0, \
0299 .iocb = i, \
0300 }
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318 enum fuse_req_flag {
0319 FR_ISREPLY,
0320 FR_FORCE,
0321 FR_BACKGROUND,
0322 FR_WAITING,
0323 FR_ABORTED,
0324 FR_INTERRUPTED,
0325 FR_LOCKED,
0326 FR_PENDING,
0327 FR_SENT,
0328 FR_FINISHED,
0329 FR_PRIVATE,
0330 FR_ASYNC,
0331 };
0332
0333
0334
0335
0336
0337
0338
0339
0340 struct fuse_req {
0341
0342
0343 struct list_head list;
0344
0345
0346 struct list_head intr_entry;
0347
0348
0349 struct fuse_args *args;
0350
0351
0352 refcount_t count;
0353
0354
0355 unsigned long flags;
0356
0357
0358 struct {
0359 struct fuse_in_header h;
0360 } in;
0361
0362
0363 struct {
0364 struct fuse_out_header h;
0365 } out;
0366
0367
0368 wait_queue_head_t waitq;
0369
0370 #if IS_ENABLED(CONFIG_VIRTIO_FS)
0371
0372 void *argbuf;
0373 #endif
0374
0375
0376 struct fuse_mount *fm;
0377 };
0378
0379 struct fuse_iqueue;
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389 struct fuse_iqueue_ops {
0390
0391
0392
0393 void (*wake_forget_and_unlock)(struct fuse_iqueue *fiq)
0394 __releases(fiq->lock);
0395
0396
0397
0398
0399 void (*wake_interrupt_and_unlock)(struct fuse_iqueue *fiq)
0400 __releases(fiq->lock);
0401
0402
0403
0404
0405 void (*wake_pending_and_unlock)(struct fuse_iqueue *fiq)
0406 __releases(fiq->lock);
0407
0408
0409
0410
0411 void (*release)(struct fuse_iqueue *fiq);
0412 };
0413
0414
0415 extern const struct fuse_iqueue_ops fuse_dev_fiq_ops;
0416
0417 struct fuse_iqueue {
0418
0419 unsigned connected;
0420
0421
0422 spinlock_t lock;
0423
0424
0425 wait_queue_head_t waitq;
0426
0427
0428 u64 reqctr;
0429
0430
0431 struct list_head pending;
0432
0433
0434 struct list_head interrupts;
0435
0436
0437 struct fuse_forget_link forget_list_head;
0438 struct fuse_forget_link *forget_list_tail;
0439
0440
0441 int forget_batch;
0442
0443
0444 struct fasync_struct *fasync;
0445
0446
0447 const struct fuse_iqueue_ops *ops;
0448
0449
0450 void *priv;
0451 };
0452
0453 #define FUSE_PQ_HASH_BITS 8
0454 #define FUSE_PQ_HASH_SIZE (1 << FUSE_PQ_HASH_BITS)
0455
0456 struct fuse_pqueue {
0457
0458 unsigned connected;
0459
0460
0461 spinlock_t lock;
0462
0463
0464 struct list_head *processing;
0465
0466
0467 struct list_head io;
0468 };
0469
0470
0471
0472
0473 struct fuse_dev {
0474
0475 struct fuse_conn *fc;
0476
0477
0478 struct fuse_pqueue pq;
0479
0480
0481 struct list_head entry;
0482 };
0483
0484 enum fuse_dax_mode {
0485 FUSE_DAX_INODE_DEFAULT,
0486 FUSE_DAX_ALWAYS,
0487 FUSE_DAX_NEVER,
0488 FUSE_DAX_INODE_USER,
0489 };
0490
0491 static inline bool fuse_is_inode_dax_mode(enum fuse_dax_mode mode)
0492 {
0493 return mode == FUSE_DAX_INODE_DEFAULT || mode == FUSE_DAX_INODE_USER;
0494 }
0495
0496 struct fuse_fs_context {
0497 int fd;
0498 struct file *file;
0499 unsigned int rootmode;
0500 kuid_t user_id;
0501 kgid_t group_id;
0502 bool is_bdev:1;
0503 bool fd_present:1;
0504 bool rootmode_present:1;
0505 bool user_id_present:1;
0506 bool group_id_present:1;
0507 bool default_permissions:1;
0508 bool allow_other:1;
0509 bool destroy:1;
0510 bool no_control:1;
0511 bool no_force_umount:1;
0512 bool legacy_opts_show:1;
0513 enum fuse_dax_mode dax_mode;
0514 unsigned int max_read;
0515 unsigned int blksize;
0516 const char *subtype;
0517
0518
0519 struct dax_device *dax_dev;
0520
0521
0522 void **fudptr;
0523 };
0524
0525 struct fuse_sync_bucket {
0526
0527 atomic_t count;
0528 wait_queue_head_t waitq;
0529 struct rcu_head rcu;
0530 };
0531
0532
0533
0534
0535
0536
0537
0538
0539 struct fuse_conn {
0540
0541 spinlock_t lock;
0542
0543
0544 refcount_t count;
0545
0546
0547 atomic_t dev_count;
0548
0549 struct rcu_head rcu;
0550
0551
0552 kuid_t user_id;
0553
0554
0555 kgid_t group_id;
0556
0557
0558 struct pid_namespace *pid_ns;
0559
0560
0561 struct user_namespace *user_ns;
0562
0563
0564 unsigned max_read;
0565
0566
0567 unsigned max_write;
0568
0569
0570 unsigned int max_pages;
0571
0572
0573 unsigned int max_pages_limit;
0574
0575
0576 struct fuse_iqueue iq;
0577
0578
0579 atomic64_t khctr;
0580
0581
0582 struct rb_root polled_files;
0583
0584
0585 unsigned max_background;
0586
0587
0588 unsigned congestion_threshold;
0589
0590
0591 unsigned num_background;
0592
0593
0594 unsigned active_background;
0595
0596
0597 struct list_head bg_queue;
0598
0599
0600
0601 spinlock_t bg_lock;
0602
0603
0604
0605 int initialized;
0606
0607
0608
0609
0610 int blocked;
0611
0612
0613 wait_queue_head_t blocked_waitq;
0614
0615
0616
0617 unsigned connected;
0618
0619
0620 bool aborted;
0621
0622
0623
0624
0625 unsigned conn_error:1;
0626
0627
0628 unsigned conn_init:1;
0629
0630
0631 unsigned async_read:1;
0632
0633
0634 unsigned abort_err:1;
0635
0636
0637 unsigned atomic_o_trunc:1;
0638
0639
0640 unsigned export_support:1;
0641
0642
0643 unsigned writeback_cache:1;
0644
0645
0646 unsigned parallel_dirops:1;
0647
0648
0649 unsigned handle_killpriv:1;
0650
0651
0652 unsigned cache_symlinks:1;
0653
0654
0655 unsigned int legacy_opts_show:1;
0656
0657
0658
0659
0660
0661
0662
0663 unsigned handle_killpriv_v2:1;
0664
0665
0666
0667
0668
0669
0670
0671 unsigned no_open:1;
0672
0673
0674 unsigned no_opendir:1;
0675
0676
0677 unsigned no_fsync:1;
0678
0679
0680 unsigned no_fsyncdir:1;
0681
0682
0683 unsigned no_flush:1;
0684
0685
0686 unsigned no_setxattr:1;
0687
0688
0689 unsigned setxattr_ext:1;
0690
0691
0692 unsigned no_getxattr:1;
0693
0694
0695 unsigned no_listxattr:1;
0696
0697
0698 unsigned no_removexattr:1;
0699
0700
0701 unsigned no_lock:1;
0702
0703
0704 unsigned no_access:1;
0705
0706
0707 unsigned no_create:1;
0708
0709
0710 unsigned no_interrupt:1;
0711
0712
0713 unsigned no_bmap:1;
0714
0715
0716 unsigned no_poll:1;
0717
0718
0719 unsigned big_writes:1;
0720
0721
0722 unsigned dont_mask:1;
0723
0724
0725 unsigned no_flock:1;
0726
0727
0728 unsigned no_fallocate:1;
0729
0730
0731 unsigned no_rename2:1;
0732
0733
0734 unsigned auto_inval_data:1;
0735
0736
0737 unsigned explicit_inval_data:1;
0738
0739
0740 unsigned do_readdirplus:1;
0741
0742
0743 unsigned readdirplus_auto:1;
0744
0745
0746 unsigned async_dio:1;
0747
0748
0749 unsigned no_lseek:1;
0750
0751
0752 unsigned posix_acl:1;
0753
0754
0755 unsigned default_permissions:1;
0756
0757
0758 unsigned allow_other:1;
0759
0760
0761 unsigned no_copy_file_range:1;
0762
0763
0764 unsigned int destroy:1;
0765
0766
0767 unsigned int delete_stale:1;
0768
0769
0770 unsigned int no_control:1;
0771
0772
0773 unsigned int no_force_umount:1;
0774
0775
0776 unsigned int auto_submounts:1;
0777
0778
0779 unsigned int sync_fs:1;
0780
0781
0782 unsigned int init_security:1;
0783
0784
0785 unsigned int inode_dax:1;
0786
0787
0788 atomic_t num_waiting;
0789
0790
0791 unsigned minor;
0792
0793
0794 struct list_head entry;
0795
0796
0797 dev_t dev;
0798
0799
0800 struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
0801
0802
0803 int ctl_ndents;
0804
0805
0806 u32 scramble_key[4];
0807
0808
0809 atomic64_t attr_version;
0810
0811
0812 void (*release)(struct fuse_conn *);
0813
0814
0815
0816
0817
0818 struct rw_semaphore killsb;
0819
0820
0821 struct list_head devices;
0822
0823 #ifdef CONFIG_FUSE_DAX
0824
0825 enum fuse_dax_mode dax_mode;
0826
0827
0828 struct fuse_conn_dax *dax;
0829 #endif
0830
0831
0832 struct list_head mounts;
0833
0834
0835 struct fuse_sync_bucket __rcu *curr_bucket;
0836 };
0837
0838
0839
0840
0841
0842
0843
0844
0845 struct fuse_mount {
0846
0847 struct fuse_conn *fc;
0848
0849
0850
0851
0852
0853 struct super_block *sb;
0854
0855
0856 struct list_head fc_entry;
0857 };
0858
0859 static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb)
0860 {
0861 return sb->s_fs_info;
0862 }
0863
0864 static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
0865 {
0866 return get_fuse_mount_super(sb)->fc;
0867 }
0868
0869 static inline struct fuse_mount *get_fuse_mount(struct inode *inode)
0870 {
0871 return get_fuse_mount_super(inode->i_sb);
0872 }
0873
0874 static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
0875 {
0876 return get_fuse_mount_super(inode->i_sb)->fc;
0877 }
0878
0879 static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
0880 {
0881 return container_of(inode, struct fuse_inode, inode);
0882 }
0883
0884 static inline u64 get_node_id(struct inode *inode)
0885 {
0886 return get_fuse_inode(inode)->nodeid;
0887 }
0888
0889 static inline int invalid_nodeid(u64 nodeid)
0890 {
0891 return !nodeid || nodeid == FUSE_ROOT_ID;
0892 }
0893
0894 static inline u64 fuse_get_attr_version(struct fuse_conn *fc)
0895 {
0896 return atomic64_read(&fc->attr_version);
0897 }
0898
0899 static inline bool fuse_stale_inode(const struct inode *inode, int generation,
0900 struct fuse_attr *attr)
0901 {
0902 return inode->i_generation != generation ||
0903 inode_wrong_type(inode, attr->mode);
0904 }
0905
0906 static inline void fuse_make_bad(struct inode *inode)
0907 {
0908 remove_inode_hash(inode);
0909 set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state);
0910 }
0911
0912 static inline bool fuse_is_bad(struct inode *inode)
0913 {
0914 return unlikely(test_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state));
0915 }
0916
0917 static inline struct page **fuse_pages_alloc(unsigned int npages, gfp_t flags,
0918 struct fuse_page_desc **desc)
0919 {
0920 struct page **pages;
0921
0922 pages = kzalloc(npages * (sizeof(struct page *) +
0923 sizeof(struct fuse_page_desc)), flags);
0924 *desc = (void *) (pages + npages);
0925
0926 return pages;
0927 }
0928
0929 static inline void fuse_page_descs_length_init(struct fuse_page_desc *descs,
0930 unsigned int index,
0931 unsigned int nr_pages)
0932 {
0933 int i;
0934
0935 for (i = index; i < index + nr_pages; i++)
0936 descs[i].length = PAGE_SIZE - descs[i].offset;
0937 }
0938
0939 static inline void fuse_sync_bucket_dec(struct fuse_sync_bucket *bucket)
0940 {
0941
0942 rcu_read_lock();
0943 if (atomic_dec_and_test(&bucket->count))
0944 wake_up(&bucket->waitq);
0945 rcu_read_unlock();
0946 }
0947
0948
0949 extern const struct file_operations fuse_dev_operations;
0950
0951 extern const struct dentry_operations fuse_dentry_operations;
0952 extern const struct dentry_operations fuse_root_dentry_operations;
0953
0954
0955
0956
0957 struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
0958 int generation, struct fuse_attr *attr,
0959 u64 attr_valid, u64 attr_version);
0960
0961 int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
0962 struct fuse_entry_out *outarg, struct inode **inode);
0963
0964
0965
0966
0967 void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
0968 u64 nodeid, u64 nlookup);
0969
0970 struct fuse_forget_link *fuse_alloc_forget(void);
0971
0972 struct fuse_forget_link *fuse_dequeue_forget(struct fuse_iqueue *fiq,
0973 unsigned int max,
0974 unsigned int *countp);
0975
0976
0977
0978
0979 struct fuse_io_args {
0980 union {
0981 struct {
0982 struct fuse_read_in in;
0983 u64 attr_ver;
0984 } read;
0985 struct {
0986 struct fuse_write_in in;
0987 struct fuse_write_out out;
0988 bool page_locked;
0989 } write;
0990 };
0991 struct fuse_args_pages ap;
0992 struct fuse_io_priv *io;
0993 struct fuse_file *ff;
0994 };
0995
0996 void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
0997 size_t count, int opcode);
0998
0999
1000
1001
1002
1003 int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
1004
1005 struct fuse_file *fuse_file_alloc(struct fuse_mount *fm);
1006 void fuse_file_free(struct fuse_file *ff);
1007 void fuse_finish_open(struct inode *inode, struct file *file);
1008
1009 void fuse_sync_release(struct fuse_inode *fi, struct fuse_file *ff,
1010 unsigned int flags);
1011
1012
1013
1014
1015 void fuse_release_common(struct file *file, bool isdir);
1016
1017
1018
1019
1020 int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
1021 int datasync, int opcode);
1022
1023
1024
1025
1026 int fuse_notify_poll_wakeup(struct fuse_conn *fc,
1027 struct fuse_notify_poll_wakeup_out *outarg);
1028
1029
1030
1031
1032 void fuse_init_file_inode(struct inode *inode, unsigned int flags);
1033
1034
1035
1036
1037 void fuse_init_common(struct inode *inode);
1038
1039
1040
1041
1042 void fuse_init_dir(struct inode *inode);
1043
1044
1045
1046
1047 void fuse_init_symlink(struct inode *inode);
1048
1049
1050
1051
1052 void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
1053 u64 attr_valid, u64 attr_version);
1054
1055 void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
1056 u64 attr_valid, u32 cache_mask);
1057
1058 u32 fuse_get_cache_mask(struct inode *inode);
1059
1060
1061
1062
1063 int fuse_dev_init(void);
1064
1065
1066
1067
1068 void fuse_dev_cleanup(void);
1069
1070 int fuse_ctl_init(void);
1071 void __exit fuse_ctl_cleanup(void);
1072
1073
1074
1075
1076 ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args);
1077 int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args,
1078 gfp_t gfp_flags);
1079
1080
1081
1082
1083 void fuse_request_end(struct fuse_req *req);
1084
1085
1086 void fuse_abort_conn(struct fuse_conn *fc);
1087 void fuse_wait_aborted(struct fuse_conn *fc);
1088
1089
1090
1091
1092
1093
1094 #define FUSE_STATX_MODIFY (STATX_MTIME | STATX_CTIME | STATX_BLOCKS)
1095
1096
1097 #define FUSE_STATX_MODSIZE (FUSE_STATX_MODIFY | STATX_SIZE)
1098
1099 void fuse_invalidate_attr(struct inode *inode);
1100 void fuse_invalidate_attr_mask(struct inode *inode, u32 mask);
1101
1102 void fuse_invalidate_entry_cache(struct dentry *entry);
1103
1104 void fuse_invalidate_atime(struct inode *inode);
1105
1106 u64 entry_attr_timeout(struct fuse_entry_out *o);
1107 void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o);
1108
1109
1110
1111
1112 struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
1113
1114
1115
1116
1117 void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm,
1118 struct user_namespace *user_ns,
1119 const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv);
1120
1121
1122
1123
1124 void fuse_conn_put(struct fuse_conn *fc);
1125
1126 struct fuse_dev *fuse_dev_alloc_install(struct fuse_conn *fc);
1127 struct fuse_dev *fuse_dev_alloc(void);
1128 void fuse_dev_install(struct fuse_dev *fud, struct fuse_conn *fc);
1129 void fuse_dev_free(struct fuse_dev *fud);
1130 void fuse_send_init(struct fuse_mount *fm);
1131
1132
1133
1134
1135
1136
1137 int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx);
1138
1139
1140
1141
1142
1143
1144 bool fuse_mount_remove(struct fuse_mount *fm);
1145
1146
1147
1148
1149 int fuse_init_fs_context_submount(struct fs_context *fsc);
1150
1151
1152
1153
1154 void fuse_conn_destroy(struct fuse_mount *fm);
1155
1156
1157 void fuse_mount_destroy(struct fuse_mount *fm);
1158
1159
1160
1161
1162 int fuse_ctl_add_conn(struct fuse_conn *fc);
1163
1164
1165
1166
1167 void fuse_ctl_remove_conn(struct fuse_conn *fc);
1168
1169
1170
1171
1172 int fuse_valid_type(int m);
1173
1174 bool fuse_invalid_attr(struct fuse_attr *attr);
1175
1176
1177
1178
1179 int fuse_allow_current_process(struct fuse_conn *fc);
1180
1181 u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
1182
1183 void fuse_flush_time_update(struct inode *inode);
1184 void fuse_update_ctime(struct inode *inode);
1185
1186 int fuse_update_attributes(struct inode *inode, struct file *file, u32 mask);
1187
1188 void fuse_flush_writepages(struct inode *inode);
1189
1190 void fuse_set_nowrite(struct inode *inode);
1191 void fuse_release_nowrite(struct inode *inode);
1192
1193
1194
1195
1196
1197
1198
1199
1200 struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid,
1201 struct fuse_mount **fm);
1202
1203
1204
1205
1206 int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
1207 loff_t offset, loff_t len);
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219 int fuse_reverse_inval_entry(struct fuse_conn *fc, u64 parent_nodeid,
1220 u64 child_nodeid, struct qstr *name);
1221
1222 int fuse_do_open(struct fuse_mount *fm, u64 nodeid, struct file *file,
1223 bool isdir);
1224
1225
1226
1227
1228
1229
1230 #define FUSE_DIO_WRITE (1 << 0)
1231
1232
1233 #define FUSE_DIO_CUSE (1 << 1)
1234
1235 ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
1236 loff_t *ppos, int flags);
1237 long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
1238 unsigned int flags);
1239 long fuse_ioctl_common(struct file *file, unsigned int cmd,
1240 unsigned long arg, unsigned int flags);
1241 __poll_t fuse_file_poll(struct file *file, poll_table *wait);
1242 int fuse_dev_release(struct inode *inode, struct file *file);
1243
1244 bool fuse_write_update_attr(struct inode *inode, loff_t pos, ssize_t written);
1245
1246 int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
1247 int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
1248
1249 int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1250 struct file *file);
1251
1252 void fuse_set_initialized(struct fuse_conn *fc);
1253
1254 void fuse_unlock_inode(struct inode *inode, bool locked);
1255 bool fuse_lock_inode(struct inode *inode);
1256
1257 int fuse_setxattr(struct inode *inode, const char *name, const void *value,
1258 size_t size, int flags, unsigned int extra_flags);
1259 ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value,
1260 size_t size);
1261 ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
1262 int fuse_removexattr(struct inode *inode, const char *name);
1263 extern const struct xattr_handler *fuse_xattr_handlers[];
1264 extern const struct xattr_handler *fuse_acl_xattr_handlers[];
1265 extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
1266
1267 struct posix_acl;
1268 struct posix_acl *fuse_get_acl(struct inode *inode, int type, bool rcu);
1269 int fuse_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
1270 struct posix_acl *acl, int type);
1271
1272
1273 int fuse_readdir(struct file *file, struct dir_context *ctx);
1274
1275
1276
1277
1278 unsigned int fuse_len_args(unsigned int numargs, struct fuse_arg *args);
1279
1280
1281
1282
1283 u64 fuse_get_unique(struct fuse_iqueue *fiq);
1284 void fuse_free_conn(struct fuse_conn *fc);
1285
1286
1287
1288 #define FUSE_IS_DAX(inode) (IS_ENABLED(CONFIG_FUSE_DAX) && IS_DAX(inode))
1289
1290 ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to);
1291 ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from);
1292 int fuse_dax_mmap(struct file *file, struct vm_area_struct *vma);
1293 int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, u64 dmap_end);
1294 int fuse_dax_conn_alloc(struct fuse_conn *fc, enum fuse_dax_mode mode,
1295 struct dax_device *dax_dev);
1296 void fuse_dax_conn_free(struct fuse_conn *fc);
1297 bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi);
1298 void fuse_dax_inode_init(struct inode *inode, unsigned int flags);
1299 void fuse_dax_inode_cleanup(struct inode *inode);
1300 void fuse_dax_dontcache(struct inode *inode, unsigned int flags);
1301 bool fuse_dax_check_alignment(struct fuse_conn *fc, unsigned int map_alignment);
1302 void fuse_dax_cancel_work(struct fuse_conn *fc);
1303
1304
1305 long fuse_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1306 long fuse_file_compat_ioctl(struct file *file, unsigned int cmd,
1307 unsigned long arg);
1308 int fuse_fileattr_get(struct dentry *dentry, struct fileattr *fa);
1309 int fuse_fileattr_set(struct user_namespace *mnt_userns,
1310 struct dentry *dentry, struct fileattr *fa);
1311
1312
1313
1314 struct fuse_file *fuse_file_open(struct fuse_mount *fm, u64 nodeid,
1315 unsigned int open_flags, bool isdir);
1316 void fuse_file_release(struct inode *inode, struct fuse_file *ff,
1317 unsigned int open_flags, fl_owner_t id, bool isdir);
1318
1319 #endif