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, 118*06a7c3c2SMaxim Patlasov /** An operation changing file size is in progress */ 119*06a7c3c2SMaxim Patlasov FUSE_I_SIZE_UNSTABLE, 120d8a5ba45SMiklos Szeredi }; 121d8a5ba45SMiklos Szeredi 122da5e4714SMiklos Szeredi struct fuse_conn; 123da5e4714SMiklos Szeredi 124b6aeadedSMiklos Szeredi /** FUSE specific file data */ 125b6aeadedSMiklos Szeredi struct fuse_file { 126da5e4714SMiklos Szeredi /** Fuse connection for this file */ 127da5e4714SMiklos Szeredi struct fuse_conn *fc; 128da5e4714SMiklos Szeredi 129b6aeadedSMiklos Szeredi /** Request reserved for flush and release */ 13033649c91SMiklos Szeredi struct fuse_req *reserved_req; 131b6aeadedSMiklos Szeredi 132acf99433STejun Heo /** Kernel file handle guaranteed to be unique */ 133acf99433STejun Heo u64 kh; 134acf99433STejun Heo 135b6aeadedSMiklos Szeredi /** File handle used by userspace */ 136b6aeadedSMiklos Szeredi u64 fh; 137c756e0a4SMiklos Szeredi 138da5e4714SMiklos Szeredi /** Node id of this file */ 139da5e4714SMiklos Szeredi u64 nodeid; 140da5e4714SMiklos Szeredi 141c756e0a4SMiklos Szeredi /** Refcount */ 142c756e0a4SMiklos Szeredi atomic_t count; 14393a8c3cdSMiklos Szeredi 144c7b7143cSMiklos Szeredi /** FOPEN_* flags returned by open */ 145c7b7143cSMiklos Szeredi u32 open_flags; 146c7b7143cSMiklos Szeredi 14793a8c3cdSMiklos Szeredi /** Entry on inode's write_files list */ 14893a8c3cdSMiklos Szeredi struct list_head write_entry; 14995668a69STejun Heo 15095668a69STejun Heo /** RB node to be linked on fuse_conn->polled_files */ 15195668a69STejun Heo struct rb_node polled_node; 15295668a69STejun Heo 15395668a69STejun Heo /** Wait queue head for poll */ 15495668a69STejun Heo wait_queue_head_t poll_wait; 15537fb3a30SMiklos Szeredi 15637fb3a30SMiklos Szeredi /** Has flock been performed on this file? */ 15737fb3a30SMiklos Szeredi bool flock:1; 158b6aeadedSMiklos Szeredi }; 159b6aeadedSMiklos Szeredi 160334f485dSMiklos Szeredi /** One input argument of a request */ 161334f485dSMiklos Szeredi struct fuse_in_arg { 162334f485dSMiklos Szeredi unsigned size; 163334f485dSMiklos Szeredi const void *value; 164334f485dSMiklos Szeredi }; 165334f485dSMiklos Szeredi 166334f485dSMiklos Szeredi /** The request input */ 167334f485dSMiklos Szeredi struct fuse_in { 168334f485dSMiklos Szeredi /** The request header */ 169334f485dSMiklos Szeredi struct fuse_in_header h; 170334f485dSMiklos Szeredi 171334f485dSMiklos Szeredi /** True if the data for the last argument is in req->pages */ 172334f485dSMiklos Szeredi unsigned argpages:1; 173334f485dSMiklos Szeredi 174334f485dSMiklos Szeredi /** Number of arguments */ 175334f485dSMiklos Szeredi unsigned numargs; 176334f485dSMiklos Szeredi 177334f485dSMiklos Szeredi /** Array of arguments */ 178334f485dSMiklos Szeredi struct fuse_in_arg args[3]; 179334f485dSMiklos Szeredi }; 180334f485dSMiklos Szeredi 181334f485dSMiklos Szeredi /** One output argument of a request */ 182334f485dSMiklos Szeredi struct fuse_arg { 183334f485dSMiklos Szeredi unsigned size; 184334f485dSMiklos Szeredi void *value; 185334f485dSMiklos Szeredi }; 186334f485dSMiklos Szeredi 187334f485dSMiklos Szeredi /** The request output */ 188334f485dSMiklos Szeredi struct fuse_out { 189334f485dSMiklos Szeredi /** Header returned from userspace */ 190334f485dSMiklos Szeredi struct fuse_out_header h; 191334f485dSMiklos Szeredi 192095da6cbSMiklos Szeredi /* 193095da6cbSMiklos Szeredi * The following bitfields are not changed during the request 194095da6cbSMiklos Szeredi * processing 195095da6cbSMiklos Szeredi */ 196095da6cbSMiklos Szeredi 197334f485dSMiklos Szeredi /** Last argument is variable length (can be shorter than 198334f485dSMiklos Szeredi arg->size) */ 199334f485dSMiklos Szeredi unsigned argvar:1; 200334f485dSMiklos Szeredi 201334f485dSMiklos Szeredi /** Last argument is a list of pages to copy data to */ 202334f485dSMiklos Szeredi unsigned argpages:1; 203334f485dSMiklos Szeredi 204334f485dSMiklos Szeredi /** Zero partially or not copied pages */ 205334f485dSMiklos Szeredi unsigned page_zeroing:1; 206334f485dSMiklos Szeredi 207ce534fb0SMiklos Szeredi /** Pages may be replaced with new ones */ 208ce534fb0SMiklos Szeredi unsigned page_replace:1; 209ce534fb0SMiklos Szeredi 210334f485dSMiklos Szeredi /** Number or arguments */ 211334f485dSMiklos Szeredi unsigned numargs; 212334f485dSMiklos Szeredi 213334f485dSMiklos Szeredi /** Array of arguments */ 214334f485dSMiklos Szeredi struct fuse_arg args[3]; 215334f485dSMiklos Szeredi }; 216334f485dSMiklos Szeredi 217b2430d75SMaxim Patlasov /** FUSE page descriptor */ 218b2430d75SMaxim Patlasov struct fuse_page_desc { 219b2430d75SMaxim Patlasov unsigned int length; 220b2430d75SMaxim Patlasov unsigned int offset; 221b2430d75SMaxim Patlasov }; 222b2430d75SMaxim Patlasov 22383cfd493SMiklos Szeredi /** The request state */ 22483cfd493SMiklos Szeredi enum fuse_req_state { 22583cfd493SMiklos Szeredi FUSE_REQ_INIT = 0, 22683cfd493SMiklos Szeredi FUSE_REQ_PENDING, 22783cfd493SMiklos Szeredi FUSE_REQ_READING, 22883cfd493SMiklos Szeredi FUSE_REQ_SENT, 229a4d27e75SMiklos Szeredi FUSE_REQ_WRITING, 23083cfd493SMiklos Szeredi FUSE_REQ_FINISHED 23183cfd493SMiklos Szeredi }; 23283cfd493SMiklos Szeredi 23301e9d11aSMaxim Patlasov /** The request IO state (for asynchronous processing) */ 23401e9d11aSMaxim Patlasov struct fuse_io_priv { 23501e9d11aSMaxim Patlasov int async; 23601e9d11aSMaxim Patlasov spinlock_t lock; 23701e9d11aSMaxim Patlasov unsigned reqs; 23801e9d11aSMaxim Patlasov ssize_t bytes; 23901e9d11aSMaxim Patlasov size_t size; 24001e9d11aSMaxim Patlasov __u64 offset; 24101e9d11aSMaxim Patlasov bool write; 24201e9d11aSMaxim Patlasov int err; 24301e9d11aSMaxim Patlasov struct kiocb *iocb; 24401e9d11aSMaxim Patlasov struct file *file; 24501e9d11aSMaxim Patlasov }; 24601e9d11aSMaxim Patlasov 247334f485dSMiklos Szeredi /** 248334f485dSMiklos Szeredi * A request to the client 249334f485dSMiklos Szeredi */ 250334f485dSMiklos Szeredi struct fuse_req { 251ce1d5a49SMiklos Szeredi /** This can be on either pending processing or io lists in 252ce1d5a49SMiklos Szeredi fuse_conn */ 253334f485dSMiklos Szeredi struct list_head list; 254334f485dSMiklos Szeredi 255a4d27e75SMiklos Szeredi /** Entry on the interrupts list */ 256a4d27e75SMiklos Szeredi struct list_head intr_entry; 257a4d27e75SMiklos Szeredi 258334f485dSMiklos Szeredi /** refcount */ 259334f485dSMiklos Szeredi atomic_t count; 260334f485dSMiklos Szeredi 261a4d27e75SMiklos Szeredi /** Unique ID for the interrupt request */ 262a4d27e75SMiklos Szeredi u64 intr_unique; 263a4d27e75SMiklos Szeredi 264095da6cbSMiklos Szeredi /* 265095da6cbSMiklos Szeredi * The following bitfields are either set once before the 266095da6cbSMiklos Szeredi * request is queued or setting/clearing them is protected by 267d7133114SMiklos Szeredi * fuse_conn->lock 268095da6cbSMiklos Szeredi */ 269095da6cbSMiklos Szeredi 270334f485dSMiklos Szeredi /** True if the request has reply */ 271334f485dSMiklos Szeredi unsigned isreply:1; 272334f485dSMiklos Szeredi 27351eb01e7SMiklos Szeredi /** Force sending of the request even if interrupted */ 27451eb01e7SMiklos Szeredi unsigned force:1; 27551eb01e7SMiklos Szeredi 276f9a2842eSMiklos Szeredi /** The request was aborted */ 277f9a2842eSMiklos Szeredi unsigned aborted:1; 278334f485dSMiklos Szeredi 279334f485dSMiklos Szeredi /** Request is sent in the background */ 280334f485dSMiklos Szeredi unsigned background:1; 281334f485dSMiklos Szeredi 282a4d27e75SMiklos Szeredi /** The request has been interrupted */ 283a4d27e75SMiklos Szeredi unsigned interrupted:1; 284a4d27e75SMiklos Szeredi 285334f485dSMiklos Szeredi /** Data is being copied to/from the request */ 286334f485dSMiklos Szeredi unsigned locked:1; 287334f485dSMiklos Szeredi 2889bc5dddaSMiklos Szeredi /** Request is counted as "waiting" */ 2899bc5dddaSMiklos Szeredi unsigned waiting:1; 2909bc5dddaSMiklos Szeredi 29183cfd493SMiklos Szeredi /** State of the request */ 29283cfd493SMiklos Szeredi enum fuse_req_state state; 293334f485dSMiklos Szeredi 294334f485dSMiklos Szeredi /** The request input */ 295334f485dSMiklos Szeredi struct fuse_in in; 296334f485dSMiklos Szeredi 297334f485dSMiklos Szeredi /** The request output */ 298334f485dSMiklos Szeredi struct fuse_out out; 299334f485dSMiklos Szeredi 300334f485dSMiklos Szeredi /** Used to wake up the task waiting for completion of request*/ 301334f485dSMiklos Szeredi wait_queue_head_t waitq; 302334f485dSMiklos Szeredi 303334f485dSMiklos Szeredi /** Data for asynchronous requests */ 304334f485dSMiklos Szeredi union { 305b57d4264SMiklos Szeredi struct { 3065a18ec17SMiklos Szeredi union { 307b57d4264SMiklos Szeredi struct fuse_release_in in; 3085a18ec17SMiklos Szeredi struct work_struct work; 3095a18ec17SMiklos Szeredi }; 310b0be46ebSMiklos Szeredi struct path path; 311b57d4264SMiklos Szeredi } release; 3123ec870d5SMiklos Szeredi struct fuse_init_in init_in; 3133ec870d5SMiklos Szeredi struct fuse_init_out init_out; 31408cbf542STejun Heo struct cuse_init_in cuse_init_in; 3155c5c5e51SMiklos Szeredi struct { 3165c5c5e51SMiklos Szeredi struct fuse_read_in in; 3175c5c5e51SMiklos Szeredi u64 attr_ver; 3185c5c5e51SMiklos Szeredi } read; 319b25e82e5SMiklos Szeredi struct { 320b25e82e5SMiklos Szeredi struct fuse_write_in in; 321b25e82e5SMiklos Szeredi struct fuse_write_out out; 322b25e82e5SMiklos Szeredi } write; 3232d45ba38SMiklos Szeredi struct fuse_notify_retrieve_in retrieve_in; 32471421259SMiklos Szeredi struct fuse_lk_in lk_in; 325334f485dSMiklos Szeredi } misc; 326334f485dSMiklos Szeredi 327334f485dSMiklos Szeredi /** page vector */ 3284250c066SMaxim Patlasov struct page **pages; 3294250c066SMaxim Patlasov 330b2430d75SMaxim Patlasov /** page-descriptor vector */ 331b2430d75SMaxim Patlasov struct fuse_page_desc *page_descs; 332b2430d75SMaxim Patlasov 3334250c066SMaxim Patlasov /** size of the 'pages' array */ 3344250c066SMaxim Patlasov unsigned max_pages; 3354250c066SMaxim Patlasov 3364250c066SMaxim Patlasov /** inline page vector */ 3374250c066SMaxim Patlasov struct page *inline_pages[FUSE_REQ_INLINE_PAGES]; 338334f485dSMiklos Szeredi 339b2430d75SMaxim Patlasov /** inline page-descriptor vector */ 340b2430d75SMaxim Patlasov struct fuse_page_desc inline_page_descs[FUSE_REQ_INLINE_PAGES]; 341b2430d75SMaxim Patlasov 342334f485dSMiklos Szeredi /** number of pages in vector */ 343334f485dSMiklos Szeredi unsigned num_pages; 344334f485dSMiklos Szeredi 345334f485dSMiklos Szeredi /** File used in the request (or NULL) */ 346c756e0a4SMiklos Szeredi struct fuse_file *ff; 34764c6d8edSMiklos Szeredi 3483be5a52bSMiklos Szeredi /** Inode used in the request or NULL */ 3493be5a52bSMiklos Szeredi struct inode *inode; 3503be5a52bSMiklos Szeredi 35101e9d11aSMaxim Patlasov /** AIO control block */ 35201e9d11aSMaxim Patlasov struct fuse_io_priv *io; 35301e9d11aSMaxim Patlasov 3543be5a52bSMiklos Szeredi /** Link on fi->writepages */ 3553be5a52bSMiklos Szeredi struct list_head writepages_entry; 3563be5a52bSMiklos Szeredi 35764c6d8edSMiklos Szeredi /** Request completion callback */ 35864c6d8edSMiklos Szeredi void (*end)(struct fuse_conn *, struct fuse_req *); 35933649c91SMiklos Szeredi 36033649c91SMiklos Szeredi /** Request is stolen from fuse_file->reserved_req */ 36133649c91SMiklos Szeredi struct file *stolen_file; 362334f485dSMiklos Szeredi }; 363334f485dSMiklos Szeredi 364d8a5ba45SMiklos Szeredi /** 365d8a5ba45SMiklos Szeredi * A Fuse connection. 366d8a5ba45SMiklos Szeredi * 367d8a5ba45SMiklos Szeredi * This structure is created, when the filesystem is mounted, and is 368d8a5ba45SMiklos Szeredi * destroyed, when the client device is closed and the filesystem is 369d8a5ba45SMiklos Szeredi * unmounted. 370d8a5ba45SMiklos Szeredi */ 371d8a5ba45SMiklos Szeredi struct fuse_conn { 372d7133114SMiklos Szeredi /** Lock protecting accessess to members of this structure */ 373d7133114SMiklos Szeredi spinlock_t lock; 374d7133114SMiklos Szeredi 375d2a85164SMiklos Szeredi /** Mutex protecting against directory alias creation */ 376d2a85164SMiklos Szeredi struct mutex inst_mutex; 377d2a85164SMiklos Szeredi 378bafa9654SMiklos Szeredi /** Refcount */ 379bafa9654SMiklos Szeredi atomic_t count; 380bafa9654SMiklos Szeredi 381d8a5ba45SMiklos Szeredi /** The user id for this mount */ 382499dcf20SEric W. Biederman kuid_t user_id; 383d8a5ba45SMiklos Szeredi 38487729a55SMiklos Szeredi /** The group id for this mount */ 385499dcf20SEric W. Biederman kgid_t group_id; 38687729a55SMiklos Szeredi 3871e9a4ed9SMiklos Szeredi /** The fuse mount flags for this mount */ 3881e9a4ed9SMiklos Szeredi unsigned flags; 3891e9a4ed9SMiklos Szeredi 390db50b96cSMiklos Szeredi /** Maximum read size */ 391db50b96cSMiklos Szeredi unsigned max_read; 392db50b96cSMiklos Szeredi 393413ef8cbSMiklos Szeredi /** Maximum write size */ 394413ef8cbSMiklos Szeredi unsigned max_write; 395413ef8cbSMiklos Szeredi 396334f485dSMiklos Szeredi /** Readers of the connection are waiting on this */ 397334f485dSMiklos Szeredi wait_queue_head_t waitq; 398334f485dSMiklos Szeredi 399334f485dSMiklos Szeredi /** The list of pending requests */ 400334f485dSMiklos Szeredi struct list_head pending; 401334f485dSMiklos Szeredi 402334f485dSMiklos Szeredi /** The list of requests being processed */ 403334f485dSMiklos Szeredi struct list_head processing; 404334f485dSMiklos Szeredi 405d77a1d5bSMiklos Szeredi /** The list of requests under I/O */ 406d77a1d5bSMiklos Szeredi struct list_head io; 407d77a1d5bSMiklos Szeredi 408acf99433STejun Heo /** The next unique kernel file handle */ 409acf99433STejun Heo u64 khctr; 410acf99433STejun Heo 41195668a69STejun Heo /** rbtree of fuse_files waiting for poll events indexed by ph */ 41295668a69STejun Heo struct rb_root polled_files; 41395668a69STejun Heo 4147a6d3c8bSCsaba Henk /** Maximum number of outstanding background requests */ 4157a6d3c8bSCsaba Henk unsigned max_background; 4167a6d3c8bSCsaba Henk 4177a6d3c8bSCsaba Henk /** Number of background requests at which congestion starts */ 4187a6d3c8bSCsaba Henk unsigned congestion_threshold; 4197a6d3c8bSCsaba Henk 42008a53cdcSMiklos Szeredi /** Number of requests currently in the background */ 42108a53cdcSMiklos Szeredi unsigned num_background; 42208a53cdcSMiklos Szeredi 423d12def1bSMiklos Szeredi /** Number of background requests currently queued for userspace */ 424d12def1bSMiklos Szeredi unsigned active_background; 425d12def1bSMiklos Szeredi 426d12def1bSMiklos Szeredi /** The list of background requests set aside for later queuing */ 427d12def1bSMiklos Szeredi struct list_head bg_queue; 428d12def1bSMiklos Szeredi 429a4d27e75SMiklos Szeredi /** Pending interrupts */ 430a4d27e75SMiklos Szeredi struct list_head interrupts; 431a4d27e75SMiklos Szeredi 43207e77dcaSMiklos Szeredi /** Queue of pending forgets */ 43307e77dcaSMiklos Szeredi struct fuse_forget_link forget_list_head; 43407e77dcaSMiklos Szeredi struct fuse_forget_link *forget_list_tail; 43507e77dcaSMiklos Szeredi 43607e77dcaSMiklos Szeredi /** Batching of FORGET requests (positive indicates FORGET batch) */ 43707e77dcaSMiklos Szeredi int forget_batch; 43807e77dcaSMiklos Szeredi 439796523fbSMaxim Patlasov /** Flag indicating that INIT reply has been received. Allocating 440796523fbSMaxim Patlasov * any fuse request will be suspended until the flag is set */ 441796523fbSMaxim Patlasov int initialized; 442796523fbSMaxim Patlasov 44308a53cdcSMiklos Szeredi /** Flag indicating if connection is blocked. This will be 44408a53cdcSMiklos Szeredi the case before the INIT reply is received, and if there 44508a53cdcSMiklos Szeredi are too many outstading backgrounds requests */ 44608a53cdcSMiklos Szeredi int blocked; 44708a53cdcSMiklos Szeredi 44808a53cdcSMiklos Szeredi /** waitq for blocked connection */ 44908a53cdcSMiklos Szeredi wait_queue_head_t blocked_waitq; 45008a53cdcSMiklos Szeredi 451de5e3decSMiklos Szeredi /** waitq for reserved requests */ 452de5e3decSMiklos Szeredi wait_queue_head_t reserved_req_waitq; 453de5e3decSMiklos Szeredi 454334f485dSMiklos Szeredi /** The next unique request id */ 455334f485dSMiklos Szeredi u64 reqctr; 456334f485dSMiklos Szeredi 45769a53bf2SMiklos Szeredi /** Connection established, cleared on umount, connection 45869a53bf2SMiklos Szeredi abort and device release */ 459095da6cbSMiklos Szeredi unsigned connected; 4601e9a4ed9SMiklos Szeredi 461095da6cbSMiklos Szeredi /** Connection failed (version mismatch). Cannot race with 462095da6cbSMiklos Szeredi setting other bitfields since it is only set once in INIT 463095da6cbSMiklos Szeredi reply, before any other request, and never cleared */ 464334f485dSMiklos Szeredi unsigned conn_error:1; 465334f485dSMiklos Szeredi 4660ec7ca41SMiklos Szeredi /** Connection successful. Only set in INIT */ 4670ec7ca41SMiklos Szeredi unsigned conn_init:1; 4680ec7ca41SMiklos Szeredi 4699cd68455SMiklos Szeredi /** Do readpages asynchronously? Only set in INIT */ 4709cd68455SMiklos Szeredi unsigned async_read:1; 4719cd68455SMiklos Szeredi 4726ff958edSMiklos Szeredi /** Do not send separate SETATTR request before open(O_TRUNC) */ 4736ff958edSMiklos Szeredi unsigned atomic_o_trunc:1; 4746ff958edSMiklos Szeredi 47533670fa2SMiklos Szeredi /** Filesystem supports NFS exporting. Only set in INIT */ 47633670fa2SMiklos Szeredi unsigned export_support:1; 47733670fa2SMiklos Szeredi 478a325f9b9STejun Heo /** Set if bdi is valid */ 479a325f9b9STejun Heo unsigned bdi_initialized:1; 480a325f9b9STejun Heo 481095da6cbSMiklos Szeredi /* 482095da6cbSMiklos Szeredi * The following bitfields are only for optimization purposes 483095da6cbSMiklos Szeredi * and hence races in setting them will not cause malfunction 484095da6cbSMiklos Szeredi */ 485095da6cbSMiklos Szeredi 486b6aeadedSMiklos Szeredi /** Is fsync not implemented by fs? */ 487b6aeadedSMiklos Szeredi unsigned no_fsync:1; 488b6aeadedSMiklos Szeredi 48982547981SMiklos Szeredi /** Is fsyncdir not implemented by fs? */ 49082547981SMiklos Szeredi unsigned no_fsyncdir:1; 49182547981SMiklos Szeredi 492b6aeadedSMiklos Szeredi /** Is flush not implemented by fs? */ 493b6aeadedSMiklos Szeredi unsigned no_flush:1; 494b6aeadedSMiklos Szeredi 49592a8780eSMiklos Szeredi /** Is setxattr not implemented by fs? */ 49692a8780eSMiklos Szeredi unsigned no_setxattr:1; 49792a8780eSMiklos Szeredi 49892a8780eSMiklos Szeredi /** Is getxattr not implemented by fs? */ 49992a8780eSMiklos Szeredi unsigned no_getxattr:1; 50092a8780eSMiklos Szeredi 50192a8780eSMiklos Szeredi /** Is listxattr not implemented by fs? */ 50292a8780eSMiklos Szeredi unsigned no_listxattr:1; 50392a8780eSMiklos Szeredi 50492a8780eSMiklos Szeredi /** Is removexattr not implemented by fs? */ 50592a8780eSMiklos Szeredi unsigned no_removexattr:1; 50692a8780eSMiklos Szeredi 50737fb3a30SMiklos Szeredi /** Are posix file locking primitives not implemented by fs? */ 50871421259SMiklos Szeredi unsigned no_lock:1; 50971421259SMiklos Szeredi 51031d40d74SMiklos Szeredi /** Is access not implemented by fs? */ 51131d40d74SMiklos Szeredi unsigned no_access:1; 51231d40d74SMiklos Szeredi 513fd72faacSMiklos Szeredi /** Is create not implemented by fs? */ 514fd72faacSMiklos Szeredi unsigned no_create:1; 515fd72faacSMiklos Szeredi 516a4d27e75SMiklos Szeredi /** Is interrupt not implemented by fs? */ 517a4d27e75SMiklos Szeredi unsigned no_interrupt:1; 518a4d27e75SMiklos Szeredi 519b2d2272fSMiklos Szeredi /** Is bmap not implemented by fs? */ 520b2d2272fSMiklos Szeredi unsigned no_bmap:1; 521b2d2272fSMiklos Szeredi 52295668a69STejun Heo /** Is poll not implemented by fs? */ 52395668a69STejun Heo unsigned no_poll:1; 52495668a69STejun Heo 52578bb6cb9SMiklos Szeredi /** Do multi-page cached writes */ 52678bb6cb9SMiklos Szeredi unsigned big_writes:1; 52778bb6cb9SMiklos Szeredi 528e0a43ddcSMiklos Szeredi /** Don't apply umask to creation modes */ 529e0a43ddcSMiklos Szeredi unsigned dont_mask:1; 530e0a43ddcSMiklos Szeredi 53137fb3a30SMiklos Szeredi /** Are BSD file locking primitives not implemented by fs? */ 53237fb3a30SMiklos Szeredi unsigned no_flock:1; 53337fb3a30SMiklos Szeredi 534519c6040SMiklos Szeredi /** Is fallocate not implemented by fs? */ 535519c6040SMiklos Szeredi unsigned no_fallocate:1; 536519c6040SMiklos Szeredi 53772d0d248SBrian Foster /** Use enhanced/automatic page cache invalidation. */ 53872d0d248SBrian Foster unsigned auto_inval_data:1; 53972d0d248SBrian Foster 540634734b6SEric Wong /** Does the filesystem support readdirplus? */ 5410b05b183SAnand V. Avati unsigned do_readdirplus:1; 5420b05b183SAnand V. Avati 543634734b6SEric Wong /** Does the filesystem want adaptive readdirplus? */ 544634734b6SEric Wong unsigned readdirplus_auto:1; 545634734b6SEric Wong 54660b9df7aSMiklos Szeredi /** Does the filesystem support asynchronous direct-IO submission? */ 54760b9df7aSMiklos Szeredi unsigned async_dio:1; 54860b9df7aSMiklos Szeredi 5490cd5b885SMiklos Szeredi /** The number of requests waiting for completion */ 5500cd5b885SMiklos Szeredi atomic_t num_waiting; 5510cd5b885SMiklos Szeredi 55245714d65SMiklos Szeredi /** Negotiated minor version */ 55345714d65SMiklos Szeredi unsigned minor; 55445714d65SMiklos Szeredi 555d8a5ba45SMiklos Szeredi /** Backing dev info */ 556d8a5ba45SMiklos Szeredi struct backing_dev_info bdi; 557f543f253SMiklos Szeredi 558bafa9654SMiklos Szeredi /** Entry on the fuse_conn_list */ 559bafa9654SMiklos Szeredi struct list_head entry; 560bafa9654SMiklos Szeredi 561b6f2fcbcSMiklos Szeredi /** Device ID from super block */ 562b6f2fcbcSMiklos Szeredi dev_t dev; 563bafa9654SMiklos Szeredi 564bafa9654SMiklos Szeredi /** Dentries in the control filesystem */ 565bafa9654SMiklos Szeredi struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; 566bafa9654SMiklos Szeredi 567bafa9654SMiklos Szeredi /** number of dentries used in the above array */ 568bafa9654SMiklos Szeredi int ctl_ndents; 569385a17bfSJeff Dike 570385a17bfSJeff Dike /** O_ASYNC requests */ 571385a17bfSJeff Dike struct fasync_struct *fasync; 5729c8ef561SMiklos Szeredi 5739c8ef561SMiklos Szeredi /** Key for lock owner ID scrambling */ 5749c8ef561SMiklos Szeredi u32 scramble_key[4]; 5750ec7ca41SMiklos Szeredi 5760ec7ca41SMiklos Szeredi /** Reserved request for the DESTROY message */ 5770ec7ca41SMiklos Szeredi struct fuse_req *destroy_req; 5781fb69e78SMiklos Szeredi 5791fb69e78SMiklos Szeredi /** Version counter for attribute changes */ 5801fb69e78SMiklos Szeredi u64 attr_version; 58143901aabSTejun Heo 58243901aabSTejun Heo /** Called on final put */ 58343901aabSTejun Heo void (*release)(struct fuse_conn *); 5843b463ae0SJohn Muir 5853b463ae0SJohn Muir /** Super block for this connection. */ 5863b463ae0SJohn Muir struct super_block *sb; 5873b463ae0SJohn Muir 5883b463ae0SJohn Muir /** Read/write semaphore to hold when accessing sb. */ 5893b463ae0SJohn Muir struct rw_semaphore killsb; 590d8a5ba45SMiklos Szeredi }; 591d8a5ba45SMiklos Szeredi 592d8a5ba45SMiklos Szeredi static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) 593d8a5ba45SMiklos Szeredi { 5946383bdaaSMiklos Szeredi return sb->s_fs_info; 595d8a5ba45SMiklos Szeredi } 596d8a5ba45SMiklos Szeredi 597d8a5ba45SMiklos Szeredi static inline struct fuse_conn *get_fuse_conn(struct inode *inode) 598d8a5ba45SMiklos Szeredi { 599d8a5ba45SMiklos Szeredi return get_fuse_conn_super(inode->i_sb); 600d8a5ba45SMiklos Szeredi } 601d8a5ba45SMiklos Szeredi 602d8a5ba45SMiklos Szeredi static inline struct fuse_inode *get_fuse_inode(struct inode *inode) 603d8a5ba45SMiklos Szeredi { 604d8a5ba45SMiklos Szeredi return container_of(inode, struct fuse_inode, inode); 605d8a5ba45SMiklos Szeredi } 606d8a5ba45SMiklos Szeredi 607d8a5ba45SMiklos Szeredi static inline u64 get_node_id(struct inode *inode) 608d8a5ba45SMiklos Szeredi { 609d8a5ba45SMiklos Szeredi return get_fuse_inode(inode)->nodeid; 610d8a5ba45SMiklos Szeredi } 611d8a5ba45SMiklos Szeredi 612334f485dSMiklos Szeredi /** Device operations */ 6134b6f5d20SArjan van de Ven extern const struct file_operations fuse_dev_operations; 614334f485dSMiklos Szeredi 6154269590aSAl Viro extern const struct dentry_operations fuse_dentry_operations; 616dbd561d2SMiklos Szeredi 617d8a5ba45SMiklos Szeredi /** 6183b463ae0SJohn Muir * Inode to nodeid comparison. 6193b463ae0SJohn Muir */ 6203b463ae0SJohn Muir int fuse_inode_eq(struct inode *inode, void *_nodeidp); 6213b463ae0SJohn Muir 6223b463ae0SJohn Muir /** 623e5e5558eSMiklos Szeredi * Get a filled in inode 624e5e5558eSMiklos Szeredi */ 625b48badf0SMiklos Szeredi struct inode *fuse_iget(struct super_block *sb, u64 nodeid, 6261fb69e78SMiklos Szeredi int generation, struct fuse_attr *attr, 6271fb69e78SMiklos Szeredi u64 attr_valid, u64 attr_version); 628e5e5558eSMiklos Szeredi 62933670fa2SMiklos Szeredi int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name, 63033670fa2SMiklos Szeredi struct fuse_entry_out *outarg, struct inode **inode); 63133670fa2SMiklos Szeredi 632e5e5558eSMiklos Szeredi /** 633e5e5558eSMiklos Szeredi * Send FORGET command 634e5e5558eSMiklos Szeredi */ 63507e77dcaSMiklos Szeredi void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, 636b48badf0SMiklos Szeredi u64 nodeid, u64 nlookup); 637e5e5558eSMiklos Szeredi 63807e77dcaSMiklos Szeredi struct fuse_forget_link *fuse_alloc_forget(void); 63907e77dcaSMiklos Szeredi 6400b05b183SAnand V. Avati /* Used by READDIRPLUS */ 6410b05b183SAnand V. Avati void fuse_force_forget(struct file *file, u64 nodeid); 6420b05b183SAnand V. Avati 643e5e5558eSMiklos Szeredi /** 644361b1eb5SMiklos Szeredi * Initialize READ or READDIR request 64504730fefSMiklos Szeredi */ 646a6643094SMiklos Szeredi void fuse_read_fill(struct fuse_req *req, struct file *file, 6472106cb18SMiklos Szeredi loff_t pos, size_t count, int opcode); 64804730fefSMiklos Szeredi 64904730fefSMiklos Szeredi /** 65004730fefSMiklos Szeredi * Send OPEN or OPENDIR request 65104730fefSMiklos Szeredi */ 65291fe96b4SMiklos Szeredi int fuse_open_common(struct inode *inode, struct file *file, bool isdir); 65304730fefSMiklos Szeredi 654acf99433STejun Heo struct fuse_file *fuse_file_alloc(struct fuse_conn *fc); 655c7b7143cSMiklos Szeredi struct fuse_file *fuse_file_get(struct fuse_file *ff); 656fd72faacSMiklos Szeredi void fuse_file_free(struct fuse_file *ff); 657c7b7143cSMiklos Szeredi void fuse_finish_open(struct inode *inode, struct file *file); 658fd72faacSMiklos Szeredi 6598b0797a4SMiklos Szeredi void fuse_sync_release(struct fuse_file *ff, int flags); 660c756e0a4SMiklos Szeredi 66104730fefSMiklos Szeredi /** 66204730fefSMiklos Szeredi * Send RELEASE or RELEASEDIR request 66304730fefSMiklos Szeredi */ 6648b0797a4SMiklos Szeredi void fuse_release_common(struct file *file, int opcode); 66504730fefSMiklos Szeredi 66604730fefSMiklos Szeredi /** 66782547981SMiklos Szeredi * Send FSYNC or FSYNCDIR request 66882547981SMiklos Szeredi */ 66902c24a82SJosef Bacik int fuse_fsync_common(struct file *file, loff_t start, loff_t end, 67002c24a82SJosef Bacik int datasync, int isdir); 67182547981SMiklos Szeredi 67282547981SMiklos Szeredi /** 67395668a69STejun Heo * Notify poll wakeup 67495668a69STejun Heo */ 67595668a69STejun Heo int fuse_notify_poll_wakeup(struct fuse_conn *fc, 67695668a69STejun Heo struct fuse_notify_poll_wakeup_out *outarg); 67795668a69STejun Heo 67895668a69STejun Heo /** 6791779381dSMiklos Szeredi * Initialize file operations on a regular file 680b6aeadedSMiklos Szeredi */ 681b6aeadedSMiklos Szeredi void fuse_init_file_inode(struct inode *inode); 682b6aeadedSMiklos Szeredi 683b6aeadedSMiklos Szeredi /** 6841779381dSMiklos Szeredi * Initialize inode operations on regular files and special files 685e5e5558eSMiklos Szeredi */ 686e5e5558eSMiklos Szeredi void fuse_init_common(struct inode *inode); 687e5e5558eSMiklos Szeredi 688e5e5558eSMiklos Szeredi /** 6891779381dSMiklos Szeredi * Initialize inode and file operations on a directory 690e5e5558eSMiklos Szeredi */ 691e5e5558eSMiklos Szeredi void fuse_init_dir(struct inode *inode); 692e5e5558eSMiklos Szeredi 693e5e5558eSMiklos Szeredi /** 6941779381dSMiklos Szeredi * Initialize inode operations on a symlink 695e5e5558eSMiklos Szeredi */ 696e5e5558eSMiklos Szeredi void fuse_init_symlink(struct inode *inode); 697e5e5558eSMiklos Szeredi 698e5e5558eSMiklos Szeredi /** 699e5e5558eSMiklos Szeredi * Change attributes of an inode 700e5e5558eSMiklos Szeredi */ 7011fb69e78SMiklos Szeredi void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, 7021fb69e78SMiklos Szeredi u64 attr_valid, u64 attr_version); 703e5e5558eSMiklos Szeredi 7043be5a52bSMiklos Szeredi void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, 7053be5a52bSMiklos Szeredi u64 attr_valid); 7063be5a52bSMiklos Szeredi 707e5e5558eSMiklos Szeredi /** 708334f485dSMiklos Szeredi * Initialize the client device 709334f485dSMiklos Szeredi */ 710334f485dSMiklos Szeredi int fuse_dev_init(void); 711334f485dSMiklos Szeredi 712334f485dSMiklos Szeredi /** 713334f485dSMiklos Szeredi * Cleanup the client device 714334f485dSMiklos Szeredi */ 715334f485dSMiklos Szeredi void fuse_dev_cleanup(void); 716334f485dSMiklos Szeredi 717bafa9654SMiklos Szeredi int fuse_ctl_init(void); 718bafa9654SMiklos Szeredi void fuse_ctl_cleanup(void); 719bafa9654SMiklos Szeredi 720334f485dSMiklos Szeredi /** 721334f485dSMiklos Szeredi * Allocate a request 722334f485dSMiklos Szeredi */ 7234250c066SMaxim Patlasov struct fuse_req *fuse_request_alloc(unsigned npages); 724334f485dSMiklos Szeredi 7254250c066SMaxim Patlasov struct fuse_req *fuse_request_alloc_nofs(unsigned npages); 7263be5a52bSMiklos Szeredi 727334f485dSMiklos Szeredi /** 728334f485dSMiklos Szeredi * Free a request 729334f485dSMiklos Szeredi */ 730334f485dSMiklos Szeredi void fuse_request_free(struct fuse_req *req); 731334f485dSMiklos Szeredi 732334f485dSMiklos Szeredi /** 733b111c8c0SMaxim Patlasov * Get a request, may fail with -ENOMEM, 734b111c8c0SMaxim Patlasov * caller should specify # elements in req->pages[] explicitly 735334f485dSMiklos Szeredi */ 736b111c8c0SMaxim Patlasov struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages); 7378b41e671SMaxim Patlasov struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc, 7388b41e671SMaxim Patlasov unsigned npages); 739b111c8c0SMaxim Patlasov 74036cf66edSMaxim Patlasov /* 74136cf66edSMaxim Patlasov * Increment reference count on request 74236cf66edSMaxim Patlasov */ 74336cf66edSMaxim Patlasov void __fuse_get_request(struct fuse_req *req); 74436cf66edSMaxim Patlasov 745b111c8c0SMaxim Patlasov /** 746b111c8c0SMaxim Patlasov * Get a request, may fail with -ENOMEM, 747b111c8c0SMaxim Patlasov * useful for callers who doesn't use req->pages[] 748b111c8c0SMaxim Patlasov */ 749b111c8c0SMaxim Patlasov static inline struct fuse_req *fuse_get_req_nopages(struct fuse_conn *fc) 750b111c8c0SMaxim Patlasov { 751b111c8c0SMaxim Patlasov return fuse_get_req(fc, 0); 752b111c8c0SMaxim Patlasov } 753334f485dSMiklos Szeredi 754334f485dSMiklos Szeredi /** 75533649c91SMiklos Szeredi * Gets a requests for a file operation, always succeeds 75633649c91SMiklos Szeredi */ 757b111c8c0SMaxim Patlasov struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc, 758b111c8c0SMaxim Patlasov struct file *file); 75933649c91SMiklos Szeredi 76033649c91SMiklos Szeredi /** 761ce1d5a49SMiklos Szeredi * Decrement reference count of a request. If count goes to zero free 762ce1d5a49SMiklos Szeredi * the request. 763334f485dSMiklos Szeredi */ 764334f485dSMiklos Szeredi void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req); 765334f485dSMiklos Szeredi 766334f485dSMiklos Szeredi /** 7677c352bdfSMiklos Szeredi * Send a request (synchronous) 768334f485dSMiklos Szeredi */ 769b93f858aSTejun Heo void fuse_request_send(struct fuse_conn *fc, struct fuse_req *req); 770334f485dSMiklos Szeredi 771334f485dSMiklos Szeredi /** 772334f485dSMiklos Szeredi * Send a request in the background 773334f485dSMiklos Szeredi */ 774b93f858aSTejun Heo void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req); 775334f485dSMiklos Szeredi 776b93f858aSTejun Heo void fuse_request_send_background_locked(struct fuse_conn *fc, 777b93f858aSTejun Heo struct fuse_req *req); 7783be5a52bSMiklos Szeredi 7795a5fb1eaSMiklos Szeredi /* Abort all requests */ 78069a53bf2SMiklos Szeredi void fuse_abort_conn(struct fuse_conn *fc); 78169a53bf2SMiklos Szeredi 7821e9a4ed9SMiklos Szeredi /** 783e5e5558eSMiklos Szeredi * Invalidate inode attributes 784e5e5558eSMiklos Szeredi */ 785e5e5558eSMiklos Szeredi void fuse_invalidate_attr(struct inode *inode); 786bafa9654SMiklos Szeredi 787dbd561d2SMiklos Szeredi void fuse_invalidate_entry_cache(struct dentry *entry); 788dbd561d2SMiklos Szeredi 789bafa9654SMiklos Szeredi /** 790bafa9654SMiklos Szeredi * Acquire reference to fuse_conn 791bafa9654SMiklos Szeredi */ 792bafa9654SMiklos Szeredi struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); 793bafa9654SMiklos Szeredi 79408cbf542STejun Heo void fuse_conn_kill(struct fuse_conn *fc); 79508cbf542STejun Heo 796bafa9654SMiklos Szeredi /** 7970d179aa5STejun Heo * Initialize fuse_conn 7980d179aa5STejun Heo */ 799a325f9b9STejun Heo void fuse_conn_init(struct fuse_conn *fc); 8000d179aa5STejun Heo 8010d179aa5STejun Heo /** 802bafa9654SMiklos Szeredi * Release reference to fuse_conn 803bafa9654SMiklos Szeredi */ 804bafa9654SMiklos Szeredi void fuse_conn_put(struct fuse_conn *fc); 805bafa9654SMiklos Szeredi 806bafa9654SMiklos Szeredi /** 807bafa9654SMiklos Szeredi * Add connection to control filesystem 808bafa9654SMiklos Szeredi */ 809bafa9654SMiklos Szeredi int fuse_ctl_add_conn(struct fuse_conn *fc); 810bafa9654SMiklos Szeredi 811bafa9654SMiklos Szeredi /** 812bafa9654SMiklos Szeredi * Remove connection from control filesystem 813bafa9654SMiklos Szeredi */ 814bafa9654SMiklos Szeredi void fuse_ctl_remove_conn(struct fuse_conn *fc); 815a5bfffacSTimo Savola 816a5bfffacSTimo Savola /** 817a5bfffacSTimo Savola * Is file type valid? 818a5bfffacSTimo Savola */ 819a5bfffacSTimo Savola int fuse_valid_type(int m); 820e57ac683SMiklos Szeredi 821e57ac683SMiklos Szeredi /** 822c2132c1bSAnatol Pomozov * Is current process allowed to perform filesystem operation? 823e57ac683SMiklos Szeredi */ 824c2132c1bSAnatol Pomozov int fuse_allow_current_process(struct fuse_conn *fc); 825f3332114SMiklos Szeredi 826f3332114SMiklos Szeredi u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id); 827bcb4be80SMiklos Szeredi 828bcb4be80SMiklos Szeredi int fuse_update_attributes(struct inode *inode, struct kstat *stat, 829bcb4be80SMiklos Szeredi struct file *file, bool *refreshed); 8303be5a52bSMiklos Szeredi 8313be5a52bSMiklos Szeredi void fuse_flush_writepages(struct inode *inode); 8323be5a52bSMiklos Szeredi 8333be5a52bSMiklos Szeredi void fuse_set_nowrite(struct inode *inode); 8343be5a52bSMiklos Szeredi void fuse_release_nowrite(struct inode *inode); 8355c5c5e51SMiklos Szeredi 8365c5c5e51SMiklos Szeredi u64 fuse_get_attr_version(struct fuse_conn *fc); 83729d434b3STejun Heo 8383b463ae0SJohn Muir /** 8393b463ae0SJohn Muir * File-system tells the kernel to invalidate cache for the given node id. 8403b463ae0SJohn Muir */ 8413b463ae0SJohn Muir int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid, 8423b463ae0SJohn Muir loff_t offset, loff_t len); 8433b463ae0SJohn Muir 8443b463ae0SJohn Muir /** 8453b463ae0SJohn Muir * File-system tells the kernel to invalidate parent attributes and 8463b463ae0SJohn Muir * the dentry matching parent/name. 847451d0f59SJohn Muir * 848451d0f59SJohn Muir * If the child_nodeid is non-zero and: 849451d0f59SJohn Muir * - matches the inode number for the dentry matching parent/name, 850451d0f59SJohn Muir * - is not a mount point 851451d0f59SJohn Muir * - is a file or oan empty directory 852451d0f59SJohn Muir * then the dentry is unhashed (d_delete()). 8533b463ae0SJohn Muir */ 8543b463ae0SJohn Muir int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid, 855451d0f59SJohn Muir u64 child_nodeid, struct qstr *name); 8563b463ae0SJohn Muir 85708cbf542STejun Heo int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file, 85808cbf542STejun Heo bool isdir); 85936cf66edSMaxim Patlasov ssize_t fuse_direct_io(struct fuse_io_priv *io, const struct iovec *iov, 860fb05f41fSMiklos Szeredi unsigned long nr_segs, size_t count, loff_t *ppos, 861fb05f41fSMiklos Szeredi int write); 86208cbf542STejun Heo long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, 86308cbf542STejun Heo unsigned int flags); 864b18da0c5SMiklos Szeredi long fuse_ioctl_common(struct file *file, unsigned int cmd, 865b18da0c5SMiklos Szeredi unsigned long arg, unsigned int flags); 86608cbf542STejun Heo unsigned fuse_file_poll(struct file *file, poll_table *wait); 86708cbf542STejun Heo int fuse_dev_release(struct inode *inode, struct file *file); 86808cbf542STejun Heo 869a1d75f25SMiklos Szeredi void fuse_write_update_size(struct inode *inode, loff_t pos); 870a1d75f25SMiklos Szeredi 871efb9fa9eSMaxim Patlasov int fuse_do_setattr(struct inode *inode, struct iattr *attr, 872efb9fa9eSMaxim Patlasov struct file *file); 873efb9fa9eSMaxim Patlasov 87429d434b3STejun Heo #endif /* _FS_FUSE_I_H */ 875