1d8a5ba45SMiklos Szeredi /* 2d8a5ba45SMiklos Szeredi FUSE: Filesystem in Userspace 31729a16cSMiklos Szeredi Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> 4d8a5ba45SMiklos Szeredi 5d8a5ba45SMiklos Szeredi This program can be distributed under the terms of the GNU GPL. 6d8a5ba45SMiklos Szeredi See the file COPYING. 7d8a5ba45SMiklos Szeredi */ 8d8a5ba45SMiklos Szeredi 929d434b3STejun Heo #ifndef _FS_FUSE_I_H 1029d434b3STejun Heo #define _FS_FUSE_I_H 1129d434b3STejun Heo 12d8a5ba45SMiklos Szeredi #include <linux/fuse.h> 13d8a5ba45SMiklos Szeredi #include <linux/fs.h> 1451eb01e7SMiklos Szeredi #include <linux/mount.h> 15d8a5ba45SMiklos Szeredi #include <linux/wait.h> 16d8a5ba45SMiklos Szeredi #include <linux/list.h> 17d8a5ba45SMiklos Szeredi #include <linux/spinlock.h> 18d8a5ba45SMiklos Szeredi #include <linux/mm.h> 19d8a5ba45SMiklos Szeredi #include <linux/backing-dev.h> 20bafa9654SMiklos Szeredi #include <linux/mutex.h> 213be5a52bSMiklos Szeredi #include <linux/rwsem.h> 2295668a69STejun Heo #include <linux/rbtree.h> 2395668a69STejun Heo #include <linux/poll.h> 245a18ec17SMiklos Szeredi #include <linux/workqueue.h> 25d8a5ba45SMiklos Szeredi 26334f485dSMiklos Szeredi /** Max number of pages that can be used in a single read request */ 27334f485dSMiklos Szeredi #define FUSE_MAX_PAGES_PER_REQ 32 28334f485dSMiklos Szeredi 293be5a52bSMiklos Szeredi /** Bias for fi->writectr, meaning new writepages must not be sent */ 303be5a52bSMiklos Szeredi #define FUSE_NOWRITE INT_MIN 313be5a52bSMiklos Szeredi 321d3d752bSMiklos Szeredi /** It could be as large as PATH_MAX, but would that have any uses? */ 331d3d752bSMiklos Szeredi #define FUSE_NAME_MAX 1024 341d3d752bSMiklos Szeredi 35bafa9654SMiklos Szeredi /** Number of dentries for each connection in the control filesystem */ 3679a9d994SCsaba Henk #define FUSE_CTL_NUM_DENTRIES 5 37bafa9654SMiklos Szeredi 381e9a4ed9SMiklos Szeredi /** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem 391e9a4ed9SMiklos Szeredi module will check permissions based on the file mode. Otherwise no 401e9a4ed9SMiklos Szeredi permission checking is done in the kernel */ 411e9a4ed9SMiklos Szeredi #define FUSE_DEFAULT_PERMISSIONS (1 << 0) 421e9a4ed9SMiklos Szeredi 431e9a4ed9SMiklos Szeredi /** If the FUSE_ALLOW_OTHER flag is given, then not only the user 441e9a4ed9SMiklos Szeredi doing the mount will be allowed to access the filesystem */ 451e9a4ed9SMiklos Szeredi #define FUSE_ALLOW_OTHER (1 << 1) 461e9a4ed9SMiklos Szeredi 474250c066SMaxim Patlasov /** Number of page pointers embedded in fuse_req */ 484250c066SMaxim Patlasov #define FUSE_REQ_INLINE_PAGES 1 494250c066SMaxim Patlasov 50bafa9654SMiklos Szeredi /** List of active connections */ 51bafa9654SMiklos Szeredi extern struct list_head fuse_conn_list; 52bafa9654SMiklos Szeredi 53bafa9654SMiklos Szeredi /** Global mutex protecting fuse_conn_list and the control filesystem */ 54bafa9654SMiklos Szeredi extern struct mutex fuse_mutex; 55413ef8cbSMiklos Szeredi 5679a9d994SCsaba Henk /** Module parameters */ 5779a9d994SCsaba Henk extern unsigned max_user_bgreq; 5879a9d994SCsaba Henk extern unsigned max_user_congthresh; 5979a9d994SCsaba Henk 6007e77dcaSMiklos Szeredi /* One forget request */ 6107e77dcaSMiklos Szeredi struct fuse_forget_link { 6202c048b9SMiklos Szeredi struct fuse_forget_one forget_one; 6307e77dcaSMiklos Szeredi struct fuse_forget_link *next; 6407e77dcaSMiklos Szeredi }; 6507e77dcaSMiklos Szeredi 66d8a5ba45SMiklos Szeredi /** FUSE inode */ 67d8a5ba45SMiklos Szeredi struct fuse_inode { 68d8a5ba45SMiklos Szeredi /** Inode data */ 69d8a5ba45SMiklos Szeredi struct inode inode; 70d8a5ba45SMiklos Szeredi 71d8a5ba45SMiklos Szeredi /** Unique ID, which identifies the inode between userspace 72d8a5ba45SMiklos Szeredi * and kernel */ 73d8a5ba45SMiklos Szeredi u64 nodeid; 74d8a5ba45SMiklos Szeredi 759e6268dbSMiklos Szeredi /** Number of lookups on this inode */ 769e6268dbSMiklos Szeredi u64 nlookup; 779e6268dbSMiklos Szeredi 78e5e5558eSMiklos Szeredi /** The request used for sending the FORGET message */ 7907e77dcaSMiklos Szeredi struct fuse_forget_link *forget; 80e5e5558eSMiklos Szeredi 81d8a5ba45SMiklos Szeredi /** Time in jiffies until the file attributes are valid */ 820a0898cfSMiklos Szeredi u64 i_time; 83ebc14c4dSMiklos Szeredi 84ebc14c4dSMiklos Szeredi /** The sticky bit in inode->i_mode may have been removed, so 85ebc14c4dSMiklos Szeredi preserve the original mode */ 86541af6a0SAl Viro umode_t orig_i_mode; 871fb69e78SMiklos Szeredi 8845c72cd7SPavel Shilovsky /** 64 bit inode number */ 8945c72cd7SPavel Shilovsky u64 orig_ino; 9045c72cd7SPavel Shilovsky 911fb69e78SMiklos Szeredi /** Version of last attribute change */ 921fb69e78SMiklos Szeredi u64 attr_version; 9393a8c3cdSMiklos Szeredi 9493a8c3cdSMiklos Szeredi /** Files usable in writepage. Protected by fc->lock */ 9593a8c3cdSMiklos Szeredi struct list_head write_files; 963be5a52bSMiklos Szeredi 973be5a52bSMiklos Szeredi /** Writepages pending on truncate or fsync */ 983be5a52bSMiklos Szeredi struct list_head queued_writes; 993be5a52bSMiklos Szeredi 1003be5a52bSMiklos Szeredi /** Number of sent writes, a negative bias (FUSE_NOWRITE) 1013be5a52bSMiklos Szeredi * means more writes are blocked */ 1023be5a52bSMiklos Szeredi int writectr; 1033be5a52bSMiklos Szeredi 1043be5a52bSMiklos Szeredi /** Waitq for writepage completion */ 1053be5a52bSMiklos Szeredi wait_queue_head_t page_waitq; 1063be5a52bSMiklos Szeredi 1073be5a52bSMiklos Szeredi /** List of writepage requestst (pending or sent) */ 1083be5a52bSMiklos Szeredi struct list_head writepages; 1094582a4abSFeng Shuo 1104582a4abSFeng Shuo /** Miscellaneous bits describing inode state */ 1114582a4abSFeng Shuo unsigned long state; 1124582a4abSFeng Shuo }; 1134582a4abSFeng Shuo 1144582a4abSFeng Shuo /** FUSE inode state bits */ 1154582a4abSFeng Shuo enum { 1164582a4abSFeng Shuo /** Advise readdirplus */ 1174582a4abSFeng Shuo FUSE_I_ADVISE_RDPLUS, 1186314efeeSMiklos Szeredi /** Initialized with readdirplus */ 1196314efeeSMiklos Szeredi FUSE_I_INIT_RDPLUS, 12006a7c3c2SMaxim Patlasov /** An operation changing file size is in progress */ 12106a7c3c2SMaxim Patlasov FUSE_I_SIZE_UNSTABLE, 122d8a5ba45SMiklos Szeredi }; 123d8a5ba45SMiklos Szeredi 124da5e4714SMiklos Szeredi struct fuse_conn; 125da5e4714SMiklos Szeredi 126b6aeadedSMiklos Szeredi /** FUSE specific file data */ 127b6aeadedSMiklos Szeredi struct fuse_file { 128da5e4714SMiklos Szeredi /** Fuse connection for this file */ 129da5e4714SMiklos Szeredi struct fuse_conn *fc; 130da5e4714SMiklos Szeredi 131b6aeadedSMiklos Szeredi /** Request reserved for flush and release */ 13233649c91SMiklos Szeredi struct fuse_req *reserved_req; 133b6aeadedSMiklos Szeredi 134acf99433STejun Heo /** Kernel file handle guaranteed to be unique */ 135acf99433STejun Heo u64 kh; 136acf99433STejun Heo 137b6aeadedSMiklos Szeredi /** File handle used by userspace */ 138b6aeadedSMiklos Szeredi u64 fh; 139c756e0a4SMiklos Szeredi 140da5e4714SMiklos Szeredi /** Node id of this file */ 141da5e4714SMiklos Szeredi u64 nodeid; 142da5e4714SMiklos Szeredi 143c756e0a4SMiklos Szeredi /** Refcount */ 144c756e0a4SMiklos Szeredi atomic_t count; 14593a8c3cdSMiklos Szeredi 146c7b7143cSMiklos Szeredi /** FOPEN_* flags returned by open */ 147c7b7143cSMiklos Szeredi u32 open_flags; 148c7b7143cSMiklos Szeredi 14993a8c3cdSMiklos Szeredi /** Entry on inode's write_files list */ 15093a8c3cdSMiklos Szeredi struct list_head write_entry; 15195668a69STejun Heo 15295668a69STejun Heo /** RB node to be linked on fuse_conn->polled_files */ 15395668a69STejun Heo struct rb_node polled_node; 15495668a69STejun Heo 15595668a69STejun Heo /** Wait queue head for poll */ 15695668a69STejun Heo wait_queue_head_t poll_wait; 15737fb3a30SMiklos Szeredi 15837fb3a30SMiklos Szeredi /** Has flock been performed on this file? */ 15937fb3a30SMiklos Szeredi bool flock:1; 160b6aeadedSMiklos Szeredi }; 161b6aeadedSMiklos Szeredi 162334f485dSMiklos Szeredi /** One input argument of a request */ 163334f485dSMiklos Szeredi struct fuse_in_arg { 164334f485dSMiklos Szeredi unsigned size; 165334f485dSMiklos Szeredi const void *value; 166334f485dSMiklos Szeredi }; 167334f485dSMiklos Szeredi 168334f485dSMiklos Szeredi /** The request input */ 169334f485dSMiklos Szeredi struct fuse_in { 170334f485dSMiklos Szeredi /** The request header */ 171334f485dSMiklos Szeredi struct fuse_in_header h; 172334f485dSMiklos Szeredi 173334f485dSMiklos Szeredi /** True if the data for the last argument is in req->pages */ 174334f485dSMiklos Szeredi unsigned argpages:1; 175334f485dSMiklos Szeredi 176334f485dSMiklos Szeredi /** Number of arguments */ 177334f485dSMiklos Szeredi unsigned numargs; 178334f485dSMiklos Szeredi 179334f485dSMiklos Szeredi /** Array of arguments */ 180334f485dSMiklos Szeredi struct fuse_in_arg args[3]; 181334f485dSMiklos Szeredi }; 182334f485dSMiklos Szeredi 183334f485dSMiklos Szeredi /** One output argument of a request */ 184334f485dSMiklos Szeredi struct fuse_arg { 185334f485dSMiklos Szeredi unsigned size; 186334f485dSMiklos Szeredi void *value; 187334f485dSMiklos Szeredi }; 188334f485dSMiklos Szeredi 189334f485dSMiklos Szeredi /** The request output */ 190334f485dSMiklos Szeredi struct fuse_out { 191334f485dSMiklos Szeredi /** Header returned from userspace */ 192334f485dSMiklos Szeredi struct fuse_out_header h; 193334f485dSMiklos Szeredi 194095da6cbSMiklos Szeredi /* 195095da6cbSMiklos Szeredi * The following bitfields are not changed during the request 196095da6cbSMiklos Szeredi * processing 197095da6cbSMiklos Szeredi */ 198095da6cbSMiklos Szeredi 199334f485dSMiklos Szeredi /** Last argument is variable length (can be shorter than 200334f485dSMiklos Szeredi arg->size) */ 201334f485dSMiklos Szeredi unsigned argvar:1; 202334f485dSMiklos Szeredi 203334f485dSMiklos Szeredi /** Last argument is a list of pages to copy data to */ 204334f485dSMiklos Szeredi unsigned argpages:1; 205334f485dSMiklos Szeredi 206334f485dSMiklos Szeredi /** Zero partially or not copied pages */ 207334f485dSMiklos Szeredi unsigned page_zeroing:1; 208334f485dSMiklos Szeredi 209ce534fb0SMiklos Szeredi /** Pages may be replaced with new ones */ 210ce534fb0SMiklos Szeredi unsigned page_replace:1; 211ce534fb0SMiklos Szeredi 212334f485dSMiklos Szeredi /** Number or arguments */ 213334f485dSMiklos Szeredi unsigned numargs; 214334f485dSMiklos Szeredi 215334f485dSMiklos Szeredi /** Array of arguments */ 216f704dcb5SMiklos Szeredi struct fuse_arg args[2]; 217334f485dSMiklos Szeredi }; 218334f485dSMiklos Szeredi 219b2430d75SMaxim Patlasov /** FUSE page descriptor */ 220b2430d75SMaxim Patlasov struct fuse_page_desc { 221b2430d75SMaxim Patlasov unsigned int length; 222b2430d75SMaxim Patlasov unsigned int offset; 223b2430d75SMaxim Patlasov }; 224b2430d75SMaxim Patlasov 2257078187aSMiklos Szeredi struct fuse_args { 2267078187aSMiklos Szeredi struct { 2277078187aSMiklos Szeredi struct { 2287078187aSMiklos Szeredi uint32_t opcode; 2297078187aSMiklos Szeredi uint64_t nodeid; 2307078187aSMiklos Szeredi } h; 2317078187aSMiklos Szeredi unsigned numargs; 2327078187aSMiklos Szeredi struct fuse_in_arg args[3]; 2337078187aSMiklos Szeredi 2347078187aSMiklos Szeredi } in; 2357078187aSMiklos Szeredi struct { 2367078187aSMiklos Szeredi unsigned argvar:1; 2377078187aSMiklos Szeredi unsigned numargs; 2387078187aSMiklos Szeredi struct fuse_arg args[2]; 2397078187aSMiklos Szeredi } out; 2407078187aSMiklos Szeredi }; 2417078187aSMiklos Szeredi 2427078187aSMiklos Szeredi #define FUSE_ARGS(args) struct fuse_args args = {} 2437078187aSMiklos Szeredi 24483cfd493SMiklos Szeredi /** The request state */ 24583cfd493SMiklos Szeredi enum fuse_req_state { 24683cfd493SMiklos Szeredi FUSE_REQ_INIT = 0, 24783cfd493SMiklos Szeredi FUSE_REQ_PENDING, 24883cfd493SMiklos Szeredi FUSE_REQ_READING, 24983cfd493SMiklos Szeredi FUSE_REQ_SENT, 250a4d27e75SMiklos Szeredi FUSE_REQ_WRITING, 25183cfd493SMiklos Szeredi FUSE_REQ_FINISHED 25283cfd493SMiklos Szeredi }; 25383cfd493SMiklos Szeredi 25401e9d11aSMaxim Patlasov /** The request IO state (for asynchronous processing) */ 25501e9d11aSMaxim Patlasov struct fuse_io_priv { 25601e9d11aSMaxim Patlasov int async; 25701e9d11aSMaxim Patlasov spinlock_t lock; 25801e9d11aSMaxim Patlasov unsigned reqs; 25901e9d11aSMaxim Patlasov ssize_t bytes; 26001e9d11aSMaxim Patlasov size_t size; 26101e9d11aSMaxim Patlasov __u64 offset; 26201e9d11aSMaxim Patlasov bool write; 26301e9d11aSMaxim Patlasov int err; 26401e9d11aSMaxim Patlasov struct kiocb *iocb; 26501e9d11aSMaxim Patlasov struct file *file; 266*9d5722b7SChristoph Hellwig struct completion *done; 26701e9d11aSMaxim Patlasov }; 26801e9d11aSMaxim Patlasov 269334f485dSMiklos Szeredi /** 270334f485dSMiklos Szeredi * A request to the client 271334f485dSMiklos Szeredi */ 272334f485dSMiklos Szeredi struct fuse_req { 273ce1d5a49SMiklos Szeredi /** This can be on either pending processing or io lists in 274ce1d5a49SMiklos Szeredi fuse_conn */ 275334f485dSMiklos Szeredi struct list_head list; 276334f485dSMiklos Szeredi 277a4d27e75SMiklos Szeredi /** Entry on the interrupts list */ 278a4d27e75SMiklos Szeredi struct list_head intr_entry; 279a4d27e75SMiklos Szeredi 280334f485dSMiklos Szeredi /** refcount */ 281334f485dSMiklos Szeredi atomic_t count; 282334f485dSMiklos Szeredi 283a4d27e75SMiklos Szeredi /** Unique ID for the interrupt request */ 284a4d27e75SMiklos Szeredi u64 intr_unique; 285a4d27e75SMiklos Szeredi 286095da6cbSMiklos Szeredi /* 287095da6cbSMiklos Szeredi * The following bitfields are either set once before the 288095da6cbSMiklos Szeredi * request is queued or setting/clearing them is protected by 289d7133114SMiklos Szeredi * fuse_conn->lock 290095da6cbSMiklos Szeredi */ 291095da6cbSMiklos Szeredi 292334f485dSMiklos Szeredi /** True if the request has reply */ 293334f485dSMiklos Szeredi unsigned isreply:1; 294334f485dSMiklos Szeredi 29551eb01e7SMiklos Szeredi /** Force sending of the request even if interrupted */ 29651eb01e7SMiklos Szeredi unsigned force:1; 29751eb01e7SMiklos Szeredi 298f9a2842eSMiklos Szeredi /** The request was aborted */ 299f9a2842eSMiklos Szeredi unsigned aborted:1; 300334f485dSMiklos Szeredi 301334f485dSMiklos Szeredi /** Request is sent in the background */ 302334f485dSMiklos Szeredi unsigned background:1; 303334f485dSMiklos Szeredi 304a4d27e75SMiklos Szeredi /** The request has been interrupted */ 305a4d27e75SMiklos Szeredi unsigned interrupted:1; 306a4d27e75SMiklos Szeredi 307334f485dSMiklos Szeredi /** Data is being copied to/from the request */ 308334f485dSMiklos Szeredi unsigned locked:1; 309334f485dSMiklos Szeredi 3109bc5dddaSMiklos Szeredi /** Request is counted as "waiting" */ 3119bc5dddaSMiklos Szeredi unsigned waiting:1; 3129bc5dddaSMiklos Szeredi 31383cfd493SMiklos Szeredi /** State of the request */ 31483cfd493SMiklos Szeredi enum fuse_req_state state; 315334f485dSMiklos Szeredi 316334f485dSMiklos Szeredi /** The request input */ 317334f485dSMiklos Szeredi struct fuse_in in; 318334f485dSMiklos Szeredi 319334f485dSMiklos Szeredi /** The request output */ 320334f485dSMiklos Szeredi struct fuse_out out; 321334f485dSMiklos Szeredi 322334f485dSMiklos Szeredi /** Used to wake up the task waiting for completion of request*/ 323334f485dSMiklos Szeredi wait_queue_head_t waitq; 324334f485dSMiklos Szeredi 325334f485dSMiklos Szeredi /** Data for asynchronous requests */ 326334f485dSMiklos Szeredi union { 327b57d4264SMiklos Szeredi struct { 328b57d4264SMiklos Szeredi struct fuse_release_in in; 329baebccbeSMiklos Szeredi struct inode *inode; 330b57d4264SMiklos Szeredi } release; 3313ec870d5SMiklos Szeredi struct fuse_init_in init_in; 3323ec870d5SMiklos Szeredi struct fuse_init_out init_out; 33308cbf542STejun Heo struct cuse_init_in cuse_init_in; 3345c5c5e51SMiklos Szeredi struct { 3355c5c5e51SMiklos Szeredi struct fuse_read_in in; 3365c5c5e51SMiklos Szeredi u64 attr_ver; 3375c5c5e51SMiklos Szeredi } read; 338b25e82e5SMiklos Szeredi struct { 339b25e82e5SMiklos Szeredi struct fuse_write_in in; 340b25e82e5SMiklos Szeredi struct fuse_write_out out; 3418b284dc4SMiklos Szeredi struct fuse_req *next; 342b25e82e5SMiklos Szeredi } write; 3432d45ba38SMiklos Szeredi struct fuse_notify_retrieve_in retrieve_in; 344334f485dSMiklos Szeredi } misc; 345334f485dSMiklos Szeredi 346334f485dSMiklos Szeredi /** page vector */ 3474250c066SMaxim Patlasov struct page **pages; 3484250c066SMaxim Patlasov 349b2430d75SMaxim Patlasov /** page-descriptor vector */ 350b2430d75SMaxim Patlasov struct fuse_page_desc *page_descs; 351b2430d75SMaxim Patlasov 3524250c066SMaxim Patlasov /** size of the 'pages' array */ 3534250c066SMaxim Patlasov unsigned max_pages; 3544250c066SMaxim Patlasov 3554250c066SMaxim Patlasov /** inline page vector */ 3564250c066SMaxim Patlasov struct page *inline_pages[FUSE_REQ_INLINE_PAGES]; 357334f485dSMiklos Szeredi 358b2430d75SMaxim Patlasov /** inline page-descriptor vector */ 359b2430d75SMaxim Patlasov struct fuse_page_desc inline_page_descs[FUSE_REQ_INLINE_PAGES]; 360b2430d75SMaxim Patlasov 361334f485dSMiklos Szeredi /** number of pages in vector */ 362334f485dSMiklos Szeredi unsigned num_pages; 363334f485dSMiklos Szeredi 364334f485dSMiklos Szeredi /** File used in the request (or NULL) */ 365c756e0a4SMiklos Szeredi struct fuse_file *ff; 36664c6d8edSMiklos Szeredi 3673be5a52bSMiklos Szeredi /** Inode used in the request or NULL */ 3683be5a52bSMiklos Szeredi struct inode *inode; 3693be5a52bSMiklos Szeredi 37001e9d11aSMaxim Patlasov /** AIO control block */ 37101e9d11aSMaxim Patlasov struct fuse_io_priv *io; 37201e9d11aSMaxim Patlasov 3733be5a52bSMiklos Szeredi /** Link on fi->writepages */ 3743be5a52bSMiklos Szeredi struct list_head writepages_entry; 3753be5a52bSMiklos Szeredi 37664c6d8edSMiklos Szeredi /** Request completion callback */ 37764c6d8edSMiklos Szeredi void (*end)(struct fuse_conn *, struct fuse_req *); 37833649c91SMiklos Szeredi 37933649c91SMiklos Szeredi /** Request is stolen from fuse_file->reserved_req */ 38033649c91SMiklos Szeredi struct file *stolen_file; 381334f485dSMiklos Szeredi }; 382334f485dSMiklos Szeredi 383d8a5ba45SMiklos Szeredi /** 384d8a5ba45SMiklos Szeredi * A Fuse connection. 385d8a5ba45SMiklos Szeredi * 386d8a5ba45SMiklos Szeredi * This structure is created, when the filesystem is mounted, and is 387d8a5ba45SMiklos Szeredi * destroyed, when the client device is closed and the filesystem is 388d8a5ba45SMiklos Szeredi * unmounted. 389d8a5ba45SMiklos Szeredi */ 390d8a5ba45SMiklos Szeredi struct fuse_conn { 391d7133114SMiklos Szeredi /** Lock protecting accessess to members of this structure */ 392d7133114SMiklos Szeredi spinlock_t lock; 393d7133114SMiklos Szeredi 394bafa9654SMiklos Szeredi /** Refcount */ 395bafa9654SMiklos Szeredi atomic_t count; 396bafa9654SMiklos Szeredi 397dd3e2c55SAl Viro struct rcu_head rcu; 398dd3e2c55SAl Viro 399d8a5ba45SMiklos Szeredi /** The user id for this mount */ 400499dcf20SEric W. Biederman kuid_t user_id; 401d8a5ba45SMiklos Szeredi 40287729a55SMiklos Szeredi /** The group id for this mount */ 403499dcf20SEric W. Biederman kgid_t group_id; 40487729a55SMiklos Szeredi 4051e9a4ed9SMiklos Szeredi /** The fuse mount flags for this mount */ 4061e9a4ed9SMiklos Szeredi unsigned flags; 4071e9a4ed9SMiklos Szeredi 408db50b96cSMiklos Szeredi /** Maximum read size */ 409db50b96cSMiklos Szeredi unsigned max_read; 410db50b96cSMiklos Szeredi 411413ef8cbSMiklos Szeredi /** Maximum write size */ 412413ef8cbSMiklos Szeredi unsigned max_write; 413413ef8cbSMiklos Szeredi 414334f485dSMiklos Szeredi /** Readers of the connection are waiting on this */ 415334f485dSMiklos Szeredi wait_queue_head_t waitq; 416334f485dSMiklos Szeredi 417334f485dSMiklos Szeredi /** The list of pending requests */ 418334f485dSMiklos Szeredi struct list_head pending; 419334f485dSMiklos Szeredi 420334f485dSMiklos Szeredi /** The list of requests being processed */ 421334f485dSMiklos Szeredi struct list_head processing; 422334f485dSMiklos Szeredi 423d77a1d5bSMiklos Szeredi /** The list of requests under I/O */ 424d77a1d5bSMiklos Szeredi struct list_head io; 425d77a1d5bSMiklos Szeredi 426acf99433STejun Heo /** The next unique kernel file handle */ 427acf99433STejun Heo u64 khctr; 428acf99433STejun Heo 42995668a69STejun Heo /** rbtree of fuse_files waiting for poll events indexed by ph */ 43095668a69STejun Heo struct rb_root polled_files; 43195668a69STejun Heo 4327a6d3c8bSCsaba Henk /** Maximum number of outstanding background requests */ 4337a6d3c8bSCsaba Henk unsigned max_background; 4347a6d3c8bSCsaba Henk 4357a6d3c8bSCsaba Henk /** Number of background requests at which congestion starts */ 4367a6d3c8bSCsaba Henk unsigned congestion_threshold; 4377a6d3c8bSCsaba Henk 43808a53cdcSMiklos Szeredi /** Number of requests currently in the background */ 43908a53cdcSMiklos Szeredi unsigned num_background; 44008a53cdcSMiklos Szeredi 441d12def1bSMiklos Szeredi /** Number of background requests currently queued for userspace */ 442d12def1bSMiklos Szeredi unsigned active_background; 443d12def1bSMiklos Szeredi 444d12def1bSMiklos Szeredi /** The list of background requests set aside for later queuing */ 445d12def1bSMiklos Szeredi struct list_head bg_queue; 446d12def1bSMiklos Szeredi 447a4d27e75SMiklos Szeredi /** Pending interrupts */ 448a4d27e75SMiklos Szeredi struct list_head interrupts; 449a4d27e75SMiklos Szeredi 45007e77dcaSMiklos Szeredi /** Queue of pending forgets */ 45107e77dcaSMiklos Szeredi struct fuse_forget_link forget_list_head; 45207e77dcaSMiklos Szeredi struct fuse_forget_link *forget_list_tail; 45307e77dcaSMiklos Szeredi 45407e77dcaSMiklos Szeredi /** Batching of FORGET requests (positive indicates FORGET batch) */ 45507e77dcaSMiklos Szeredi int forget_batch; 45607e77dcaSMiklos Szeredi 457796523fbSMaxim Patlasov /** Flag indicating that INIT reply has been received. Allocating 458796523fbSMaxim Patlasov * any fuse request will be suspended until the flag is set */ 459796523fbSMaxim Patlasov int initialized; 460796523fbSMaxim Patlasov 46108a53cdcSMiklos Szeredi /** Flag indicating if connection is blocked. This will be 46208a53cdcSMiklos Szeredi the case before the INIT reply is received, and if there 46308a53cdcSMiklos Szeredi are too many outstading backgrounds requests */ 46408a53cdcSMiklos Szeredi int blocked; 46508a53cdcSMiklos Szeredi 46608a53cdcSMiklos Szeredi /** waitq for blocked connection */ 46708a53cdcSMiklos Szeredi wait_queue_head_t blocked_waitq; 46808a53cdcSMiklos Szeredi 469de5e3decSMiklos Szeredi /** waitq for reserved requests */ 470de5e3decSMiklos Szeredi wait_queue_head_t reserved_req_waitq; 471de5e3decSMiklos Szeredi 472334f485dSMiklos Szeredi /** The next unique request id */ 473334f485dSMiklos Szeredi u64 reqctr; 474334f485dSMiklos Szeredi 47569a53bf2SMiklos Szeredi /** Connection established, cleared on umount, connection 47669a53bf2SMiklos Szeredi abort and device release */ 477095da6cbSMiklos Szeredi unsigned connected; 4781e9a4ed9SMiklos Szeredi 479095da6cbSMiklos Szeredi /** Connection failed (version mismatch). Cannot race with 480095da6cbSMiklos Szeredi setting other bitfields since it is only set once in INIT 481095da6cbSMiklos Szeredi reply, before any other request, and never cleared */ 482334f485dSMiklos Szeredi unsigned conn_error:1; 483334f485dSMiklos Szeredi 4840ec7ca41SMiklos Szeredi /** Connection successful. Only set in INIT */ 4850ec7ca41SMiklos Szeredi unsigned conn_init:1; 4860ec7ca41SMiklos Szeredi 4879cd68455SMiklos Szeredi /** Do readpages asynchronously? Only set in INIT */ 4889cd68455SMiklos Szeredi unsigned async_read:1; 4899cd68455SMiklos Szeredi 4906ff958edSMiklos Szeredi /** Do not send separate SETATTR request before open(O_TRUNC) */ 4916ff958edSMiklos Szeredi unsigned atomic_o_trunc:1; 4926ff958edSMiklos Szeredi 49333670fa2SMiklos Szeredi /** Filesystem supports NFS exporting. Only set in INIT */ 49433670fa2SMiklos Szeredi unsigned export_support:1; 49533670fa2SMiklos Szeredi 496a325f9b9STejun Heo /** Set if bdi is valid */ 497a325f9b9STejun Heo unsigned bdi_initialized:1; 498a325f9b9STejun Heo 499d5cd66c5SPavel Emelyanov /** write-back cache policy (default is write-through) */ 500d5cd66c5SPavel Emelyanov unsigned writeback_cache:1; 501d5cd66c5SPavel Emelyanov 502095da6cbSMiklos Szeredi /* 503095da6cbSMiklos Szeredi * The following bitfields are only for optimization purposes 504095da6cbSMiklos Szeredi * and hence races in setting them will not cause malfunction 505095da6cbSMiklos Szeredi */ 506095da6cbSMiklos Szeredi 5077678ac50SAndrew Gallagher /** Is open/release not implemented by fs? */ 5087678ac50SAndrew Gallagher unsigned no_open:1; 5097678ac50SAndrew Gallagher 510b6aeadedSMiklos Szeredi /** Is fsync not implemented by fs? */ 511b6aeadedSMiklos Szeredi unsigned no_fsync:1; 512b6aeadedSMiklos Szeredi 51382547981SMiklos Szeredi /** Is fsyncdir not implemented by fs? */ 51482547981SMiklos Szeredi unsigned no_fsyncdir:1; 51582547981SMiklos Szeredi 516b6aeadedSMiklos Szeredi /** Is flush not implemented by fs? */ 517b6aeadedSMiklos Szeredi unsigned no_flush:1; 518b6aeadedSMiklos Szeredi 51992a8780eSMiklos Szeredi /** Is setxattr not implemented by fs? */ 52092a8780eSMiklos Szeredi unsigned no_setxattr:1; 52192a8780eSMiklos Szeredi 52292a8780eSMiklos Szeredi /** Is getxattr not implemented by fs? */ 52392a8780eSMiklos Szeredi unsigned no_getxattr:1; 52492a8780eSMiklos Szeredi 52592a8780eSMiklos Szeredi /** Is listxattr not implemented by fs? */ 52692a8780eSMiklos Szeredi unsigned no_listxattr:1; 52792a8780eSMiklos Szeredi 52892a8780eSMiklos Szeredi /** Is removexattr not implemented by fs? */ 52992a8780eSMiklos Szeredi unsigned no_removexattr:1; 53092a8780eSMiklos Szeredi 53137fb3a30SMiklos Szeredi /** Are posix file locking primitives not implemented by fs? */ 53271421259SMiklos Szeredi unsigned no_lock:1; 53371421259SMiklos Szeredi 53431d40d74SMiklos Szeredi /** Is access not implemented by fs? */ 53531d40d74SMiklos Szeredi unsigned no_access:1; 53631d40d74SMiklos Szeredi 537fd72faacSMiklos Szeredi /** Is create not implemented by fs? */ 538fd72faacSMiklos Szeredi unsigned no_create:1; 539fd72faacSMiklos Szeredi 540a4d27e75SMiklos Szeredi /** Is interrupt not implemented by fs? */ 541a4d27e75SMiklos Szeredi unsigned no_interrupt:1; 542a4d27e75SMiklos Szeredi 543b2d2272fSMiklos Szeredi /** Is bmap not implemented by fs? */ 544b2d2272fSMiklos Szeredi unsigned no_bmap:1; 545b2d2272fSMiklos Szeredi 54695668a69STejun Heo /** Is poll not implemented by fs? */ 54795668a69STejun Heo unsigned no_poll:1; 54895668a69STejun Heo 54978bb6cb9SMiklos Szeredi /** Do multi-page cached writes */ 55078bb6cb9SMiklos Szeredi unsigned big_writes:1; 55178bb6cb9SMiklos Szeredi 552e0a43ddcSMiklos Szeredi /** Don't apply umask to creation modes */ 553e0a43ddcSMiklos Szeredi unsigned dont_mask:1; 554e0a43ddcSMiklos Szeredi 55537fb3a30SMiklos Szeredi /** Are BSD file locking primitives not implemented by fs? */ 55637fb3a30SMiklos Szeredi unsigned no_flock:1; 55737fb3a30SMiklos Szeredi 558519c6040SMiklos Szeredi /** Is fallocate not implemented by fs? */ 559519c6040SMiklos Szeredi unsigned no_fallocate:1; 560519c6040SMiklos Szeredi 5611560c974SMiklos Szeredi /** Is rename with flags implemented by fs? */ 5621560c974SMiklos Szeredi unsigned no_rename2:1; 5631560c974SMiklos Szeredi 56472d0d248SBrian Foster /** Use enhanced/automatic page cache invalidation. */ 56572d0d248SBrian Foster unsigned auto_inval_data:1; 56672d0d248SBrian Foster 567634734b6SEric Wong /** Does the filesystem support readdirplus? */ 5680b05b183SAnand V. Avati unsigned do_readdirplus:1; 5690b05b183SAnand V. Avati 570634734b6SEric Wong /** Does the filesystem want adaptive readdirplus? */ 571634734b6SEric Wong unsigned readdirplus_auto:1; 572634734b6SEric Wong 57360b9df7aSMiklos Szeredi /** Does the filesystem support asynchronous direct-IO submission? */ 57460b9df7aSMiklos Szeredi unsigned async_dio:1; 57560b9df7aSMiklos Szeredi 5760cd5b885SMiklos Szeredi /** The number of requests waiting for completion */ 5770cd5b885SMiklos Szeredi atomic_t num_waiting; 5780cd5b885SMiklos Szeredi 57945714d65SMiklos Szeredi /** Negotiated minor version */ 58045714d65SMiklos Szeredi unsigned minor; 58145714d65SMiklos Szeredi 582d8a5ba45SMiklos Szeredi /** Backing dev info */ 583d8a5ba45SMiklos Szeredi struct backing_dev_info bdi; 584f543f253SMiklos Szeredi 585bafa9654SMiklos Szeredi /** Entry on the fuse_conn_list */ 586bafa9654SMiklos Szeredi struct list_head entry; 587bafa9654SMiklos Szeredi 588b6f2fcbcSMiklos Szeredi /** Device ID from super block */ 589b6f2fcbcSMiklos Szeredi dev_t dev; 590bafa9654SMiklos Szeredi 591bafa9654SMiklos Szeredi /** Dentries in the control filesystem */ 592bafa9654SMiklos Szeredi struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; 593bafa9654SMiklos Szeredi 594bafa9654SMiklos Szeredi /** number of dentries used in the above array */ 595bafa9654SMiklos Szeredi int ctl_ndents; 596385a17bfSJeff Dike 597385a17bfSJeff Dike /** O_ASYNC requests */ 598385a17bfSJeff Dike struct fasync_struct *fasync; 5999c8ef561SMiklos Szeredi 6009c8ef561SMiklos Szeredi /** Key for lock owner ID scrambling */ 6019c8ef561SMiklos Szeredi u32 scramble_key[4]; 6020ec7ca41SMiklos Szeredi 6030ec7ca41SMiklos Szeredi /** Reserved request for the DESTROY message */ 6040ec7ca41SMiklos Szeredi struct fuse_req *destroy_req; 6051fb69e78SMiklos Szeredi 6061fb69e78SMiklos Szeredi /** Version counter for attribute changes */ 6071fb69e78SMiklos Szeredi u64 attr_version; 60843901aabSTejun Heo 60943901aabSTejun Heo /** Called on final put */ 61043901aabSTejun Heo void (*release)(struct fuse_conn *); 6113b463ae0SJohn Muir 6123b463ae0SJohn Muir /** Super block for this connection. */ 6133b463ae0SJohn Muir struct super_block *sb; 6143b463ae0SJohn Muir 6153b463ae0SJohn Muir /** Read/write semaphore to hold when accessing sb. */ 6163b463ae0SJohn Muir struct rw_semaphore killsb; 617d8a5ba45SMiklos Szeredi }; 618d8a5ba45SMiklos Szeredi 619d8a5ba45SMiklos Szeredi static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) 620d8a5ba45SMiklos Szeredi { 6216383bdaaSMiklos Szeredi return sb->s_fs_info; 622d8a5ba45SMiklos Szeredi } 623d8a5ba45SMiklos Szeredi 624d8a5ba45SMiklos Szeredi static inline struct fuse_conn *get_fuse_conn(struct inode *inode) 625d8a5ba45SMiklos Szeredi { 626d8a5ba45SMiklos Szeredi return get_fuse_conn_super(inode->i_sb); 627d8a5ba45SMiklos Szeredi } 628d8a5ba45SMiklos Szeredi 629d8a5ba45SMiklos Szeredi static inline struct fuse_inode *get_fuse_inode(struct inode *inode) 630d8a5ba45SMiklos Szeredi { 631d8a5ba45SMiklos Szeredi return container_of(inode, struct fuse_inode, inode); 632d8a5ba45SMiklos Szeredi } 633d8a5ba45SMiklos Szeredi 634d8a5ba45SMiklos Szeredi static inline u64 get_node_id(struct inode *inode) 635d8a5ba45SMiklos Szeredi { 636d8a5ba45SMiklos Szeredi return get_fuse_inode(inode)->nodeid; 637d8a5ba45SMiklos Szeredi } 638d8a5ba45SMiklos Szeredi 639334f485dSMiklos Szeredi /** Device operations */ 6404b6f5d20SArjan van de Ven extern const struct file_operations fuse_dev_operations; 641334f485dSMiklos Szeredi 6424269590aSAl Viro extern const struct dentry_operations fuse_dentry_operations; 643dbd561d2SMiklos Szeredi 644d8a5ba45SMiklos Szeredi /** 6453b463ae0SJohn Muir * Inode to nodeid comparison. 6463b463ae0SJohn Muir */ 6473b463ae0SJohn Muir int fuse_inode_eq(struct inode *inode, void *_nodeidp); 6483b463ae0SJohn Muir 6493b463ae0SJohn Muir /** 650e5e5558eSMiklos Szeredi * Get a filled in inode 651e5e5558eSMiklos Szeredi */ 652b48badf0SMiklos Szeredi struct inode *fuse_iget(struct super_block *sb, u64 nodeid, 6531fb69e78SMiklos Szeredi int generation, struct fuse_attr *attr, 6541fb69e78SMiklos Szeredi u64 attr_valid, u64 attr_version); 655e5e5558eSMiklos Szeredi 65633670fa2SMiklos Szeredi int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name, 65733670fa2SMiklos Szeredi struct fuse_entry_out *outarg, struct inode **inode); 65833670fa2SMiklos Szeredi 659e5e5558eSMiklos Szeredi /** 660e5e5558eSMiklos Szeredi * Send FORGET command 661e5e5558eSMiklos Szeredi */ 66207e77dcaSMiklos Szeredi void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, 663b48badf0SMiklos Szeredi u64 nodeid, u64 nlookup); 664e5e5558eSMiklos Szeredi 66507e77dcaSMiklos Szeredi struct fuse_forget_link *fuse_alloc_forget(void); 66607e77dcaSMiklos Szeredi 6670b05b183SAnand V. Avati /* Used by READDIRPLUS */ 6680b05b183SAnand V. Avati void fuse_force_forget(struct file *file, u64 nodeid); 6690b05b183SAnand V. Avati 670e5e5558eSMiklos Szeredi /** 671361b1eb5SMiklos Szeredi * Initialize READ or READDIR request 67204730fefSMiklos Szeredi */ 673a6643094SMiklos Szeredi void fuse_read_fill(struct fuse_req *req, struct file *file, 6742106cb18SMiklos Szeredi loff_t pos, size_t count, int opcode); 67504730fefSMiklos Szeredi 67604730fefSMiklos Szeredi /** 67704730fefSMiklos Szeredi * Send OPEN or OPENDIR request 67804730fefSMiklos Szeredi */ 67991fe96b4SMiklos Szeredi int fuse_open_common(struct inode *inode, struct file *file, bool isdir); 68004730fefSMiklos Szeredi 681acf99433STejun Heo struct fuse_file *fuse_file_alloc(struct fuse_conn *fc); 682c7b7143cSMiklos Szeredi struct fuse_file *fuse_file_get(struct fuse_file *ff); 683fd72faacSMiklos Szeredi void fuse_file_free(struct fuse_file *ff); 684c7b7143cSMiklos Szeredi void fuse_finish_open(struct inode *inode, struct file *file); 685fd72faacSMiklos Szeredi 6868b0797a4SMiklos Szeredi void fuse_sync_release(struct fuse_file *ff, int flags); 687c756e0a4SMiklos Szeredi 68804730fefSMiklos Szeredi /** 68904730fefSMiklos Szeredi * Send RELEASE or RELEASEDIR request 69004730fefSMiklos Szeredi */ 6918b0797a4SMiklos Szeredi void fuse_release_common(struct file *file, int opcode); 69204730fefSMiklos Szeredi 69304730fefSMiklos Szeredi /** 69482547981SMiklos Szeredi * Send FSYNC or FSYNCDIR request 69582547981SMiklos Szeredi */ 69602c24a82SJosef Bacik int fuse_fsync_common(struct file *file, loff_t start, loff_t end, 69702c24a82SJosef Bacik int datasync, int isdir); 69882547981SMiklos Szeredi 69982547981SMiklos Szeredi /** 70095668a69STejun Heo * Notify poll wakeup 70195668a69STejun Heo */ 70295668a69STejun Heo int fuse_notify_poll_wakeup(struct fuse_conn *fc, 70395668a69STejun Heo struct fuse_notify_poll_wakeup_out *outarg); 70495668a69STejun Heo 70595668a69STejun Heo /** 7061779381dSMiklos Szeredi * Initialize file operations on a regular file 707b6aeadedSMiklos Szeredi */ 708b6aeadedSMiklos Szeredi void fuse_init_file_inode(struct inode *inode); 709b6aeadedSMiklos Szeredi 710b6aeadedSMiklos Szeredi /** 7111779381dSMiklos Szeredi * Initialize inode operations on regular files and special files 712e5e5558eSMiklos Szeredi */ 713e5e5558eSMiklos Szeredi void fuse_init_common(struct inode *inode); 714e5e5558eSMiklos Szeredi 715e5e5558eSMiklos Szeredi /** 7161779381dSMiklos Szeredi * Initialize inode and file operations on a directory 717e5e5558eSMiklos Szeredi */ 718e5e5558eSMiklos Szeredi void fuse_init_dir(struct inode *inode); 719e5e5558eSMiklos Szeredi 720e5e5558eSMiklos Szeredi /** 7211779381dSMiklos Szeredi * Initialize inode operations on a symlink 722e5e5558eSMiklos Szeredi */ 723e5e5558eSMiklos Szeredi void fuse_init_symlink(struct inode *inode); 724e5e5558eSMiklos Szeredi 725e5e5558eSMiklos Szeredi /** 726e5e5558eSMiklos Szeredi * Change attributes of an inode 727e5e5558eSMiklos Szeredi */ 7281fb69e78SMiklos Szeredi void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, 7291fb69e78SMiklos Szeredi u64 attr_valid, u64 attr_version); 730e5e5558eSMiklos Szeredi 7313be5a52bSMiklos Szeredi void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, 7323be5a52bSMiklos Szeredi u64 attr_valid); 7333be5a52bSMiklos Szeredi 734e5e5558eSMiklos Szeredi /** 735334f485dSMiklos Szeredi * Initialize the client device 736334f485dSMiklos Szeredi */ 737334f485dSMiklos Szeredi int fuse_dev_init(void); 738334f485dSMiklos Szeredi 739334f485dSMiklos Szeredi /** 740334f485dSMiklos Szeredi * Cleanup the client device 741334f485dSMiklos Szeredi */ 742334f485dSMiklos Szeredi void fuse_dev_cleanup(void); 743334f485dSMiklos Szeredi 744bafa9654SMiklos Szeredi int fuse_ctl_init(void); 7457736e8ccSFabian Frederick void __exit fuse_ctl_cleanup(void); 746bafa9654SMiklos Szeredi 747334f485dSMiklos Szeredi /** 748334f485dSMiklos Szeredi * Allocate a request 749334f485dSMiklos Szeredi */ 7504250c066SMaxim Patlasov struct fuse_req *fuse_request_alloc(unsigned npages); 751334f485dSMiklos Szeredi 7524250c066SMaxim Patlasov struct fuse_req *fuse_request_alloc_nofs(unsigned npages); 7533be5a52bSMiklos Szeredi 754334f485dSMiklos Szeredi /** 755334f485dSMiklos Szeredi * Free a request 756334f485dSMiklos Szeredi */ 757334f485dSMiklos Szeredi void fuse_request_free(struct fuse_req *req); 758334f485dSMiklos Szeredi 759334f485dSMiklos Szeredi /** 760b111c8c0SMaxim Patlasov * Get a request, may fail with -ENOMEM, 761b111c8c0SMaxim Patlasov * caller should specify # elements in req->pages[] explicitly 762334f485dSMiklos Szeredi */ 763b111c8c0SMaxim Patlasov struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages); 7648b41e671SMaxim Patlasov struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc, 7658b41e671SMaxim Patlasov unsigned npages); 766b111c8c0SMaxim Patlasov 76736cf66edSMaxim Patlasov /* 76836cf66edSMaxim Patlasov * Increment reference count on request 76936cf66edSMaxim Patlasov */ 77036cf66edSMaxim Patlasov void __fuse_get_request(struct fuse_req *req); 77136cf66edSMaxim Patlasov 772b111c8c0SMaxim Patlasov /** 77333649c91SMiklos Szeredi * Gets a requests for a file operation, always succeeds 77433649c91SMiklos Szeredi */ 775b111c8c0SMaxim Patlasov struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc, 776b111c8c0SMaxim Patlasov struct file *file); 77733649c91SMiklos Szeredi 77833649c91SMiklos Szeredi /** 779ce1d5a49SMiklos Szeredi * Decrement reference count of a request. If count goes to zero free 780ce1d5a49SMiklos Szeredi * the request. 781334f485dSMiklos Szeredi */ 782334f485dSMiklos Szeredi void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req); 783334f485dSMiklos Szeredi 784334f485dSMiklos Szeredi /** 7857c352bdfSMiklos Szeredi * Send a request (synchronous) 786334f485dSMiklos Szeredi */ 787b93f858aSTejun Heo void fuse_request_send(struct fuse_conn *fc, struct fuse_req *req); 788334f485dSMiklos Szeredi 789334f485dSMiklos Szeredi /** 7907078187aSMiklos Szeredi * Simple request sending that does request allocation and freeing 7917078187aSMiklos Szeredi */ 7927078187aSMiklos Szeredi ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args); 7937078187aSMiklos Szeredi 7947078187aSMiklos Szeredi /** 795334f485dSMiklos Szeredi * Send a request in the background 796334f485dSMiklos Szeredi */ 797b93f858aSTejun Heo void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req); 798334f485dSMiklos Szeredi 799b93f858aSTejun Heo void fuse_request_send_background_locked(struct fuse_conn *fc, 800b93f858aSTejun Heo struct fuse_req *req); 8013be5a52bSMiklos Szeredi 8025a5fb1eaSMiklos Szeredi /* Abort all requests */ 80369a53bf2SMiklos Szeredi void fuse_abort_conn(struct fuse_conn *fc); 80469a53bf2SMiklos Szeredi 8051e9a4ed9SMiklos Szeredi /** 806e5e5558eSMiklos Szeredi * Invalidate inode attributes 807e5e5558eSMiklos Szeredi */ 808e5e5558eSMiklos Szeredi void fuse_invalidate_attr(struct inode *inode); 809bafa9654SMiklos Szeredi 810dbd561d2SMiklos Szeredi void fuse_invalidate_entry_cache(struct dentry *entry); 811dbd561d2SMiklos Szeredi 812451418fcSAndrew Gallagher void fuse_invalidate_atime(struct inode *inode); 813451418fcSAndrew Gallagher 814bafa9654SMiklos Szeredi /** 815bafa9654SMiklos Szeredi * Acquire reference to fuse_conn 816bafa9654SMiklos Szeredi */ 817bafa9654SMiklos Szeredi struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); 818bafa9654SMiklos Szeredi 819bafa9654SMiklos Szeredi /** 8200d179aa5STejun Heo * Initialize fuse_conn 8210d179aa5STejun Heo */ 822a325f9b9STejun Heo void fuse_conn_init(struct fuse_conn *fc); 8230d179aa5STejun Heo 8240d179aa5STejun Heo /** 825bafa9654SMiklos Szeredi * Release reference to fuse_conn 826bafa9654SMiklos Szeredi */ 827bafa9654SMiklos Szeredi void fuse_conn_put(struct fuse_conn *fc); 828bafa9654SMiklos Szeredi 829bafa9654SMiklos Szeredi /** 830bafa9654SMiklos Szeredi * Add connection to control filesystem 831bafa9654SMiklos Szeredi */ 832bafa9654SMiklos Szeredi int fuse_ctl_add_conn(struct fuse_conn *fc); 833bafa9654SMiklos Szeredi 834bafa9654SMiklos Szeredi /** 835bafa9654SMiklos Szeredi * Remove connection from control filesystem 836bafa9654SMiklos Szeredi */ 837bafa9654SMiklos Szeredi void fuse_ctl_remove_conn(struct fuse_conn *fc); 838a5bfffacSTimo Savola 839a5bfffacSTimo Savola /** 840a5bfffacSTimo Savola * Is file type valid? 841a5bfffacSTimo Savola */ 842a5bfffacSTimo Savola int fuse_valid_type(int m); 843e57ac683SMiklos Szeredi 844e57ac683SMiklos Szeredi /** 845c2132c1bSAnatol Pomozov * Is current process allowed to perform filesystem operation? 846e57ac683SMiklos Szeredi */ 847c2132c1bSAnatol Pomozov int fuse_allow_current_process(struct fuse_conn *fc); 848f3332114SMiklos Szeredi 849f3332114SMiklos Szeredi u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id); 850bcb4be80SMiklos Szeredi 851bcb4be80SMiklos Szeredi int fuse_update_attributes(struct inode *inode, struct kstat *stat, 852bcb4be80SMiklos Szeredi struct file *file, bool *refreshed); 8533be5a52bSMiklos Szeredi 8543be5a52bSMiklos Szeredi void fuse_flush_writepages(struct inode *inode); 8553be5a52bSMiklos Szeredi 8563be5a52bSMiklos Szeredi void fuse_set_nowrite(struct inode *inode); 8573be5a52bSMiklos Szeredi void fuse_release_nowrite(struct inode *inode); 8585c5c5e51SMiklos Szeredi 8595c5c5e51SMiklos Szeredi u64 fuse_get_attr_version(struct fuse_conn *fc); 86029d434b3STejun Heo 8613b463ae0SJohn Muir /** 8623b463ae0SJohn Muir * File-system tells the kernel to invalidate cache for the given node id. 8633b463ae0SJohn Muir */ 8643b463ae0SJohn Muir int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid, 8653b463ae0SJohn Muir loff_t offset, loff_t len); 8663b463ae0SJohn Muir 8673b463ae0SJohn Muir /** 8683b463ae0SJohn Muir * File-system tells the kernel to invalidate parent attributes and 8693b463ae0SJohn Muir * the dentry matching parent/name. 870451d0f59SJohn Muir * 871451d0f59SJohn Muir * If the child_nodeid is non-zero and: 872451d0f59SJohn Muir * - matches the inode number for the dentry matching parent/name, 873451d0f59SJohn Muir * - is not a mount point 874451d0f59SJohn Muir * - is a file or oan empty directory 875451d0f59SJohn Muir * then the dentry is unhashed (d_delete()). 8763b463ae0SJohn Muir */ 8773b463ae0SJohn Muir int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid, 878451d0f59SJohn Muir u64 child_nodeid, struct qstr *name); 8793b463ae0SJohn Muir 88008cbf542STejun Heo int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file, 88108cbf542STejun Heo bool isdir); 882ea8cd333SPavel Emelyanov 883ea8cd333SPavel Emelyanov /** 884ea8cd333SPavel Emelyanov * fuse_direct_io() flags 885ea8cd333SPavel Emelyanov */ 886ea8cd333SPavel Emelyanov 887ea8cd333SPavel Emelyanov /** If set, it is WRITE; otherwise - READ */ 888ea8cd333SPavel Emelyanov #define FUSE_DIO_WRITE (1 << 0) 889ea8cd333SPavel Emelyanov 890ea8cd333SPavel Emelyanov /** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */ 891ea8cd333SPavel Emelyanov #define FUSE_DIO_CUSE (1 << 1) 892ea8cd333SPavel Emelyanov 893d22a943fSAl Viro ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, 894d22a943fSAl Viro loff_t *ppos, int flags); 89508cbf542STejun Heo long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, 89608cbf542STejun Heo unsigned int flags); 897b18da0c5SMiklos Szeredi long fuse_ioctl_common(struct file *file, unsigned int cmd, 898b18da0c5SMiklos Szeredi unsigned long arg, unsigned int flags); 89908cbf542STejun Heo unsigned fuse_file_poll(struct file *file, poll_table *wait); 90008cbf542STejun Heo int fuse_dev_release(struct inode *inode, struct file *file); 90108cbf542STejun Heo 902b0aa7606SMaxim Patlasov bool fuse_write_update_size(struct inode *inode, loff_t pos); 903b0aa7606SMaxim Patlasov 904ab9e13f7SMaxim Patlasov int fuse_flush_times(struct inode *inode, struct fuse_file *ff); 9051e18bda8SMiklos Szeredi int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); 906a1d75f25SMiklos Szeredi 907efb9fa9eSMaxim Patlasov int fuse_do_setattr(struct inode *inode, struct iattr *attr, 908efb9fa9eSMaxim Patlasov struct file *file); 909efb9fa9eSMaxim Patlasov 9109759bd51SMiklos Szeredi void fuse_set_initialized(struct fuse_conn *fc); 9119759bd51SMiklos Szeredi 91229d434b3STejun Heo #endif /* _FS_FUSE_I_H */ 913