fuse_i.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. /*
  2. FUSE: Filesystem in Userspace
  3. Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
  4. This program can be distributed under the terms of the GNU GPL.
  5. See the file COPYING.
  6. */
  7. #ifndef _FS_FUSE_I_H
  8. #define _FS_FUSE_I_H
  9. #include <linux/fuse.h>
  10. #include <linux/fs.h>
  11. #include <linux/mount.h>
  12. #include <linux/wait.h>
  13. #include <linux/list.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/mm.h>
  16. #include <linux/backing-dev.h>
  17. #include <linux/mutex.h>
  18. #include <linux/rwsem.h>
  19. #include <linux/rbtree.h>
  20. #include <linux/poll.h>
  21. #include <linux/workqueue.h>
  22. /** Max number of pages that can be used in a single read request */
  23. #define FUSE_MAX_PAGES_PER_REQ 32
  24. /** Bias for fi->writectr, meaning new writepages must not be sent */
  25. #define FUSE_NOWRITE INT_MIN
  26. /** It could be as large as PATH_MAX, but would that have any uses? */
  27. #define FUSE_NAME_MAX 1024
  28. /** Number of dentries for each connection in the control filesystem */
  29. #define FUSE_CTL_NUM_DENTRIES 5
  30. /** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
  31. module will check permissions based on the file mode. Otherwise no
  32. permission checking is done in the kernel */
  33. #define FUSE_DEFAULT_PERMISSIONS (1 << 0)
  34. /** If the FUSE_ALLOW_OTHER flag is given, then not only the user
  35. doing the mount will be allowed to access the filesystem */
  36. #define FUSE_ALLOW_OTHER (1 << 1)
  37. /** Number of page pointers embedded in fuse_req */
  38. #define FUSE_REQ_INLINE_PAGES 1
  39. /** List of active connections */
  40. extern struct list_head fuse_conn_list;
  41. /** Global mutex protecting fuse_conn_list and the control filesystem */
  42. extern struct mutex fuse_mutex;
  43. /** Module parameters */
  44. extern unsigned max_user_bgreq;
  45. extern unsigned max_user_congthresh;
  46. /* One forget request */
  47. struct fuse_forget_link {
  48. struct fuse_forget_one forget_one;
  49. struct fuse_forget_link *next;
  50. };
  51. /** FUSE inode */
  52. struct fuse_inode {
  53. /** Inode data */
  54. struct inode inode;
  55. /** Unique ID, which identifies the inode between userspace
  56. * and kernel */
  57. u64 nodeid;
  58. /** Number of lookups on this inode */
  59. u64 nlookup;
  60. /** The request used for sending the FORGET message */
  61. struct fuse_forget_link *forget;
  62. /** Time in jiffies until the file attributes are valid */
  63. u64 i_time;
  64. /** The sticky bit in inode->i_mode may have been removed, so
  65. preserve the original mode */
  66. umode_t orig_i_mode;
  67. /** 64 bit inode number */
  68. u64 orig_ino;
  69. /** Version of last attribute change */
  70. u64 attr_version;
  71. /** Files usable in writepage. Protected by fc->lock */
  72. struct list_head write_files;
  73. /** Writepages pending on truncate or fsync */
  74. struct list_head queued_writes;
  75. /** Number of sent writes, a negative bias (FUSE_NOWRITE)
  76. * means more writes are blocked */
  77. int writectr;
  78. /** Waitq for writepage completion */
  79. wait_queue_head_t page_waitq;
  80. /** List of writepage requestst (pending or sent) */
  81. struct list_head writepages;
  82. /** Miscellaneous bits describing inode state */
  83. unsigned long state;
  84. };
  85. /** FUSE inode state bits */
  86. enum {
  87. /** Advise readdirplus */
  88. FUSE_I_ADVISE_RDPLUS,
  89. /** Initialized with readdirplus */
  90. FUSE_I_INIT_RDPLUS,
  91. /** An operation changing file size is in progress */
  92. FUSE_I_SIZE_UNSTABLE,
  93. };
  94. struct fuse_conn;
  95. /** FUSE specific file data */
  96. struct fuse_file {
  97. /** Fuse connection for this file */
  98. struct fuse_conn *fc;
  99. /** Request reserved for flush and release */
  100. struct fuse_req *reserved_req;
  101. /** Kernel file handle guaranteed to be unique */
  102. u64 kh;
  103. /** File handle used by userspace */
  104. u64 fh;
  105. /** Node id of this file */
  106. u64 nodeid;
  107. /** Refcount */
  108. atomic_t count;
  109. /** FOPEN_* flags returned by open */
  110. u32 open_flags;
  111. /** Entry on inode's write_files list */
  112. struct list_head write_entry;
  113. /** RB node to be linked on fuse_conn->polled_files */
  114. struct rb_node polled_node;
  115. /** Wait queue head for poll */
  116. wait_queue_head_t poll_wait;
  117. /** Has flock been performed on this file? */
  118. bool flock:1;
  119. };
  120. /** One input argument of a request */
  121. struct fuse_in_arg {
  122. unsigned size;
  123. const void *value;
  124. };
  125. /** The request input */
  126. struct fuse_in {
  127. /** The request header */
  128. struct fuse_in_header h;
  129. /** True if the data for the last argument is in req->pages */
  130. unsigned argpages:1;
  131. /** Number of arguments */
  132. unsigned numargs;
  133. /** Array of arguments */
  134. struct fuse_in_arg args[3];
  135. };
  136. /** One output argument of a request */
  137. struct fuse_arg {
  138. unsigned size;
  139. void *value;
  140. };
  141. /** The request output */
  142. struct fuse_out {
  143. /** Header returned from userspace */
  144. struct fuse_out_header h;
  145. /*
  146. * The following bitfields are not changed during the request
  147. * processing
  148. */
  149. /** Last argument is variable length (can be shorter than
  150. arg->size) */
  151. unsigned argvar:1;
  152. /** Last argument is a list of pages to copy data to */
  153. unsigned argpages:1;
  154. /** Zero partially or not copied pages */
  155. unsigned page_zeroing:1;
  156. /** Pages may be replaced with new ones */
  157. unsigned page_replace:1;
  158. /** Number or arguments */
  159. unsigned numargs;
  160. /** Array of arguments */
  161. struct fuse_arg args[2];
  162. };
  163. /** FUSE page descriptor */
  164. struct fuse_page_desc {
  165. unsigned int length;
  166. unsigned int offset;
  167. };
  168. struct fuse_args {
  169. struct {
  170. struct {
  171. uint32_t opcode;
  172. uint64_t nodeid;
  173. } h;
  174. unsigned numargs;
  175. struct fuse_in_arg args[3];
  176. } in;
  177. struct {
  178. unsigned argvar:1;
  179. unsigned numargs;
  180. struct fuse_arg args[2];
  181. } out;
  182. };
  183. #define FUSE_ARGS(args) struct fuse_args args = {}
  184. /** The request IO state (for asynchronous processing) */
  185. struct fuse_io_priv {
  186. int async;
  187. spinlock_t lock;
  188. unsigned reqs;
  189. ssize_t bytes;
  190. size_t size;
  191. __u64 offset;
  192. bool write;
  193. int err;
  194. struct kiocb *iocb;
  195. struct file *file;
  196. struct completion *done;
  197. };
  198. /**
  199. * Request flags
  200. *
  201. * FR_ISREPLY: set if the request has reply
  202. * FR_FORCE: force sending of the request even if interrupted
  203. * FR_BACKGROUND: request is sent in the background
  204. * FR_WAITING: request is counted as "waiting"
  205. * FR_ABORTED: the request was aborted
  206. * FR_INTERRUPTED: the request has been interrupted
  207. * FR_LOCKED: data is being copied to/from the request
  208. * FR_PENDING: request is not yet in userspace
  209. * FR_SENT: request is in userspace, waiting for an answer
  210. * FR_FINISHED: request is finished
  211. * FR_PRIVATE: request is on private list
  212. */
  213. enum fuse_req_flag {
  214. FR_ISREPLY,
  215. FR_FORCE,
  216. FR_BACKGROUND,
  217. FR_WAITING,
  218. FR_ABORTED,
  219. FR_INTERRUPTED,
  220. FR_LOCKED,
  221. FR_PENDING,
  222. FR_SENT,
  223. FR_FINISHED,
  224. FR_PRIVATE,
  225. };
  226. /**
  227. * A request to the client
  228. *
  229. * .waitq.lock protects the following fields:
  230. * - FR_ABORTED
  231. * - FR_LOCKED (may also be modified under fc->lock, tested under both)
  232. */
  233. struct fuse_req {
  234. /** This can be on either pending processing or io lists in
  235. fuse_conn */
  236. struct list_head list;
  237. /** Entry on the interrupts list */
  238. struct list_head intr_entry;
  239. /** refcount */
  240. atomic_t count;
  241. /** Unique ID for the interrupt request */
  242. u64 intr_unique;
  243. /* Request flags, updated with test/set/clear_bit() */
  244. unsigned long flags;
  245. /** The request input */
  246. struct fuse_in in;
  247. /** The request output */
  248. struct fuse_out out;
  249. /** Used to wake up the task waiting for completion of request*/
  250. wait_queue_head_t waitq;
  251. /** Data for asynchronous requests */
  252. union {
  253. struct {
  254. struct fuse_release_in in;
  255. struct inode *inode;
  256. } release;
  257. struct fuse_init_in init_in;
  258. struct fuse_init_out init_out;
  259. struct cuse_init_in cuse_init_in;
  260. struct {
  261. struct fuse_read_in in;
  262. u64 attr_ver;
  263. } read;
  264. struct {
  265. struct fuse_write_in in;
  266. struct fuse_write_out out;
  267. struct fuse_req *next;
  268. } write;
  269. struct fuse_notify_retrieve_in retrieve_in;
  270. } misc;
  271. /** page vector */
  272. struct page **pages;
  273. /** page-descriptor vector */
  274. struct fuse_page_desc *page_descs;
  275. /** size of the 'pages' array */
  276. unsigned max_pages;
  277. /** inline page vector */
  278. struct page *inline_pages[FUSE_REQ_INLINE_PAGES];
  279. /** inline page-descriptor vector */
  280. struct fuse_page_desc inline_page_descs[FUSE_REQ_INLINE_PAGES];
  281. /** number of pages in vector */
  282. unsigned num_pages;
  283. /** File used in the request (or NULL) */
  284. struct fuse_file *ff;
  285. /** Inode used in the request or NULL */
  286. struct inode *inode;
  287. /** AIO control block */
  288. struct fuse_io_priv *io;
  289. /** Link on fi->writepages */
  290. struct list_head writepages_entry;
  291. /** Request completion callback */
  292. void (*end)(struct fuse_conn *, struct fuse_req *);
  293. /** Request is stolen from fuse_file->reserved_req */
  294. struct file *stolen_file;
  295. };
  296. struct fuse_iqueue {
  297. /** Connection established */
  298. unsigned connected;
  299. /** Readers of the connection are waiting on this */
  300. wait_queue_head_t waitq;
  301. /** The next unique request id */
  302. u64 reqctr;
  303. /** The list of pending requests */
  304. struct list_head pending;
  305. /** Pending interrupts */
  306. struct list_head interrupts;
  307. /** Queue of pending forgets */
  308. struct fuse_forget_link forget_list_head;
  309. struct fuse_forget_link *forget_list_tail;
  310. /** Batching of FORGET requests (positive indicates FORGET batch) */
  311. int forget_batch;
  312. /** O_ASYNC requests */
  313. struct fasync_struct *fasync;
  314. };
  315. struct fuse_pqueue {
  316. /** Connection established */
  317. unsigned connected;
  318. /** Lock protecting accessess to members of this structure */
  319. spinlock_t lock;
  320. /** The list of requests being processed */
  321. struct list_head processing;
  322. /** The list of requests under I/O */
  323. struct list_head io;
  324. };
  325. /**
  326. * Fuse device instance
  327. */
  328. struct fuse_dev {
  329. /** Fuse connection for this device */
  330. struct fuse_conn *fc;
  331. /** Processing queue */
  332. struct fuse_pqueue pq;
  333. /** list entry on fc->devices */
  334. struct list_head entry;
  335. };
  336. /**
  337. * A Fuse connection.
  338. *
  339. * This structure is created, when the filesystem is mounted, and is
  340. * destroyed, when the client device is closed and the filesystem is
  341. * unmounted.
  342. */
  343. struct fuse_conn {
  344. /** Lock protecting accessess to members of this structure */
  345. spinlock_t lock;
  346. /** Refcount */
  347. atomic_t count;
  348. /** Number of fuse_dev's */
  349. atomic_t dev_count;
  350. struct rcu_head rcu;
  351. /** The user id for this mount */
  352. kuid_t user_id;
  353. /** The group id for this mount */
  354. kgid_t group_id;
  355. /** The fuse mount flags for this mount */
  356. unsigned flags;
  357. /** Maximum read size */
  358. unsigned max_read;
  359. /** Maximum write size */
  360. unsigned max_write;
  361. /** Input queue */
  362. struct fuse_iqueue iq;
  363. /** The next unique kernel file handle */
  364. u64 khctr;
  365. /** rbtree of fuse_files waiting for poll events indexed by ph */
  366. struct rb_root polled_files;
  367. /** Maximum number of outstanding background requests */
  368. unsigned max_background;
  369. /** Number of background requests at which congestion starts */
  370. unsigned congestion_threshold;
  371. /** Number of requests currently in the background */
  372. unsigned num_background;
  373. /** Number of background requests currently queued for userspace */
  374. unsigned active_background;
  375. /** The list of background requests set aside for later queuing */
  376. struct list_head bg_queue;
  377. /** Flag indicating that INIT reply has been received. Allocating
  378. * any fuse request will be suspended until the flag is set */
  379. int initialized;
  380. /** Flag indicating if connection is blocked. This will be
  381. the case before the INIT reply is received, and if there
  382. are too many outstading backgrounds requests */
  383. int blocked;
  384. /** waitq for blocked connection */
  385. wait_queue_head_t blocked_waitq;
  386. /** waitq for reserved requests */
  387. wait_queue_head_t reserved_req_waitq;
  388. /** Connection established, cleared on umount, connection
  389. abort and device release */
  390. unsigned connected;
  391. /** Connection failed (version mismatch). Cannot race with
  392. setting other bitfields since it is only set once in INIT
  393. reply, before any other request, and never cleared */
  394. unsigned conn_error:1;
  395. /** Connection successful. Only set in INIT */
  396. unsigned conn_init:1;
  397. /** Do readpages asynchronously? Only set in INIT */
  398. unsigned async_read:1;
  399. /** Do not send separate SETATTR request before open(O_TRUNC) */
  400. unsigned atomic_o_trunc:1;
  401. /** Filesystem supports NFS exporting. Only set in INIT */
  402. unsigned export_support:1;
  403. /** Set if bdi is valid */
  404. unsigned bdi_initialized:1;
  405. /** write-back cache policy (default is write-through) */
  406. unsigned writeback_cache:1;
  407. /*
  408. * The following bitfields are only for optimization purposes
  409. * and hence races in setting them will not cause malfunction
  410. */
  411. /** Is open/release not implemented by fs? */
  412. unsigned no_open:1;
  413. /** Is fsync not implemented by fs? */
  414. unsigned no_fsync:1;
  415. /** Is fsyncdir not implemented by fs? */
  416. unsigned no_fsyncdir:1;
  417. /** Is flush not implemented by fs? */
  418. unsigned no_flush:1;
  419. /** Is setxattr not implemented by fs? */
  420. unsigned no_setxattr:1;
  421. /** Is getxattr not implemented by fs? */
  422. unsigned no_getxattr:1;
  423. /** Is listxattr not implemented by fs? */
  424. unsigned no_listxattr:1;
  425. /** Is removexattr not implemented by fs? */
  426. unsigned no_removexattr:1;
  427. /** Are posix file locking primitives not implemented by fs? */
  428. unsigned no_lock:1;
  429. /** Is access not implemented by fs? */
  430. unsigned no_access:1;
  431. /** Is create not implemented by fs? */
  432. unsigned no_create:1;
  433. /** Is interrupt not implemented by fs? */
  434. unsigned no_interrupt:1;
  435. /** Is bmap not implemented by fs? */
  436. unsigned no_bmap:1;
  437. /** Is poll not implemented by fs? */
  438. unsigned no_poll:1;
  439. /** Do multi-page cached writes */
  440. unsigned big_writes:1;
  441. /** Don't apply umask to creation modes */
  442. unsigned dont_mask:1;
  443. /** Are BSD file locking primitives not implemented by fs? */
  444. unsigned no_flock:1;
  445. /** Is fallocate not implemented by fs? */
  446. unsigned no_fallocate:1;
  447. /** Is rename with flags implemented by fs? */
  448. unsigned no_rename2:1;
  449. /** Use enhanced/automatic page cache invalidation. */
  450. unsigned auto_inval_data:1;
  451. /** Does the filesystem support readdirplus? */
  452. unsigned do_readdirplus:1;
  453. /** Does the filesystem want adaptive readdirplus? */
  454. unsigned readdirplus_auto:1;
  455. /** Does the filesystem support asynchronous direct-IO submission? */
  456. unsigned async_dio:1;
  457. /** The number of requests waiting for completion */
  458. atomic_t num_waiting;
  459. /** Negotiated minor version */
  460. unsigned minor;
  461. /** Backing dev info */
  462. struct backing_dev_info bdi;
  463. /** Entry on the fuse_conn_list */
  464. struct list_head entry;
  465. /** Device ID from super block */
  466. dev_t dev;
  467. /** Dentries in the control filesystem */
  468. struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
  469. /** number of dentries used in the above array */
  470. int ctl_ndents;
  471. /** Key for lock owner ID scrambling */
  472. u32 scramble_key[4];
  473. /** Reserved request for the DESTROY message */
  474. struct fuse_req *destroy_req;
  475. /** Version counter for attribute changes */
  476. u64 attr_version;
  477. /** Called on final put */
  478. void (*release)(struct fuse_conn *);
  479. /** Super block for this connection. */
  480. struct super_block *sb;
  481. /** Read/write semaphore to hold when accessing sb. */
  482. struct rw_semaphore killsb;
  483. /** List of device instances belonging to this connection */
  484. struct list_head devices;
  485. };
  486. static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
  487. {
  488. return sb->s_fs_info;
  489. }
  490. static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
  491. {
  492. return get_fuse_conn_super(inode->i_sb);
  493. }
  494. static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
  495. {
  496. return container_of(inode, struct fuse_inode, inode);
  497. }
  498. static inline u64 get_node_id(struct inode *inode)
  499. {
  500. return get_fuse_inode(inode)->nodeid;
  501. }
  502. /** Device operations */
  503. extern const struct file_operations fuse_dev_operations;
  504. extern const struct dentry_operations fuse_dentry_operations;
  505. /**
  506. * Inode to nodeid comparison.
  507. */
  508. int fuse_inode_eq(struct inode *inode, void *_nodeidp);
  509. /**
  510. * Get a filled in inode
  511. */
  512. struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
  513. int generation, struct fuse_attr *attr,
  514. u64 attr_valid, u64 attr_version);
  515. int fuse_lookup_name(struct super_block *sb, u64 nodeid, struct qstr *name,
  516. struct fuse_entry_out *outarg, struct inode **inode);
  517. /**
  518. * Send FORGET command
  519. */
  520. void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
  521. u64 nodeid, u64 nlookup);
  522. struct fuse_forget_link *fuse_alloc_forget(void);
  523. /* Used by READDIRPLUS */
  524. void fuse_force_forget(struct file *file, u64 nodeid);
  525. /**
  526. * Initialize READ or READDIR request
  527. */
  528. void fuse_read_fill(struct fuse_req *req, struct file *file,
  529. loff_t pos, size_t count, int opcode);
  530. /**
  531. * Send OPEN or OPENDIR request
  532. */
  533. int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
  534. struct fuse_file *fuse_file_alloc(struct fuse_conn *fc);
  535. struct fuse_file *fuse_file_get(struct fuse_file *ff);
  536. void fuse_file_free(struct fuse_file *ff);
  537. void fuse_finish_open(struct inode *inode, struct file *file);
  538. void fuse_sync_release(struct fuse_file *ff, int flags);
  539. /**
  540. * Send RELEASE or RELEASEDIR request
  541. */
  542. void fuse_release_common(struct file *file, int opcode);
  543. /**
  544. * Send FSYNC or FSYNCDIR request
  545. */
  546. int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
  547. int datasync, int isdir);
  548. /**
  549. * Notify poll wakeup
  550. */
  551. int fuse_notify_poll_wakeup(struct fuse_conn *fc,
  552. struct fuse_notify_poll_wakeup_out *outarg);
  553. /**
  554. * Initialize file operations on a regular file
  555. */
  556. void fuse_init_file_inode(struct inode *inode);
  557. /**
  558. * Initialize inode operations on regular files and special files
  559. */
  560. void fuse_init_common(struct inode *inode);
  561. /**
  562. * Initialize inode and file operations on a directory
  563. */
  564. void fuse_init_dir(struct inode *inode);
  565. /**
  566. * Initialize inode operations on a symlink
  567. */
  568. void fuse_init_symlink(struct inode *inode);
  569. /**
  570. * Change attributes of an inode
  571. */
  572. void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
  573. u64 attr_valid, u64 attr_version);
  574. void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
  575. u64 attr_valid);
  576. /**
  577. * Initialize the client device
  578. */
  579. int fuse_dev_init(void);
  580. /**
  581. * Cleanup the client device
  582. */
  583. void fuse_dev_cleanup(void);
  584. int fuse_ctl_init(void);
  585. void __exit fuse_ctl_cleanup(void);
  586. /**
  587. * Allocate a request
  588. */
  589. struct fuse_req *fuse_request_alloc(unsigned npages);
  590. struct fuse_req *fuse_request_alloc_nofs(unsigned npages);
  591. /**
  592. * Free a request
  593. */
  594. void fuse_request_free(struct fuse_req *req);
  595. /**
  596. * Get a request, may fail with -ENOMEM,
  597. * caller should specify # elements in req->pages[] explicitly
  598. */
  599. struct fuse_req *fuse_get_req(struct fuse_conn *fc, unsigned npages);
  600. struct fuse_req *fuse_get_req_for_background(struct fuse_conn *fc,
  601. unsigned npages);
  602. /*
  603. * Increment reference count on request
  604. */
  605. void __fuse_get_request(struct fuse_req *req);
  606. /**
  607. * Gets a requests for a file operation, always succeeds
  608. */
  609. struct fuse_req *fuse_get_req_nofail_nopages(struct fuse_conn *fc,
  610. struct file *file);
  611. /**
  612. * Decrement reference count of a request. If count goes to zero free
  613. * the request.
  614. */
  615. void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req);
  616. /**
  617. * Send a request (synchronous)
  618. */
  619. void fuse_request_send(struct fuse_conn *fc, struct fuse_req *req);
  620. /**
  621. * Simple request sending that does request allocation and freeing
  622. */
  623. ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args);
  624. /**
  625. * Send a request in the background
  626. */
  627. void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req);
  628. void fuse_request_send_background_locked(struct fuse_conn *fc,
  629. struct fuse_req *req);
  630. /* Abort all requests */
  631. void fuse_abort_conn(struct fuse_conn *fc);
  632. /**
  633. * Invalidate inode attributes
  634. */
  635. void fuse_invalidate_attr(struct inode *inode);
  636. void fuse_invalidate_entry_cache(struct dentry *entry);
  637. void fuse_invalidate_atime(struct inode *inode);
  638. /**
  639. * Acquire reference to fuse_conn
  640. */
  641. struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
  642. /**
  643. * Initialize fuse_conn
  644. */
  645. void fuse_conn_init(struct fuse_conn *fc);
  646. /**
  647. * Release reference to fuse_conn
  648. */
  649. void fuse_conn_put(struct fuse_conn *fc);
  650. struct fuse_dev *fuse_dev_alloc(struct fuse_conn *fc);
  651. void fuse_dev_free(struct fuse_dev *fud);
  652. /**
  653. * Add connection to control filesystem
  654. */
  655. int fuse_ctl_add_conn(struct fuse_conn *fc);
  656. /**
  657. * Remove connection from control filesystem
  658. */
  659. void fuse_ctl_remove_conn(struct fuse_conn *fc);
  660. /**
  661. * Is file type valid?
  662. */
  663. int fuse_valid_type(int m);
  664. /**
  665. * Is current process allowed to perform filesystem operation?
  666. */
  667. int fuse_allow_current_process(struct fuse_conn *fc);
  668. u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
  669. int fuse_update_attributes(struct inode *inode, struct kstat *stat,
  670. struct file *file, bool *refreshed);
  671. void fuse_flush_writepages(struct inode *inode);
  672. void fuse_set_nowrite(struct inode *inode);
  673. void fuse_release_nowrite(struct inode *inode);
  674. u64 fuse_get_attr_version(struct fuse_conn *fc);
  675. /**
  676. * File-system tells the kernel to invalidate cache for the given node id.
  677. */
  678. int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
  679. loff_t offset, loff_t len);
  680. /**
  681. * File-system tells the kernel to invalidate parent attributes and
  682. * the dentry matching parent/name.
  683. *
  684. * If the child_nodeid is non-zero and:
  685. * - matches the inode number for the dentry matching parent/name,
  686. * - is not a mount point
  687. * - is a file or oan empty directory
  688. * then the dentry is unhashed (d_delete()).
  689. */
  690. int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
  691. u64 child_nodeid, struct qstr *name);
  692. int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
  693. bool isdir);
  694. /**
  695. * fuse_direct_io() flags
  696. */
  697. /** If set, it is WRITE; otherwise - READ */
  698. #define FUSE_DIO_WRITE (1 << 0)
  699. /** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */
  700. #define FUSE_DIO_CUSE (1 << 1)
  701. ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
  702. loff_t *ppos, int flags);
  703. long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
  704. unsigned int flags);
  705. long fuse_ioctl_common(struct file *file, unsigned int cmd,
  706. unsigned long arg, unsigned int flags);
  707. unsigned fuse_file_poll(struct file *file, poll_table *wait);
  708. int fuse_dev_release(struct inode *inode, struct file *file);
  709. bool fuse_write_update_size(struct inode *inode, loff_t pos);
  710. int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
  711. int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
  712. int fuse_do_setattr(struct inode *inode, struct iattr *attr,
  713. struct file *file);
  714. void fuse_set_initialized(struct fuse_conn *fc);
  715. #endif /* _FS_FUSE_I_H */