xref: /openbmc/linux/fs/fuse/fuse_i.h (revision 24754db2728a87c513cc480c70c09072a7a40ba6)
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 
12f2294482SKirill Smelkov #ifndef pr_fmt
13f2294482SKirill Smelkov # define pr_fmt(fmt) "fuse: " fmt
14f2294482SKirill Smelkov #endif
15f2294482SKirill Smelkov 
16d8a5ba45SMiklos Szeredi #include <linux/fuse.h>
17d8a5ba45SMiklos Szeredi #include <linux/fs.h>
1851eb01e7SMiklos Szeredi #include <linux/mount.h>
19d8a5ba45SMiklos Szeredi #include <linux/wait.h>
20d8a5ba45SMiklos Szeredi #include <linux/list.h>
21d8a5ba45SMiklos Szeredi #include <linux/spinlock.h>
22d8a5ba45SMiklos Szeredi #include <linux/mm.h>
23d8a5ba45SMiklos Szeredi #include <linux/backing-dev.h>
24bafa9654SMiklos Szeredi #include <linux/mutex.h>
253be5a52bSMiklos Szeredi #include <linux/rwsem.h>
2695668a69STejun Heo #include <linux/rbtree.h>
2795668a69STejun Heo #include <linux/poll.h>
285a18ec17SMiklos Szeredi #include <linux/workqueue.h>
29744742d6SSeth Forshee #include <linux/kref.h>
3060bcc88aSSeth Forshee #include <linux/xattr.h>
310b6e9ea0SSeth Forshee #include <linux/pid_namespace.h>
324e8c2eb5SElena Reshetova #include <linux/refcount.h>
338cb08329SEric W. Biederman #include <linux/user_namespace.h>
34d8a5ba45SMiklos Szeredi 
355da784ccSConstantine Shulyupin /** Default max number of pages that can be used in a single read request */
365da784ccSConstantine Shulyupin #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
375da784ccSConstantine Shulyupin 
385da784ccSConstantine Shulyupin /** Maximum of max_pages received in init_out */
395da784ccSConstantine Shulyupin #define FUSE_MAX_MAX_PAGES 256
40334f485dSMiklos Szeredi 
413be5a52bSMiklos Szeredi /** Bias for fi->writectr, meaning new writepages must not be sent */
423be5a52bSMiklos Szeredi #define FUSE_NOWRITE INT_MIN
433be5a52bSMiklos Szeredi 
441d3d752bSMiklos Szeredi /** It could be as large as PATH_MAX, but would that have any uses? */
451d3d752bSMiklos Szeredi #define FUSE_NAME_MAX 1024
461d3d752bSMiklos Szeredi 
47bafa9654SMiklos Szeredi /** Number of dentries for each connection in the control filesystem */
4879a9d994SCsaba Henk #define FUSE_CTL_NUM_DENTRIES 5
49bafa9654SMiklos Szeredi 
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 
842f1e8196SMiklos Szeredi 	/* Which attributes are invalid */
852f1e8196SMiklos Szeredi 	u32 inval_mask;
862f1e8196SMiklos Szeredi 
87ebc14c4dSMiklos Szeredi 	/** The sticky bit in inode->i_mode may have been removed, so
88ebc14c4dSMiklos Szeredi 	    preserve the original mode */
89541af6a0SAl Viro 	umode_t orig_i_mode;
901fb69e78SMiklos Szeredi 
9145c72cd7SPavel Shilovsky 	/** 64 bit inode number */
9245c72cd7SPavel Shilovsky 	u64 orig_ino;
9345c72cd7SPavel Shilovsky 
941fb69e78SMiklos Szeredi 	/** Version of last attribute change */
951fb69e78SMiklos Szeredi 	u64 attr_version;
9693a8c3cdSMiklos Szeredi 
97ab2257e9SMiklos Szeredi 	union {
98ab2257e9SMiklos Szeredi 		/* Write related fields (regular file only) */
99ab2257e9SMiklos Szeredi 		struct {
100f15ecfefSKirill Tkhai 			/* Files usable in writepage.  Protected by fi->lock */
10193a8c3cdSMiklos Szeredi 			struct list_head write_files;
1023be5a52bSMiklos Szeredi 
103ab2257e9SMiklos Szeredi 			/* Writepages pending on truncate or fsync */
1043be5a52bSMiklos Szeredi 			struct list_head queued_writes;
1053be5a52bSMiklos Szeredi 
106ab2257e9SMiklos Szeredi 			/* Number of sent writes, a negative bias
107ab2257e9SMiklos Szeredi 			 * (FUSE_NOWRITE) means more writes are blocked */
1083be5a52bSMiklos Szeredi 			int writectr;
1093be5a52bSMiklos Szeredi 
110ab2257e9SMiklos Szeredi 			/* Waitq for writepage completion */
1113be5a52bSMiklos Szeredi 			wait_queue_head_t page_waitq;
1123be5a52bSMiklos Szeredi 
113ab2257e9SMiklos Szeredi 			/* List of writepage requestst (pending or sent) */
1146b2fb799SMaxim Patlasov 			struct rb_root writepages;
115ab2257e9SMiklos Szeredi 		};
1164582a4abSFeng Shuo 
117ab2257e9SMiklos Szeredi 		/* readdir cache (directory only) */
11869e34551SMiklos Szeredi 		struct {
11969e34551SMiklos Szeredi 			/* true if fully cached */
12069e34551SMiklos Szeredi 			bool cached;
12169e34551SMiklos Szeredi 
12269e34551SMiklos Szeredi 			/* size of cache */
12369e34551SMiklos Szeredi 			loff_t size;
12469e34551SMiklos Szeredi 
12569e34551SMiklos Szeredi 			/* position at end of cache (position of next entry) */
12669e34551SMiklos Szeredi 			loff_t pos;
12769e34551SMiklos Szeredi 
1283494927eSMiklos Szeredi 			/* version of the cache */
1293494927eSMiklos Szeredi 			u64 version;
1303494927eSMiklos Szeredi 
131ab2257e9SMiklos Szeredi 			/* modification time of directory when cache was
132ab2257e9SMiklos Szeredi 			 * started */
1337118883bSMiklos Szeredi 			struct timespec64 mtime;
1347118883bSMiklos Szeredi 
135261aaba7SMiklos Szeredi 			/* iversion of directory when cache was started */
136261aaba7SMiklos Szeredi 			u64 iversion;
137261aaba7SMiklos Szeredi 
13869e34551SMiklos Szeredi 			/* protects above fields */
13969e34551SMiklos Szeredi 			spinlock_t lock;
14069e34551SMiklos Szeredi 		} rdc;
141ab2257e9SMiklos Szeredi 	};
14269e34551SMiklos Szeredi 
1434582a4abSFeng Shuo 	/** Miscellaneous bits describing inode state */
1444582a4abSFeng Shuo 	unsigned long state;
1455c672ab3SMiklos Szeredi 
1465c672ab3SMiklos Szeredi 	/** Lock for serializing lookup and readdir for back compatibility*/
1475c672ab3SMiklos Szeredi 	struct mutex mutex;
148f15ecfefSKirill Tkhai 
149f15ecfefSKirill Tkhai 	/** Lock to protect write related fields */
150f15ecfefSKirill Tkhai 	spinlock_t lock;
151c2d0ad00SVivek Goyal 
1526ae330caSVivek Goyal 	/**
1536ae330caSVivek Goyal 	 * Can't take inode lock in fault path (leads to circular dependency).
1546ae330caSVivek Goyal 	 * Introduce another semaphore which can be taken in fault path and
1556ae330caSVivek Goyal 	 * then other filesystem paths can take this to block faults.
1566ae330caSVivek Goyal 	 */
1576ae330caSVivek Goyal 	struct rw_semaphore i_mmap_sem;
1586ae330caSVivek Goyal 
159c2d0ad00SVivek Goyal #ifdef CONFIG_FUSE_DAX
160c2d0ad00SVivek Goyal 	/*
161c2d0ad00SVivek Goyal 	 * Dax specific inode data
162c2d0ad00SVivek Goyal 	 */
163c2d0ad00SVivek Goyal 	struct fuse_inode_dax *dax;
164c2d0ad00SVivek Goyal #endif
1654582a4abSFeng Shuo };
1664582a4abSFeng Shuo 
1674582a4abSFeng Shuo /** FUSE inode state bits */
1684582a4abSFeng Shuo enum {
1694582a4abSFeng Shuo 	/** Advise readdirplus  */
1704582a4abSFeng Shuo 	FUSE_I_ADVISE_RDPLUS,
1716314efeeSMiklos Szeredi 	/** Initialized with readdirplus */
1726314efeeSMiklos Szeredi 	FUSE_I_INIT_RDPLUS,
17306a7c3c2SMaxim Patlasov 	/** An operation changing file size is in progress  */
17406a7c3c2SMaxim Patlasov 	FUSE_I_SIZE_UNSTABLE,
175d8a5ba45SMiklos Szeredi };
176d8a5ba45SMiklos Szeredi 
177da5e4714SMiklos Szeredi struct fuse_conn;
1784cb54866SMiklos Szeredi struct fuse_release_args;
179da5e4714SMiklos Szeredi 
180b6aeadedSMiklos Szeredi /** FUSE specific file data */
181b6aeadedSMiklos Szeredi struct fuse_file {
182da5e4714SMiklos Szeredi 	/** Fuse connection for this file */
183da5e4714SMiklos Szeredi 	struct fuse_conn *fc;
184da5e4714SMiklos Szeredi 
1854cb54866SMiklos Szeredi 	/* Argument space reserved for release */
1864cb54866SMiklos Szeredi 	struct fuse_release_args *release_args;
187b6aeadedSMiklos Szeredi 
188acf99433STejun Heo 	/** Kernel file handle guaranteed to be unique */
189acf99433STejun Heo 	u64 kh;
190acf99433STejun Heo 
191b6aeadedSMiklos Szeredi 	/** File handle used by userspace */
192b6aeadedSMiklos Szeredi 	u64 fh;
193c756e0a4SMiklos Szeredi 
194da5e4714SMiklos Szeredi 	/** Node id of this file */
195da5e4714SMiklos Szeredi 	u64 nodeid;
196da5e4714SMiklos Szeredi 
197c756e0a4SMiklos Szeredi 	/** Refcount */
1984e8c2eb5SElena Reshetova 	refcount_t count;
19993a8c3cdSMiklos Szeredi 
200c7b7143cSMiklos Szeredi 	/** FOPEN_* flags returned by open */
201c7b7143cSMiklos Szeredi 	u32 open_flags;
202c7b7143cSMiklos Szeredi 
20393a8c3cdSMiklos Szeredi 	/** Entry on inode's write_files list */
20493a8c3cdSMiklos Szeredi 	struct list_head write_entry;
20595668a69STejun Heo 
2065d7bc7e8SMiklos Szeredi 	/* Readdir related */
2075d7bc7e8SMiklos Szeredi 	struct {
2085d7bc7e8SMiklos Szeredi 		/*
2095d7bc7e8SMiklos Szeredi 		 * Protects below fields against (crazy) parallel readdir on
2105d7bc7e8SMiklos Szeredi 		 * same open file.  Uncontended in the normal case.
2115d7bc7e8SMiklos Szeredi 		 */
2125d7bc7e8SMiklos Szeredi 		struct mutex lock;
2135d7bc7e8SMiklos Szeredi 
2145d7bc7e8SMiklos Szeredi 		/* Dir stream position */
2155d7bc7e8SMiklos Szeredi 		loff_t pos;
2165d7bc7e8SMiklos Szeredi 
2175d7bc7e8SMiklos Szeredi 		/* Offset in cache */
2185d7bc7e8SMiklos Szeredi 		loff_t cache_off;
2193494927eSMiklos Szeredi 
2203494927eSMiklos Szeredi 		/* Version of cache we are reading */
2213494927eSMiklos Szeredi 		u64 version;
2223494927eSMiklos Szeredi 
2235d7bc7e8SMiklos Szeredi 	} readdir;
2245d7bc7e8SMiklos Szeredi 
22595668a69STejun Heo 	/** RB node to be linked on fuse_conn->polled_files */
22695668a69STejun Heo 	struct rb_node polled_node;
22795668a69STejun Heo 
22895668a69STejun Heo 	/** Wait queue head for poll */
22995668a69STejun Heo 	wait_queue_head_t poll_wait;
23037fb3a30SMiklos Szeredi 
23137fb3a30SMiklos Szeredi 	/** Has flock been performed on this file? */
23237fb3a30SMiklos Szeredi 	bool flock:1;
233b6aeadedSMiklos Szeredi };
234b6aeadedSMiklos Szeredi 
235334f485dSMiklos Szeredi /** One input argument of a request */
236334f485dSMiklos Szeredi struct fuse_in_arg {
237334f485dSMiklos Szeredi 	unsigned size;
238334f485dSMiklos Szeredi 	const void *value;
239334f485dSMiklos Szeredi };
240334f485dSMiklos Szeredi 
241334f485dSMiklos Szeredi /** One output argument of a request */
242334f485dSMiklos Szeredi struct fuse_arg {
243334f485dSMiklos Szeredi 	unsigned size;
244334f485dSMiklos Szeredi 	void *value;
245334f485dSMiklos Szeredi };
246334f485dSMiklos Szeredi 
247b2430d75SMaxim Patlasov /** FUSE page descriptor */
248b2430d75SMaxim Patlasov struct fuse_page_desc {
249b2430d75SMaxim Patlasov 	unsigned int length;
250b2430d75SMaxim Patlasov 	unsigned int offset;
251b2430d75SMaxim Patlasov };
252b2430d75SMaxim Patlasov 
2537078187aSMiklos Szeredi struct fuse_args {
2547078187aSMiklos Szeredi 	uint64_t nodeid;
2551f4e9d03SMiklos Szeredi 	uint32_t opcode;
2561f4e9d03SMiklos Szeredi 	unsigned short in_numargs;
2571f4e9d03SMiklos Szeredi 	unsigned short out_numargs;
258c500ebaaSMiklos Szeredi 	bool force:1;
259454a7613SMiklos Szeredi 	bool noreply:1;
260e413754bSMiklos Szeredi 	bool nocreds:1;
26168583165SMiklos Szeredi 	bool in_pages:1;
26268583165SMiklos Szeredi 	bool out_pages:1;
2631f4e9d03SMiklos Szeredi 	bool out_argvar:1;
26468583165SMiklos Szeredi 	bool page_zeroing:1;
26568583165SMiklos Szeredi 	bool page_replace:1;
266bb737bbeSVivek Goyal 	bool may_block:1;
267d5b48543SMiklos Szeredi 	struct fuse_in_arg in_args[3];
268d5b48543SMiklos Szeredi 	struct fuse_arg out_args[2];
26912597287SMiklos Szeredi 	void (*end)(struct fuse_conn *fc, struct fuse_args *args, int error);
2707078187aSMiklos Szeredi };
2717078187aSMiklos Szeredi 
27268583165SMiklos Szeredi struct fuse_args_pages {
27368583165SMiklos Szeredi 	struct fuse_args args;
27468583165SMiklos Szeredi 	struct page **pages;
27568583165SMiklos Szeredi 	struct fuse_page_desc *descs;
27668583165SMiklos Szeredi 	unsigned int num_pages;
27768583165SMiklos Szeredi };
27868583165SMiklos Szeredi 
2797078187aSMiklos Szeredi #define FUSE_ARGS(args) struct fuse_args args = {}
2807078187aSMiklos Szeredi 
28101e9d11aSMaxim Patlasov /** The request IO state (for asynchronous processing) */
28201e9d11aSMaxim Patlasov struct fuse_io_priv {
283744742d6SSeth Forshee 	struct kref refcnt;
28401e9d11aSMaxim Patlasov 	int async;
28501e9d11aSMaxim Patlasov 	spinlock_t lock;
28601e9d11aSMaxim Patlasov 	unsigned reqs;
28701e9d11aSMaxim Patlasov 	ssize_t bytes;
28801e9d11aSMaxim Patlasov 	size_t size;
28901e9d11aSMaxim Patlasov 	__u64 offset;
29001e9d11aSMaxim Patlasov 	bool write;
29161c12b49SAshish Samant 	bool should_dirty;
29201e9d11aSMaxim Patlasov 	int err;
29301e9d11aSMaxim Patlasov 	struct kiocb *iocb;
2949d5722b7SChristoph Hellwig 	struct completion *done;
2957879c4e5SAshish Sangwan 	bool blocking;
29601e9d11aSMaxim Patlasov };
29701e9d11aSMaxim Patlasov 
298e1c0eecbSMiklos Szeredi #define FUSE_IO_PRIV_SYNC(i) \
299744742d6SSeth Forshee {					\
3001e24edcaSPeter Zijlstra 	.refcnt = KREF_INIT(1),		\
301744742d6SSeth Forshee 	.async = 0,			\
302e1c0eecbSMiklos Szeredi 	.iocb = i,			\
303744742d6SSeth Forshee }
304744742d6SSeth Forshee 
305334f485dSMiklos Szeredi /**
306825d6d33SMiklos Szeredi  * Request flags
307825d6d33SMiklos Szeredi  *
308825d6d33SMiklos Szeredi  * FR_ISREPLY:		set if the request has reply
309825d6d33SMiklos Szeredi  * FR_FORCE:		force sending of the request even if interrupted
310825d6d33SMiklos Szeredi  * FR_BACKGROUND:	request is sent in the background
311825d6d33SMiklos Szeredi  * FR_WAITING:		request is counted as "waiting"
312825d6d33SMiklos Szeredi  * FR_ABORTED:		the request was aborted
313825d6d33SMiklos Szeredi  * FR_INTERRUPTED:	the request has been interrupted
314825d6d33SMiklos Szeredi  * FR_LOCKED:		data is being copied to/from the request
31533e14b4dSMiklos Szeredi  * FR_PENDING:		request is not yet in userspace
31633e14b4dSMiklos Szeredi  * FR_SENT:		request is in userspace, waiting for an answer
31733e14b4dSMiklos Szeredi  * FR_FINISHED:		request is finished
31877cd9d48SMiklos Szeredi  * FR_PRIVATE:		request is on private list
3193e8cb8b2SMiklos Szeredi  * FR_ASYNC:		request is asynchronous
320825d6d33SMiklos Szeredi  */
321825d6d33SMiklos Szeredi enum fuse_req_flag {
322825d6d33SMiklos Szeredi 	FR_ISREPLY,
323825d6d33SMiklos Szeredi 	FR_FORCE,
324825d6d33SMiklos Szeredi 	FR_BACKGROUND,
325825d6d33SMiklos Szeredi 	FR_WAITING,
326825d6d33SMiklos Szeredi 	FR_ABORTED,
327825d6d33SMiklos Szeredi 	FR_INTERRUPTED,
328825d6d33SMiklos Szeredi 	FR_LOCKED,
32933e14b4dSMiklos Szeredi 	FR_PENDING,
33033e14b4dSMiklos Szeredi 	FR_SENT,
33133e14b4dSMiklos Szeredi 	FR_FINISHED,
33277cd9d48SMiklos Szeredi 	FR_PRIVATE,
3333e8cb8b2SMiklos Szeredi 	FR_ASYNC,
334825d6d33SMiklos Szeredi };
335825d6d33SMiklos Szeredi 
336825d6d33SMiklos Szeredi /**
337334f485dSMiklos Szeredi  * A request to the client
338dc00809aSMiklos Szeredi  *
339dc00809aSMiklos Szeredi  * .waitq.lock protects the following fields:
340dc00809aSMiklos Szeredi  *   - FR_ABORTED
341dc00809aSMiklos Szeredi  *   - FR_LOCKED (may also be modified under fc->lock, tested under both)
342334f485dSMiklos Szeredi  */
343334f485dSMiklos Szeredi struct fuse_req {
344ce1d5a49SMiklos Szeredi 	/** This can be on either pending processing or io lists in
345ce1d5a49SMiklos Szeredi 	    fuse_conn */
346334f485dSMiklos Szeredi 	struct list_head list;
347334f485dSMiklos Szeredi 
348a4d27e75SMiklos Szeredi 	/** Entry on the interrupts list  */
349a4d27e75SMiklos Szeredi 	struct list_head intr_entry;
350a4d27e75SMiklos Szeredi 
35112597287SMiklos Szeredi 	/* Input/output arguments */
35212597287SMiklos Szeredi 	struct fuse_args *args;
35312597287SMiklos Szeredi 
354334f485dSMiklos Szeredi 	/** refcount */
355ec99f6d3SElena Reshetova 	refcount_t count;
356334f485dSMiklos Szeredi 
357825d6d33SMiklos Szeredi 	/* Request flags, updated with test/set/clear_bit() */
358825d6d33SMiklos Szeredi 	unsigned long flags;
3599bc5dddaSMiklos Szeredi 
360d4993774SMiklos Szeredi 	/* The request input header */
361d4993774SMiklos Szeredi 	struct {
362d4993774SMiklos Szeredi 		struct fuse_in_header h;
363d4993774SMiklos Szeredi 	} in;
364334f485dSMiklos Szeredi 
365d4993774SMiklos Szeredi 	/* The request output header */
366d4993774SMiklos Szeredi 	struct {
367d4993774SMiklos Szeredi 		struct fuse_out_header h;
368d4993774SMiklos Szeredi 	} out;
369334f485dSMiklos Szeredi 
370334f485dSMiklos Szeredi 	/** Used to wake up the task waiting for completion of request*/
371334f485dSMiklos Szeredi 	wait_queue_head_t waitq;
372334f485dSMiklos Szeredi 
373a62a8ef9SStefan Hajnoczi #if IS_ENABLED(CONFIG_VIRTIO_FS)
374a62a8ef9SStefan Hajnoczi 	/** virtio-fs's physically contiguous buffer for in and out args */
375a62a8ef9SStefan Hajnoczi 	void *argbuf;
376a62a8ef9SStefan Hajnoczi #endif
377*24754db2SMax Reitz 
378*24754db2SMax Reitz 	/** fuse_conn this request belongs to */
379*24754db2SMax Reitz 	struct fuse_conn *fc;
380334f485dSMiklos Szeredi };
381334f485dSMiklos Szeredi 
382ae3aad77SStefan Hajnoczi struct fuse_iqueue;
383ae3aad77SStefan Hajnoczi 
384ae3aad77SStefan Hajnoczi /**
385ae3aad77SStefan Hajnoczi  * Input queue callbacks
386ae3aad77SStefan Hajnoczi  *
387ae3aad77SStefan Hajnoczi  * Input queue signalling is device-specific.  For example, the /dev/fuse file
388ae3aad77SStefan Hajnoczi  * uses fiq->waitq and fasync to wake processes that are waiting on queue
389ae3aad77SStefan Hajnoczi  * readiness.  These callbacks allow other device types to respond to input
390ae3aad77SStefan Hajnoczi  * queue activity.
391ae3aad77SStefan Hajnoczi  */
392ae3aad77SStefan Hajnoczi struct fuse_iqueue_ops {
393ae3aad77SStefan Hajnoczi 	/**
394ae3aad77SStefan Hajnoczi 	 * Signal that a forget has been queued
395ae3aad77SStefan Hajnoczi 	 */
396ae3aad77SStefan Hajnoczi 	void (*wake_forget_and_unlock)(struct fuse_iqueue *fiq)
397ae3aad77SStefan Hajnoczi 		__releases(fiq->lock);
398ae3aad77SStefan Hajnoczi 
399ae3aad77SStefan Hajnoczi 	/**
400ae3aad77SStefan Hajnoczi 	 * Signal that an INTERRUPT request has been queued
401ae3aad77SStefan Hajnoczi 	 */
402ae3aad77SStefan Hajnoczi 	void (*wake_interrupt_and_unlock)(struct fuse_iqueue *fiq)
403ae3aad77SStefan Hajnoczi 		__releases(fiq->lock);
404ae3aad77SStefan Hajnoczi 
405ae3aad77SStefan Hajnoczi 	/**
406ae3aad77SStefan Hajnoczi 	 * Signal that a request has been queued
407ae3aad77SStefan Hajnoczi 	 */
408ae3aad77SStefan Hajnoczi 	void (*wake_pending_and_unlock)(struct fuse_iqueue *fiq)
409ae3aad77SStefan Hajnoczi 		__releases(fiq->lock);
410a62a8ef9SStefan Hajnoczi 
411a62a8ef9SStefan Hajnoczi 	/**
412a62a8ef9SStefan Hajnoczi 	 * Clean up when fuse_iqueue is destroyed
413a62a8ef9SStefan Hajnoczi 	 */
414a62a8ef9SStefan Hajnoczi 	void (*release)(struct fuse_iqueue *fiq);
415ae3aad77SStefan Hajnoczi };
416ae3aad77SStefan Hajnoczi 
417ae3aad77SStefan Hajnoczi /** /dev/fuse input queue operations */
418ae3aad77SStefan Hajnoczi extern const struct fuse_iqueue_ops fuse_dev_fiq_ops;
419ae3aad77SStefan Hajnoczi 
420f88996a9SMiklos Szeredi struct fuse_iqueue {
421e16714d8SMiklos Szeredi 	/** Connection established */
422e16714d8SMiklos Szeredi 	unsigned connected;
423e16714d8SMiklos Szeredi 
42476e43c8cSEric Biggers 	/** Lock protecting accesses to members of this structure */
42576e43c8cSEric Biggers 	spinlock_t lock;
42676e43c8cSEric Biggers 
427f88996a9SMiklos Szeredi 	/** Readers of the connection are waiting on this */
428f88996a9SMiklos Szeredi 	wait_queue_head_t waitq;
429f88996a9SMiklos Szeredi 
430f88996a9SMiklos Szeredi 	/** The next unique request id */
431f88996a9SMiklos Szeredi 	u64 reqctr;
432f88996a9SMiklos Szeredi 
433f88996a9SMiklos Szeredi 	/** The list of pending requests */
434f88996a9SMiklos Szeredi 	struct list_head pending;
435f88996a9SMiklos Szeredi 
436f88996a9SMiklos Szeredi 	/** Pending interrupts */
437f88996a9SMiklos Szeredi 	struct list_head interrupts;
438f88996a9SMiklos Szeredi 
439f88996a9SMiklos Szeredi 	/** Queue of pending forgets */
440f88996a9SMiklos Szeredi 	struct fuse_forget_link forget_list_head;
441f88996a9SMiklos Szeredi 	struct fuse_forget_link *forget_list_tail;
442f88996a9SMiklos Szeredi 
443f88996a9SMiklos Szeredi 	/** Batching of FORGET requests (positive indicates FORGET batch) */
444f88996a9SMiklos Szeredi 	int forget_batch;
445f88996a9SMiklos Szeredi 
446f88996a9SMiklos Szeredi 	/** O_ASYNC requests */
447f88996a9SMiklos Szeredi 	struct fasync_struct *fasync;
448ae3aad77SStefan Hajnoczi 
449ae3aad77SStefan Hajnoczi 	/** Device-specific callbacks */
450ae3aad77SStefan Hajnoczi 	const struct fuse_iqueue_ops *ops;
451ae3aad77SStefan Hajnoczi 
452ae3aad77SStefan Hajnoczi 	/** Device-specific state */
453ae3aad77SStefan Hajnoczi 	void *priv;
454f88996a9SMiklos Szeredi };
455f88996a9SMiklos Szeredi 
456be2ff42cSKirill Tkhai #define FUSE_PQ_HASH_BITS 8
457be2ff42cSKirill Tkhai #define FUSE_PQ_HASH_SIZE (1 << FUSE_PQ_HASH_BITS)
458be2ff42cSKirill Tkhai 
4593a2b5b9cSMiklos Szeredi struct fuse_pqueue {
460e96edd94SMiklos Szeredi 	/** Connection established */
461e96edd94SMiklos Szeredi 	unsigned connected;
462e96edd94SMiklos Szeredi 
46345a91cb1SMiklos Szeredi 	/** Lock protecting accessess to  members of this structure */
46445a91cb1SMiklos Szeredi 	spinlock_t lock;
46545a91cb1SMiklos Szeredi 
466be2ff42cSKirill Tkhai 	/** Hash table of requests being processed */
467be2ff42cSKirill Tkhai 	struct list_head *processing;
4683a2b5b9cSMiklos Szeredi 
4693a2b5b9cSMiklos Szeredi 	/** The list of requests under I/O */
4703a2b5b9cSMiklos Szeredi 	struct list_head io;
4713a2b5b9cSMiklos Szeredi };
4723a2b5b9cSMiklos Szeredi 
473d8a5ba45SMiklos Szeredi /**
474cc080e9eSMiklos Szeredi  * Fuse device instance
475cc080e9eSMiklos Szeredi  */
476cc080e9eSMiklos Szeredi struct fuse_dev {
477cc080e9eSMiklos Szeredi 	/** Fuse connection for this device */
478cc080e9eSMiklos Szeredi 	struct fuse_conn *fc;
479cc080e9eSMiklos Szeredi 
480c3696046SMiklos Szeredi 	/** Processing queue */
481c3696046SMiklos Szeredi 	struct fuse_pqueue pq;
482c3696046SMiklos Szeredi 
483cc080e9eSMiklos Szeredi 	/** list entry on fc->devices */
484cc080e9eSMiklos Szeredi 	struct list_head entry;
485cc080e9eSMiklos Szeredi };
486cc080e9eSMiklos Szeredi 
4870cc2656cSStefan Hajnoczi struct fuse_fs_context {
4880cc2656cSStefan Hajnoczi 	int fd;
4890cc2656cSStefan Hajnoczi 	unsigned int rootmode;
4900cc2656cSStefan Hajnoczi 	kuid_t user_id;
4910cc2656cSStefan Hajnoczi 	kgid_t group_id;
4920cc2656cSStefan Hajnoczi 	bool is_bdev:1;
4930cc2656cSStefan Hajnoczi 	bool fd_present:1;
4940cc2656cSStefan Hajnoczi 	bool rootmode_present:1;
4950cc2656cSStefan Hajnoczi 	bool user_id_present:1;
4960cc2656cSStefan Hajnoczi 	bool group_id_present:1;
4970cc2656cSStefan Hajnoczi 	bool default_permissions:1;
4980cc2656cSStefan Hajnoczi 	bool allow_other:1;
499783863d6SMiklos Szeredi 	bool destroy:1;
50015c8e72eSVivek Goyal 	bool no_control:1;
50115c8e72eSVivek Goyal 	bool no_force_umount:1;
502f4fd4ae3SVivek Goyal 	bool legacy_opts_show:1;
5031dd53957SVivek Goyal 	bool dax:1;
5040cc2656cSStefan Hajnoczi 	unsigned int max_read;
5050cc2656cSStefan Hajnoczi 	unsigned int blksize;
5060cc2656cSStefan Hajnoczi 	const char *subtype;
5070cc2656cSStefan Hajnoczi 
5081dd53957SVivek Goyal 	/* DAX device, may be NULL */
5091dd53957SVivek Goyal 	struct dax_device *dax_dev;
5101dd53957SVivek Goyal 
5110cc2656cSStefan Hajnoczi 	/* fuse_dev pointer to fill in, should contain NULL on entry */
5120cc2656cSStefan Hajnoczi 	void **fudptr;
5130cc2656cSStefan Hajnoczi };
5140cc2656cSStefan Hajnoczi 
515cc080e9eSMiklos Szeredi /**
516d8a5ba45SMiklos Szeredi  * A Fuse connection.
517d8a5ba45SMiklos Szeredi  *
518d8a5ba45SMiklos Szeredi  * This structure is created, when the filesystem is mounted, and is
519d8a5ba45SMiklos Szeredi  * destroyed, when the client device is closed and the filesystem is
520d8a5ba45SMiklos Szeredi  * unmounted.
521d8a5ba45SMiklos Szeredi  */
522d8a5ba45SMiklos Szeredi struct fuse_conn {
523d7133114SMiklos Szeredi 	/** Lock protecting accessess to  members of this structure */
524d7133114SMiklos Szeredi 	spinlock_t lock;
525d7133114SMiklos Szeredi 
526bafa9654SMiklos Szeredi 	/** Refcount */
527095fc40aSElena Reshetova 	refcount_t count;
528bafa9654SMiklos Szeredi 
529c3696046SMiklos Szeredi 	/** Number of fuse_dev's */
530c3696046SMiklos Szeredi 	atomic_t dev_count;
531c3696046SMiklos Szeredi 
532dd3e2c55SAl Viro 	struct rcu_head rcu;
533dd3e2c55SAl Viro 
534d8a5ba45SMiklos Szeredi 	/** The user id for this mount */
535499dcf20SEric W. Biederman 	kuid_t user_id;
536d8a5ba45SMiklos Szeredi 
53787729a55SMiklos Szeredi 	/** The group id for this mount */
538499dcf20SEric W. Biederman 	kgid_t group_id;
53987729a55SMiklos Szeredi 
5400b6e9ea0SSeth Forshee 	/** The pid namespace for this mount */
5410b6e9ea0SSeth Forshee 	struct pid_namespace *pid_ns;
5420b6e9ea0SSeth Forshee 
5438cb08329SEric W. Biederman 	/** The user namespace for this mount */
5448cb08329SEric W. Biederman 	struct user_namespace *user_ns;
5458cb08329SEric W. Biederman 
546db50b96cSMiklos Szeredi 	/** Maximum read size */
547db50b96cSMiklos Szeredi 	unsigned max_read;
548db50b96cSMiklos Szeredi 
549413ef8cbSMiklos Szeredi 	/** Maximum write size */
550413ef8cbSMiklos Szeredi 	unsigned max_write;
551413ef8cbSMiklos Szeredi 
5525da784ccSConstantine Shulyupin 	/** Maxmum number of pages that can be used in a single request */
5535da784ccSConstantine Shulyupin 	unsigned int max_pages;
5545da784ccSConstantine Shulyupin 
555f88996a9SMiklos Szeredi 	/** Input queue */
556f88996a9SMiklos Szeredi 	struct fuse_iqueue iq;
557334f485dSMiklos Szeredi 
558acf99433STejun Heo 	/** The next unique kernel file handle */
55975126f55SMiklos Szeredi 	atomic64_t khctr;
560acf99433STejun Heo 
56195668a69STejun Heo 	/** rbtree of fuse_files waiting for poll events indexed by ph */
56295668a69STejun Heo 	struct rb_root polled_files;
56395668a69STejun Heo 
5647a6d3c8bSCsaba Henk 	/** Maximum number of outstanding background requests */
5657a6d3c8bSCsaba Henk 	unsigned max_background;
5667a6d3c8bSCsaba Henk 
5677a6d3c8bSCsaba Henk 	/** Number of background requests at which congestion starts */
5687a6d3c8bSCsaba Henk 	unsigned congestion_threshold;
5697a6d3c8bSCsaba Henk 
57008a53cdcSMiklos Szeredi 	/** Number of requests currently in the background */
57108a53cdcSMiklos Szeredi 	unsigned num_background;
57208a53cdcSMiklos Szeredi 
573d12def1bSMiklos Szeredi 	/** Number of background requests currently queued for userspace */
574d12def1bSMiklos Szeredi 	unsigned active_background;
575d12def1bSMiklos Szeredi 
576d12def1bSMiklos Szeredi 	/** The list of background requests set aside for later queuing */
577d12def1bSMiklos Szeredi 	struct list_head bg_queue;
578d12def1bSMiklos Szeredi 
579ae2dffa3SKirill Tkhai 	/** Protects: max_background, congestion_threshold, num_background,
580ae2dffa3SKirill Tkhai 	 * active_background, bg_queue, blocked */
581ae2dffa3SKirill Tkhai 	spinlock_t bg_lock;
582ae2dffa3SKirill Tkhai 
583796523fbSMaxim Patlasov 	/** Flag indicating that INIT reply has been received. Allocating
584796523fbSMaxim Patlasov 	 * any fuse request will be suspended until the flag is set */
585796523fbSMaxim Patlasov 	int initialized;
586796523fbSMaxim Patlasov 
58708a53cdcSMiklos Szeredi 	/** Flag indicating if connection is blocked.  This will be
58808a53cdcSMiklos Szeredi 	    the case before the INIT reply is received, and if there
58908a53cdcSMiklos Szeredi 	    are too many outstading backgrounds requests */
59008a53cdcSMiklos Szeredi 	int blocked;
59108a53cdcSMiklos Szeredi 
59208a53cdcSMiklos Szeredi 	/** waitq for blocked connection */
59308a53cdcSMiklos Szeredi 	wait_queue_head_t blocked_waitq;
59408a53cdcSMiklos Szeredi 
59569a53bf2SMiklos Szeredi 	/** Connection established, cleared on umount, connection
59669a53bf2SMiklos Szeredi 	    abort and device release */
597095da6cbSMiklos Szeredi 	unsigned connected;
5981e9a4ed9SMiklos Szeredi 
5993b7008b2SSzymon Lukasz 	/** Connection aborted via sysfs */
6003b7008b2SSzymon Lukasz 	bool aborted;
6013b7008b2SSzymon Lukasz 
602095da6cbSMiklos Szeredi 	/** Connection failed (version mismatch).  Cannot race with
603095da6cbSMiklos Szeredi 	    setting other bitfields since it is only set once in INIT
604095da6cbSMiklos Szeredi 	    reply, before any other request, and never cleared */
605334f485dSMiklos Szeredi 	unsigned conn_error:1;
606334f485dSMiklos Szeredi 
6070ec7ca41SMiklos Szeredi 	/** Connection successful.  Only set in INIT */
6080ec7ca41SMiklos Szeredi 	unsigned conn_init:1;
6090ec7ca41SMiklos Szeredi 
6109cd68455SMiklos Szeredi 	/** Do readpages asynchronously?  Only set in INIT */
6119cd68455SMiklos Szeredi 	unsigned async_read:1;
6129cd68455SMiklos Szeredi 
6133b7008b2SSzymon Lukasz 	/** Return an unique read error after abort.  Only set in INIT */
6143b7008b2SSzymon Lukasz 	unsigned abort_err:1;
6153b7008b2SSzymon Lukasz 
6166ff958edSMiklos Szeredi 	/** Do not send separate SETATTR request before open(O_TRUNC)  */
6176ff958edSMiklos Szeredi 	unsigned atomic_o_trunc:1;
6186ff958edSMiklos Szeredi 
61933670fa2SMiklos Szeredi 	/** Filesystem supports NFS exporting.  Only set in INIT */
62033670fa2SMiklos Szeredi 	unsigned export_support:1;
62133670fa2SMiklos Szeredi 
622d5cd66c5SPavel Emelyanov 	/** write-back cache policy (default is write-through) */
623d5cd66c5SPavel Emelyanov 	unsigned writeback_cache:1;
624d5cd66c5SPavel Emelyanov 
6255c672ab3SMiklos Szeredi 	/** allow parallel lookups and readdir (default is serialized) */
6265c672ab3SMiklos Szeredi 	unsigned parallel_dirops:1;
6275c672ab3SMiklos Szeredi 
6285e940c1dSMiklos Szeredi 	/** handle fs handles killing suid/sgid/cap on write/chown/trunc */
6295e940c1dSMiklos Szeredi 	unsigned handle_killpriv:1;
6305e940c1dSMiklos Szeredi 
6315571f1e6SDan Schatzberg 	/** cache READLINK responses in page cache */
6325571f1e6SDan Schatzberg 	unsigned cache_symlinks:1;
6335571f1e6SDan Schatzberg 
634f4fd4ae3SVivek Goyal 	/* show legacy mount options */
635f4fd4ae3SVivek Goyal 	unsigned int legacy_opts_show:1;
636f4fd4ae3SVivek Goyal 
637095da6cbSMiklos Szeredi 	/*
638095da6cbSMiklos Szeredi 	 * The following bitfields are only for optimization purposes
639095da6cbSMiklos Szeredi 	 * and hence races in setting them will not cause malfunction
640095da6cbSMiklos Szeredi 	 */
641095da6cbSMiklos Szeredi 
6427678ac50SAndrew Gallagher 	/** Is open/release not implemented by fs? */
6437678ac50SAndrew Gallagher 	unsigned no_open:1;
6447678ac50SAndrew Gallagher 
645d9a9ea94SChad Austin 	/** Is opendir/releasedir not implemented by fs? */
646d9a9ea94SChad Austin 	unsigned no_opendir:1;
647d9a9ea94SChad Austin 
648b6aeadedSMiklos Szeredi 	/** Is fsync not implemented by fs? */
649b6aeadedSMiklos Szeredi 	unsigned no_fsync:1;
650b6aeadedSMiklos Szeredi 
65182547981SMiklos Szeredi 	/** Is fsyncdir not implemented by fs? */
65282547981SMiklos Szeredi 	unsigned no_fsyncdir:1;
65382547981SMiklos Szeredi 
654b6aeadedSMiklos Szeredi 	/** Is flush not implemented by fs? */
655b6aeadedSMiklos Szeredi 	unsigned no_flush:1;
656b6aeadedSMiklos Szeredi 
65792a8780eSMiklos Szeredi 	/** Is setxattr not implemented by fs? */
65892a8780eSMiklos Szeredi 	unsigned no_setxattr:1;
65992a8780eSMiklos Szeredi 
66092a8780eSMiklos Szeredi 	/** Is getxattr not implemented by fs? */
66192a8780eSMiklos Szeredi 	unsigned no_getxattr:1;
66292a8780eSMiklos Szeredi 
66392a8780eSMiklos Szeredi 	/** Is listxattr not implemented by fs? */
66492a8780eSMiklos Szeredi 	unsigned no_listxattr:1;
66592a8780eSMiklos Szeredi 
66692a8780eSMiklos Szeredi 	/** Is removexattr not implemented by fs? */
66792a8780eSMiklos Szeredi 	unsigned no_removexattr:1;
66892a8780eSMiklos Szeredi 
66937fb3a30SMiklos Szeredi 	/** Are posix file locking primitives not implemented by fs? */
67071421259SMiklos Szeredi 	unsigned no_lock:1;
67171421259SMiklos Szeredi 
67231d40d74SMiklos Szeredi 	/** Is access not implemented by fs? */
67331d40d74SMiklos Szeredi 	unsigned no_access:1;
67431d40d74SMiklos Szeredi 
675fd72faacSMiklos Szeredi 	/** Is create not implemented by fs? */
676fd72faacSMiklos Szeredi 	unsigned no_create:1;
677fd72faacSMiklos Szeredi 
678a4d27e75SMiklos Szeredi 	/** Is interrupt not implemented by fs? */
679a4d27e75SMiklos Szeredi 	unsigned no_interrupt:1;
680a4d27e75SMiklos Szeredi 
681b2d2272fSMiklos Szeredi 	/** Is bmap not implemented by fs? */
682b2d2272fSMiklos Szeredi 	unsigned no_bmap:1;
683b2d2272fSMiklos Szeredi 
68495668a69STejun Heo 	/** Is poll not implemented by fs? */
68595668a69STejun Heo 	unsigned no_poll:1;
68695668a69STejun Heo 
68778bb6cb9SMiklos Szeredi 	/** Do multi-page cached writes */
68878bb6cb9SMiklos Szeredi 	unsigned big_writes:1;
68978bb6cb9SMiklos Szeredi 
690e0a43ddcSMiklos Szeredi 	/** Don't apply umask to creation modes */
691e0a43ddcSMiklos Szeredi 	unsigned dont_mask:1;
692e0a43ddcSMiklos Szeredi 
69337fb3a30SMiklos Szeredi 	/** Are BSD file locking primitives not implemented by fs? */
69437fb3a30SMiklos Szeredi 	unsigned no_flock:1;
69537fb3a30SMiklos Szeredi 
696519c6040SMiklos Szeredi 	/** Is fallocate not implemented by fs? */
697519c6040SMiklos Szeredi 	unsigned no_fallocate:1;
698519c6040SMiklos Szeredi 
6991560c974SMiklos Szeredi 	/** Is rename with flags implemented by fs? */
7001560c974SMiklos Szeredi 	unsigned no_rename2:1;
7011560c974SMiklos Szeredi 
70272d0d248SBrian Foster 	/** Use enhanced/automatic page cache invalidation. */
70372d0d248SBrian Foster 	unsigned auto_inval_data:1;
70472d0d248SBrian Foster 
705ad2ba64dSKirill Smelkov 	/** Filesystem is fully reponsible for page cache invalidation. */
706ad2ba64dSKirill Smelkov 	unsigned explicit_inval_data:1;
707ad2ba64dSKirill Smelkov 
708634734b6SEric Wong 	/** Does the filesystem support readdirplus? */
7090b05b183SAnand V. Avati 	unsigned do_readdirplus:1;
7100b05b183SAnand V. Avati 
711634734b6SEric Wong 	/** Does the filesystem want adaptive readdirplus? */
712634734b6SEric Wong 	unsigned readdirplus_auto:1;
713634734b6SEric Wong 
71460b9df7aSMiklos Szeredi 	/** Does the filesystem support asynchronous direct-IO submission? */
71560b9df7aSMiklos Szeredi 	unsigned async_dio:1;
71660b9df7aSMiklos Szeredi 
7170b5da8dbSRavishankar N 	/** Is lseek not implemented by fs? */
7180b5da8dbSRavishankar N 	unsigned no_lseek:1;
7190b5da8dbSRavishankar N 
72060bcc88aSSeth Forshee 	/** Does the filesystem support posix acls? */
72160bcc88aSSeth Forshee 	unsigned posix_acl:1;
72260bcc88aSSeth Forshee 
72329433a29SMiklos Szeredi 	/** Check permissions based on the file mode or not? */
72429433a29SMiklos Szeredi 	unsigned default_permissions:1;
72529433a29SMiklos Szeredi 
72629433a29SMiklos Szeredi 	/** Allow other than the mounter user to access the filesystem ? */
72729433a29SMiklos Szeredi 	unsigned allow_other:1;
72829433a29SMiklos Szeredi 
72988bc7d50SNiels de Vos 	/** Does the filesystem support copy_file_range? */
73088bc7d50SNiels de Vos 	unsigned no_copy_file_range:1;
73188bc7d50SNiels de Vos 
7321ccd1ea2SMiklos Szeredi 	/* Send DESTROY request */
7331ccd1ea2SMiklos Szeredi 	unsigned int destroy:1;
7341ccd1ea2SMiklos Szeredi 
7358fab0106SMiklos Szeredi 	/* Delete dentries that have gone stale */
7368fab0106SMiklos Szeredi 	unsigned int delete_stale:1;
7378fab0106SMiklos Szeredi 
73815c8e72eSVivek Goyal 	/** Do not create entry in fusectl fs */
73915c8e72eSVivek Goyal 	unsigned int no_control:1;
74015c8e72eSVivek Goyal 
74115c8e72eSVivek Goyal 	/** Do not allow MNT_FORCE umount */
74215c8e72eSVivek Goyal 	unsigned int no_force_umount:1;
74315c8e72eSVivek Goyal 
7440cd5b885SMiklos Szeredi 	/** The number of requests waiting for completion */
7450cd5b885SMiklos Szeredi 	atomic_t num_waiting;
7460cd5b885SMiklos Szeredi 
74745714d65SMiklos Szeredi 	/** Negotiated minor version */
74845714d65SMiklos Szeredi 	unsigned minor;
74945714d65SMiklos Szeredi 
750bafa9654SMiklos Szeredi 	/** Entry on the fuse_conn_list */
751bafa9654SMiklos Szeredi 	struct list_head entry;
752bafa9654SMiklos Szeredi 
753b6f2fcbcSMiklos Szeredi 	/** Device ID from super block */
754b6f2fcbcSMiklos Szeredi 	dev_t dev;
755bafa9654SMiklos Szeredi 
756bafa9654SMiklos Szeredi 	/** Dentries in the control filesystem */
757bafa9654SMiklos Szeredi 	struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
758bafa9654SMiklos Szeredi 
759bafa9654SMiklos Szeredi 	/** number of dentries used in the above array */
760bafa9654SMiklos Szeredi 	int ctl_ndents;
761385a17bfSJeff Dike 
7629c8ef561SMiklos Szeredi 	/** Key for lock owner ID scrambling */
7639c8ef561SMiklos Szeredi 	u32 scramble_key[4];
7640ec7ca41SMiklos Szeredi 
7651fb69e78SMiklos Szeredi 	/** Version counter for attribute changes */
7664510d86fSKirill Tkhai 	atomic64_t attr_version;
76743901aabSTejun Heo 
76843901aabSTejun Heo 	/** Called on final put */
76943901aabSTejun Heo 	void (*release)(struct fuse_conn *);
7703b463ae0SJohn Muir 
7713b463ae0SJohn Muir 	/** Super block for this connection. */
7723b463ae0SJohn Muir 	struct super_block *sb;
7733b463ae0SJohn Muir 
7743b463ae0SJohn Muir 	/** Read/write semaphore to hold when accessing sb. */
7753b463ae0SJohn Muir 	struct rw_semaphore killsb;
776cc080e9eSMiklos Szeredi 
777cc080e9eSMiklos Szeredi 	/** List of device instances belonging to this connection */
778cc080e9eSMiklos Szeredi 	struct list_head devices;
7791dd53957SVivek Goyal 
7801dd53957SVivek Goyal #ifdef CONFIG_FUSE_DAX
7811dd53957SVivek Goyal 	/* Dax specific conn data, non-NULL if DAX is enabled */
7821dd53957SVivek Goyal 	struct fuse_conn_dax *dax;
7831dd53957SVivek Goyal #endif
784d8a5ba45SMiklos Szeredi };
785d8a5ba45SMiklos Szeredi 
786d8a5ba45SMiklos Szeredi static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
787d8a5ba45SMiklos Szeredi {
7886383bdaaSMiklos Szeredi 	return sb->s_fs_info;
789d8a5ba45SMiklos Szeredi }
790d8a5ba45SMiklos Szeredi 
791d8a5ba45SMiklos Szeredi static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
792d8a5ba45SMiklos Szeredi {
793d8a5ba45SMiklos Szeredi 	return get_fuse_conn_super(inode->i_sb);
794d8a5ba45SMiklos Szeredi }
795d8a5ba45SMiklos Szeredi 
796d8a5ba45SMiklos Szeredi static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
797d8a5ba45SMiklos Szeredi {
798d8a5ba45SMiklos Szeredi 	return container_of(inode, struct fuse_inode, inode);
799d8a5ba45SMiklos Szeredi }
800d8a5ba45SMiklos Szeredi 
801d8a5ba45SMiklos Szeredi static inline u64 get_node_id(struct inode *inode)
802d8a5ba45SMiklos Szeredi {
803d8a5ba45SMiklos Szeredi 	return get_fuse_inode(inode)->nodeid;
804d8a5ba45SMiklos Szeredi }
805d8a5ba45SMiklos Szeredi 
806d123d8e1SMiklos Szeredi static inline int invalid_nodeid(u64 nodeid)
807d123d8e1SMiklos Szeredi {
808d123d8e1SMiklos Szeredi 	return !nodeid || nodeid == FUSE_ROOT_ID;
809d123d8e1SMiklos Szeredi }
810d123d8e1SMiklos Szeredi 
8114510d86fSKirill Tkhai static inline u64 fuse_get_attr_version(struct fuse_conn *fc)
8124510d86fSKirill Tkhai {
8134510d86fSKirill Tkhai 	return atomic64_read(&fc->attr_version);
8144510d86fSKirill Tkhai }
8154510d86fSKirill Tkhai 
816334f485dSMiklos Szeredi /** Device operations */
8174b6f5d20SArjan van de Ven extern const struct file_operations fuse_dev_operations;
818334f485dSMiklos Szeredi 
8194269590aSAl Viro extern const struct dentry_operations fuse_dentry_operations;
8200ce267ffSMiklos Szeredi extern const struct dentry_operations fuse_root_dentry_operations;
821dbd561d2SMiklos Szeredi 
822d8a5ba45SMiklos Szeredi /**
8233b463ae0SJohn Muir  * Inode to nodeid comparison.
8243b463ae0SJohn Muir  */
8253b463ae0SJohn Muir int fuse_inode_eq(struct inode *inode, void *_nodeidp);
8263b463ae0SJohn Muir 
8273b463ae0SJohn Muir /**
828e5e5558eSMiklos Szeredi  * Get a filled in inode
829e5e5558eSMiklos Szeredi  */
830b48badf0SMiklos Szeredi struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
8311fb69e78SMiklos Szeredi 			int generation, struct fuse_attr *attr,
8321fb69e78SMiklos Szeredi 			u64 attr_valid, u64 attr_version);
833e5e5558eSMiklos Szeredi 
83413983d06SAl Viro int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name,
83533670fa2SMiklos Szeredi 		     struct fuse_entry_out *outarg, struct inode **inode);
83633670fa2SMiklos Szeredi 
837e5e5558eSMiklos Szeredi /**
838e5e5558eSMiklos Szeredi  * Send FORGET command
839e5e5558eSMiklos Szeredi  */
84007e77dcaSMiklos Szeredi void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget,
841b48badf0SMiklos Szeredi 		       u64 nodeid, u64 nlookup);
842e5e5558eSMiklos Szeredi 
84307e77dcaSMiklos Szeredi struct fuse_forget_link *fuse_alloc_forget(void);
84407e77dcaSMiklos Szeredi 
8454388c5aaSVivek Goyal struct fuse_forget_link *fuse_dequeue_forget(struct fuse_iqueue *fiq,
8464388c5aaSVivek Goyal 					     unsigned int max,
8474388c5aaSVivek Goyal 					     unsigned int *countp);
8484388c5aaSVivek Goyal 
84943f5098eSMiklos Szeredi /*
850361b1eb5SMiklos Szeredi  * Initialize READ or READDIR request
85104730fefSMiklos Szeredi  */
85243f5098eSMiklos Szeredi struct fuse_io_args {
85343f5098eSMiklos Szeredi 	union {
85443f5098eSMiklos Szeredi 		struct {
85543f5098eSMiklos Szeredi 			struct fuse_read_in in;
85643f5098eSMiklos Szeredi 			u64 attr_ver;
85743f5098eSMiklos Szeredi 		} read;
85843f5098eSMiklos Szeredi 		struct {
85943f5098eSMiklos Szeredi 			struct fuse_write_in in;
86043f5098eSMiklos Szeredi 			struct fuse_write_out out;
86143f5098eSMiklos Szeredi 		} write;
86243f5098eSMiklos Szeredi 	};
86343f5098eSMiklos Szeredi 	struct fuse_args_pages ap;
86443f5098eSMiklos Szeredi 	struct fuse_io_priv *io;
86543f5098eSMiklos Szeredi 	struct fuse_file *ff;
86643f5098eSMiklos Szeredi };
86743f5098eSMiklos Szeredi 
86843f5098eSMiklos Szeredi void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos,
86943f5098eSMiklos Szeredi 			 size_t count, int opcode);
87043f5098eSMiklos Szeredi 
87104730fefSMiklos Szeredi 
87204730fefSMiklos Szeredi /**
87304730fefSMiklos Szeredi  * Send OPEN or OPENDIR request
87404730fefSMiklos Szeredi  */
87591fe96b4SMiklos Szeredi int fuse_open_common(struct inode *inode, struct file *file, bool isdir);
87604730fefSMiklos Szeredi 
877acf99433STejun Heo struct fuse_file *fuse_file_alloc(struct fuse_conn *fc);
878fd72faacSMiklos Szeredi void fuse_file_free(struct fuse_file *ff);
879c7b7143cSMiklos Szeredi void fuse_finish_open(struct inode *inode, struct file *file);
880fd72faacSMiklos Szeredi 
881ebf84d0cSKirill Tkhai void fuse_sync_release(struct fuse_inode *fi, struct fuse_file *ff, int flags);
882c756e0a4SMiklos Szeredi 
88304730fefSMiklos Szeredi /**
88404730fefSMiklos Szeredi  * Send RELEASE or RELEASEDIR request
88504730fefSMiklos Szeredi  */
8862e64ff15SChad Austin void fuse_release_common(struct file *file, bool isdir);
88704730fefSMiklos Szeredi 
88804730fefSMiklos Szeredi /**
88982547981SMiklos Szeredi  * Send FSYNC or FSYNCDIR request
89082547981SMiklos Szeredi  */
89102c24a82SJosef Bacik int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
892a9c2d1e8SMiklos Szeredi 		      int datasync, int opcode);
89382547981SMiklos Szeredi 
89482547981SMiklos Szeredi /**
89595668a69STejun Heo  * Notify poll wakeup
89695668a69STejun Heo  */
89795668a69STejun Heo int fuse_notify_poll_wakeup(struct fuse_conn *fc,
89895668a69STejun Heo 			    struct fuse_notify_poll_wakeup_out *outarg);
89995668a69STejun Heo 
90095668a69STejun Heo /**
9011779381dSMiklos Szeredi  * Initialize file operations on a regular file
902b6aeadedSMiklos Szeredi  */
903b6aeadedSMiklos Szeredi void fuse_init_file_inode(struct inode *inode);
904b6aeadedSMiklos Szeredi 
905b6aeadedSMiklos Szeredi /**
9061779381dSMiklos Szeredi  * Initialize inode operations on regular files and special files
907e5e5558eSMiklos Szeredi  */
908e5e5558eSMiklos Szeredi void fuse_init_common(struct inode *inode);
909e5e5558eSMiklos Szeredi 
910e5e5558eSMiklos Szeredi /**
9111779381dSMiklos Szeredi  * Initialize inode and file operations on a directory
912e5e5558eSMiklos Szeredi  */
913e5e5558eSMiklos Szeredi void fuse_init_dir(struct inode *inode);
914e5e5558eSMiklos Szeredi 
915e5e5558eSMiklos Szeredi /**
9161779381dSMiklos Szeredi  * Initialize inode operations on a symlink
917e5e5558eSMiklos Szeredi  */
918e5e5558eSMiklos Szeredi void fuse_init_symlink(struct inode *inode);
919e5e5558eSMiklos Szeredi 
920e5e5558eSMiklos Szeredi /**
921e5e5558eSMiklos Szeredi  * Change attributes of an inode
922e5e5558eSMiklos Szeredi  */
9231fb69e78SMiklos Szeredi void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
9241fb69e78SMiklos Szeredi 			    u64 attr_valid, u64 attr_version);
925e5e5558eSMiklos Szeredi 
9263be5a52bSMiklos Szeredi void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
9273be5a52bSMiklos Szeredi 				   u64 attr_valid);
9283be5a52bSMiklos Szeredi 
929e5e5558eSMiklos Szeredi /**
930334f485dSMiklos Szeredi  * Initialize the client device
931334f485dSMiklos Szeredi  */
932334f485dSMiklos Szeredi int fuse_dev_init(void);
933334f485dSMiklos Szeredi 
934334f485dSMiklos Szeredi /**
935334f485dSMiklos Szeredi  * Cleanup the client device
936334f485dSMiklos Szeredi  */
937334f485dSMiklos Szeredi void fuse_dev_cleanup(void);
938334f485dSMiklos Szeredi 
939bafa9654SMiklos Szeredi int fuse_ctl_init(void);
9407736e8ccSFabian Frederick void __exit fuse_ctl_cleanup(void);
941bafa9654SMiklos Szeredi 
942334f485dSMiklos Szeredi /**
9437078187aSMiklos Szeredi  * Simple request sending that does request allocation and freeing
9447078187aSMiklos Szeredi  */
9457078187aSMiklos Szeredi ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args);
94612597287SMiklos Szeredi int fuse_simple_background(struct fuse_conn *fc, struct fuse_args *args,
94712597287SMiklos Szeredi 			   gfp_t gfp_flags);
9487078187aSMiklos Szeredi 
94904ec5af0SStefan Hajnoczi /**
95004ec5af0SStefan Hajnoczi  * End a finished request
95104ec5af0SStefan Hajnoczi  */
95204ec5af0SStefan Hajnoczi void fuse_request_end(struct fuse_conn *fc, struct fuse_req *req);
95304ec5af0SStefan Hajnoczi 
9545a5fb1eaSMiklos Szeredi /* Abort all requests */
955eb98e3bdSMiklos Szeredi void fuse_abort_conn(struct fuse_conn *fc);
956b8f95e5dSMiklos Szeredi void fuse_wait_aborted(struct fuse_conn *fc);
95769a53bf2SMiklos Szeredi 
9581e9a4ed9SMiklos Szeredi /**
959e5e5558eSMiklos Szeredi  * Invalidate inode attributes
960e5e5558eSMiklos Szeredi  */
961e5e5558eSMiklos Szeredi void fuse_invalidate_attr(struct inode *inode);
962bafa9654SMiklos Szeredi 
963dbd561d2SMiklos Szeredi void fuse_invalidate_entry_cache(struct dentry *entry);
964dbd561d2SMiklos Szeredi 
965451418fcSAndrew Gallagher void fuse_invalidate_atime(struct inode *inode);
966451418fcSAndrew Gallagher 
967d123d8e1SMiklos Szeredi u64 entry_attr_timeout(struct fuse_entry_out *o);
968d123d8e1SMiklos Szeredi void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o);
969d123d8e1SMiklos Szeredi 
970bafa9654SMiklos Szeredi /**
971bafa9654SMiklos Szeredi  * Acquire reference to fuse_conn
972bafa9654SMiklos Szeredi  */
973bafa9654SMiklos Szeredi struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
974bafa9654SMiklos Szeredi 
975bafa9654SMiklos Szeredi /**
9760d179aa5STejun Heo  * Initialize fuse_conn
9770d179aa5STejun Heo  */
978ae3aad77SStefan Hajnoczi void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns,
979ae3aad77SStefan Hajnoczi 		    const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv);
9800d179aa5STejun Heo 
9810d179aa5STejun Heo /**
982bafa9654SMiklos Szeredi  * Release reference to fuse_conn
983bafa9654SMiklos Szeredi  */
984bafa9654SMiklos Szeredi void fuse_conn_put(struct fuse_conn *fc);
985bafa9654SMiklos Szeredi 
9860cd1eb9aSVivek Goyal struct fuse_dev *fuse_dev_alloc_install(struct fuse_conn *fc);
9870cd1eb9aSVivek Goyal struct fuse_dev *fuse_dev_alloc(void);
9880cd1eb9aSVivek Goyal void fuse_dev_install(struct fuse_dev *fud, struct fuse_conn *fc);
989cc080e9eSMiklos Szeredi void fuse_dev_free(struct fuse_dev *fud);
99095a84cdbSVivek Goyal void fuse_send_init(struct fuse_conn *fc);
991cc080e9eSMiklos Szeredi 
992bafa9654SMiklos Szeredi /**
9930cc2656cSStefan Hajnoczi  * Fill in superblock and initialize fuse connection
9940cc2656cSStefan Hajnoczi  * @sb: partially-initialized superblock to fill in
9950cc2656cSStefan Hajnoczi  * @ctx: mount context
9960cc2656cSStefan Hajnoczi  */
9970cc2656cSStefan Hajnoczi int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx);
9980cc2656cSStefan Hajnoczi 
9990cc2656cSStefan Hajnoczi /**
1000783863d6SMiklos Szeredi  * Disassociate fuse connection from superblock and kill the superblock
1001783863d6SMiklos Szeredi  *
1002783863d6SMiklos Szeredi  * Calls kill_anon_super(), do not use with bdev mounts.
1003783863d6SMiklos Szeredi  */
1004783863d6SMiklos Szeredi void fuse_kill_sb_anon(struct super_block *sb);
1005783863d6SMiklos Szeredi 
1006783863d6SMiklos Szeredi /**
1007bafa9654SMiklos Szeredi  * Add connection to control filesystem
1008bafa9654SMiklos Szeredi  */
1009bafa9654SMiklos Szeredi int fuse_ctl_add_conn(struct fuse_conn *fc);
1010bafa9654SMiklos Szeredi 
1011bafa9654SMiklos Szeredi /**
1012bafa9654SMiklos Szeredi  * Remove connection from control filesystem
1013bafa9654SMiklos Szeredi  */
1014bafa9654SMiklos Szeredi void fuse_ctl_remove_conn(struct fuse_conn *fc);
1015a5bfffacSTimo Savola 
1016a5bfffacSTimo Savola /**
1017a5bfffacSTimo Savola  * Is file type valid?
1018a5bfffacSTimo Savola  */
1019a5bfffacSTimo Savola int fuse_valid_type(int m);
1020e57ac683SMiklos Szeredi 
1021eb59bd17SMiklos Szeredi bool fuse_invalid_attr(struct fuse_attr *attr);
1022eb59bd17SMiklos Szeredi 
1023e57ac683SMiklos Szeredi /**
1024c2132c1bSAnatol Pomozov  * Is current process allowed to perform filesystem operation?
1025e57ac683SMiklos Szeredi  */
1026c2132c1bSAnatol Pomozov int fuse_allow_current_process(struct fuse_conn *fc);
1027f3332114SMiklos Szeredi 
1028f3332114SMiklos Szeredi u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
1029bcb4be80SMiklos Szeredi 
1030703c7362SSeth Forshee void fuse_update_ctime(struct inode *inode);
1031703c7362SSeth Forshee 
10325b97eeacSMiklos Szeredi int fuse_update_attributes(struct inode *inode, struct file *file);
10333be5a52bSMiklos Szeredi 
10343be5a52bSMiklos Szeredi void fuse_flush_writepages(struct inode *inode);
10353be5a52bSMiklos Szeredi 
10363be5a52bSMiklos Szeredi void fuse_set_nowrite(struct inode *inode);
10373be5a52bSMiklos Szeredi void fuse_release_nowrite(struct inode *inode);
10385c5c5e51SMiklos Szeredi 
10393b463ae0SJohn Muir /**
10403b463ae0SJohn Muir  * File-system tells the kernel to invalidate cache for the given node id.
10413b463ae0SJohn Muir  */
10423b463ae0SJohn Muir int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
10433b463ae0SJohn Muir 			     loff_t offset, loff_t len);
10443b463ae0SJohn Muir 
10453b463ae0SJohn Muir /**
10463b463ae0SJohn Muir  * File-system tells the kernel to invalidate parent attributes and
10473b463ae0SJohn Muir  * the dentry matching parent/name.
1048451d0f59SJohn Muir  *
1049451d0f59SJohn Muir  * If the child_nodeid is non-zero and:
1050451d0f59SJohn Muir  *    - matches the inode number for the dentry matching parent/name,
1051451d0f59SJohn Muir  *    - is not a mount point
1052451d0f59SJohn Muir  *    - is a file or oan empty directory
1053451d0f59SJohn Muir  * then the dentry is unhashed (d_delete()).
10543b463ae0SJohn Muir  */
10553b463ae0SJohn Muir int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
1056451d0f59SJohn Muir 			     u64 child_nodeid, struct qstr *name);
10573b463ae0SJohn Muir 
105808cbf542STejun Heo int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
105908cbf542STejun Heo 		 bool isdir);
1060ea8cd333SPavel Emelyanov 
1061ea8cd333SPavel Emelyanov /**
1062ea8cd333SPavel Emelyanov  * fuse_direct_io() flags
1063ea8cd333SPavel Emelyanov  */
1064ea8cd333SPavel Emelyanov 
1065ea8cd333SPavel Emelyanov /** If set, it is WRITE; otherwise - READ */
1066ea8cd333SPavel Emelyanov #define FUSE_DIO_WRITE (1 << 0)
1067ea8cd333SPavel Emelyanov 
1068ea8cd333SPavel Emelyanov /** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */
1069ea8cd333SPavel Emelyanov #define FUSE_DIO_CUSE  (1 << 1)
1070ea8cd333SPavel Emelyanov 
1071d22a943fSAl Viro ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
1072d22a943fSAl Viro 		       loff_t *ppos, int flags);
107308cbf542STejun Heo long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
107408cbf542STejun Heo 		   unsigned int flags);
1075b18da0c5SMiklos Szeredi long fuse_ioctl_common(struct file *file, unsigned int cmd,
1076b18da0c5SMiklos Szeredi 		       unsigned long arg, unsigned int flags);
1077076ccb76SAl Viro __poll_t fuse_file_poll(struct file *file, poll_table *wait);
107808cbf542STejun Heo int fuse_dev_release(struct inode *inode, struct file *file);
107908cbf542STejun Heo 
1080b0aa7606SMaxim Patlasov bool fuse_write_update_size(struct inode *inode, loff_t pos);
1081b0aa7606SMaxim Patlasov 
1082ab9e13f7SMaxim Patlasov int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
10831e18bda8SMiklos Szeredi int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
1084a1d75f25SMiklos Szeredi 
108562490330SJan Kara int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1086efb9fa9eSMaxim Patlasov 		    struct file *file);
1087efb9fa9eSMaxim Patlasov 
10889759bd51SMiklos Szeredi void fuse_set_initialized(struct fuse_conn *fc);
10899759bd51SMiklos Szeredi 
109063576c13SMiklos Szeredi void fuse_unlock_inode(struct inode *inode, bool locked);
109163576c13SMiklos Szeredi bool fuse_lock_inode(struct inode *inode);
10925c672ab3SMiklos Szeredi 
109360bcc88aSSeth Forshee int fuse_setxattr(struct inode *inode, const char *name, const void *value,
109460bcc88aSSeth Forshee 		  size_t size, int flags);
109560bcc88aSSeth Forshee ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value,
109660bcc88aSSeth Forshee 		      size_t size);
1097703c7362SSeth Forshee ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
109860bcc88aSSeth Forshee int fuse_removexattr(struct inode *inode, const char *name);
1099703c7362SSeth Forshee extern const struct xattr_handler *fuse_xattr_handlers[];
110060bcc88aSSeth Forshee extern const struct xattr_handler *fuse_acl_xattr_handlers[];
1101e45b2546SEric W. Biederman extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
110260bcc88aSSeth Forshee 
110360bcc88aSSeth Forshee struct posix_acl;
110460bcc88aSSeth Forshee struct posix_acl *fuse_get_acl(struct inode *inode, int type);
110560bcc88aSSeth Forshee int fuse_set_acl(struct inode *inode, struct posix_acl *acl, int type);
1106703c7362SSeth Forshee 
1107d123d8e1SMiklos Szeredi 
1108d123d8e1SMiklos Szeredi /* readdir.c */
1109d123d8e1SMiklos Szeredi int fuse_readdir(struct file *file, struct dir_context *ctx);
1110d123d8e1SMiklos Szeredi 
111114d46d7aSStefan Hajnoczi /**
111214d46d7aSStefan Hajnoczi  * Return the number of bytes in an arguments list
111314d46d7aSStefan Hajnoczi  */
111414d46d7aSStefan Hajnoczi unsigned int fuse_len_args(unsigned int numargs, struct fuse_arg *args);
111514d46d7aSStefan Hajnoczi 
111679d96effSStefan Hajnoczi /**
111779d96effSStefan Hajnoczi  * Get the next unique ID for a request
111879d96effSStefan Hajnoczi  */
111979d96effSStefan Hajnoczi u64 fuse_get_unique(struct fuse_iqueue *fiq);
1120783863d6SMiklos Szeredi void fuse_free_conn(struct fuse_conn *fc);
112179d96effSStefan Hajnoczi 
11221dd53957SVivek Goyal /* dax.c */
11231dd53957SVivek Goyal 
1124c2d0ad00SVivek Goyal #define FUSE_IS_DAX(inode) (IS_ENABLED(CONFIG_FUSE_DAX) && IS_DAX(inode))
1125c2d0ad00SVivek Goyal 
1126c2d0ad00SVivek Goyal ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to);
1127c2d0ad00SVivek Goyal ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from);
1128c2d0ad00SVivek Goyal int fuse_dax_mmap(struct file *file, struct vm_area_struct *vma);
11296ae330caSVivek Goyal int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, u64 dmap_end);
11301dd53957SVivek Goyal int fuse_dax_conn_alloc(struct fuse_conn *fc, struct dax_device *dax_dev);
11311dd53957SVivek Goyal void fuse_dax_conn_free(struct fuse_conn *fc);
1132c2d0ad00SVivek Goyal bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi);
1133c2d0ad00SVivek Goyal void fuse_dax_inode_init(struct inode *inode);
1134c2d0ad00SVivek Goyal void fuse_dax_inode_cleanup(struct inode *inode);
1135fd1a1dc6SStefan Hajnoczi bool fuse_dax_check_alignment(struct fuse_conn *fc, unsigned int map_alignment);
11369a752d18SVivek Goyal void fuse_dax_cancel_work(struct fuse_conn *fc);
11371dd53957SVivek Goyal 
113829d434b3STejun Heo #endif /* _FS_FUSE_I_H */
1139