xref: /openbmc/linux/fs/orangefs/orangefs-kernel.h (revision 913e9928)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2575e9461SMike Marshall /*
3575e9461SMike Marshall  * (C) 2001 Clemson University and The University of Chicago
4575e9461SMike Marshall  *
5575e9461SMike Marshall  * See COPYING in top-level directory.
6575e9461SMike Marshall  */
7575e9461SMike Marshall 
8575e9461SMike Marshall /*
9575e9461SMike Marshall  *  The ORANGEFS Linux kernel support allows ORANGEFS volumes to be mounted and
10575e9461SMike Marshall  *  accessed through the Linux VFS (i.e. using standard I/O system calls).
11575e9461SMike Marshall  *  This support is only needed on clients that wish to mount the file system.
12575e9461SMike Marshall  *
13575e9461SMike Marshall  */
14575e9461SMike Marshall 
15575e9461SMike Marshall /*
16575e9461SMike Marshall  *  Declarations and macros for the ORANGEFS Linux kernel support.
17575e9461SMike Marshall  */
18575e9461SMike Marshall 
19575e9461SMike Marshall #ifndef __ORANGEFSKERNEL_H
20575e9461SMike Marshall #define __ORANGEFSKERNEL_H
21575e9461SMike Marshall 
22575e9461SMike Marshall #include <linux/kernel.h>
23575e9461SMike Marshall #include <linux/moduleparam.h>
24575e9461SMike Marshall #include <linux/statfs.h>
25575e9461SMike Marshall #include <linux/backing-dev.h>
26575e9461SMike Marshall #include <linux/device.h>
27575e9461SMike Marshall #include <linux/mpage.h>
28575e9461SMike Marshall #include <linux/namei.h>
29575e9461SMike Marshall #include <linux/errno.h>
30575e9461SMike Marshall #include <linux/init.h>
31575e9461SMike Marshall #include <linux/module.h>
32575e9461SMike Marshall #include <linux/slab.h>
33575e9461SMike Marshall #include <linux/types.h>
34575e9461SMike Marshall #include <linux/fs.h>
35575e9461SMike Marshall #include <linux/vmalloc.h>
36575e9461SMike Marshall 
37575e9461SMike Marshall #include <linux/aio.h>
38575e9461SMike Marshall #include <linux/posix_acl.h>
39575e9461SMike Marshall #include <linux/posix_acl_xattr.h>
40575e9461SMike Marshall #include <linux/compat.h>
41575e9461SMike Marshall #include <linux/mount.h>
42575e9461SMike Marshall #include <linux/uaccess.h>
43575e9461SMike Marshall #include <linux/atomic.h>
44575e9461SMike Marshall #include <linux/uio.h>
45174cd4b1SIngo Molnar #include <linux/sched/signal.h>
46575e9461SMike Marshall #include <linux/mm.h>
47575e9461SMike Marshall #include <linux/wait.h>
48575e9461SMike Marshall #include <linux/dcache.h>
49575e9461SMike Marshall #include <linux/pagemap.h>
50575e9461SMike Marshall #include <linux/poll.h>
51575e9461SMike Marshall #include <linux/rwsem.h>
52575e9461SMike Marshall #include <linux/xattr.h>
53575e9461SMike Marshall #include <linux/exportfs.h>
54fc2e2e9cSMartin Brandenburg #include <linux/hashtable.h>
55575e9461SMike Marshall 
56575e9461SMike Marshall #include <asm/unaligned.h>
57575e9461SMike Marshall 
58575e9461SMike Marshall #include "orangefs-dev-proto.h"
59575e9461SMike Marshall 
60575e9461SMike Marshall #define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS       20
61575e9461SMike Marshall 
62575e9461SMike Marshall #define ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS   30
63575e9461SMike Marshall 
64575e9461SMike Marshall #define ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS     900	/* 15 minutes */
65575e9461SMike Marshall 
66575e9461SMike Marshall #define ORANGEFS_REQDEVICE_NAME          "pvfs2-req"
67575e9461SMike Marshall 
68575e9461SMike Marshall #define ORANGEFS_DEVREQ_MAGIC             0x20030529
69575e9461SMike Marshall #define ORANGEFS_PURGE_RETRY_COUNT     0x00000005
70575e9461SMike Marshall 
71575e9461SMike Marshall #define MAX_DEV_REQ_UPSIZE (2 * sizeof(__s32) +   \
72575e9461SMike Marshall sizeof(__u64) + sizeof(struct orangefs_upcall_s))
73575e9461SMike Marshall #define MAX_DEV_REQ_DOWNSIZE (2 * sizeof(__s32) + \
74575e9461SMike Marshall sizeof(__u64) + sizeof(struct orangefs_downcall_s))
75575e9461SMike Marshall 
76575e9461SMike Marshall /*
77575e9461SMike Marshall  * valid orangefs kernel operation states
78575e9461SMike Marshall  *
79575e9461SMike Marshall  * unknown  - op was just initialized
80575e9461SMike Marshall  * waiting  - op is on request_list (upward bound)
81575e9461SMike Marshall  * inprogr  - op is in progress (waiting for downcall)
82575e9461SMike Marshall  * serviced - op has matching downcall; ok
83575e9461SMike Marshall  * purged   - op has to start a timer since client-core
84575e9461SMike Marshall  *            exited uncleanly before servicing op
85ed42fe05SAl Viro  * given up - submitter has given up waiting for it
86575e9461SMike Marshall  */
87575e9461SMike Marshall enum orangefs_vfs_op_states {
88575e9461SMike Marshall 	OP_VFS_STATE_UNKNOWN = 0,
89575e9461SMike Marshall 	OP_VFS_STATE_WAITING = 1,
90575e9461SMike Marshall 	OP_VFS_STATE_INPROGR = 2,
91575e9461SMike Marshall 	OP_VFS_STATE_SERVICED = 4,
92575e9461SMike Marshall 	OP_VFS_STATE_PURGED = 8,
93ed42fe05SAl Viro 	OP_VFS_STATE_GIVEN_UP = 16,
94575e9461SMike Marshall };
95575e9461SMike Marshall 
96575e9461SMike Marshall /*
97575e9461SMike Marshall  * orangefs kernel memory related flags
98575e9461SMike Marshall  */
99575e9461SMike Marshall 
100538e3048SMartin Brandenburg #if (defined CONFIG_DEBUG_SLAB)
101575e9461SMike Marshall #define ORANGEFS_CACHE_CREATE_FLAGS SLAB_RED_ZONE
102575e9461SMike Marshall #else
103575e9461SMike Marshall #define ORANGEFS_CACHE_CREATE_FLAGS 0
104538e3048SMartin Brandenburg #endif
105575e9461SMike Marshall 
106575e9461SMike Marshall extern const struct xattr_handler *orangefs_xattr_handlers[];
107575e9461SMike Marshall 
1080cad6246SMiklos Szeredi extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type, bool rcu);
10913e83a49SChristian Brauner extern int orangefs_set_acl(struct mnt_idmap *idmap,
110138060baSChristian Brauner 			    struct dentry *dentry, struct posix_acl *acl,
111549c7297SChristian Brauner 			    int type);
1124053d250SChristian Brauner int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
113575e9461SMike Marshall 
114575e9461SMike Marshall /*
115575e9461SMike Marshall  * orangefs data structures
116575e9461SMike Marshall  */
117575e9461SMike Marshall struct orangefs_kernel_op_s {
118575e9461SMike Marshall 	enum orangefs_vfs_op_states op_state;
119575e9461SMike Marshall 	__u64 tag;
120575e9461SMike Marshall 
121575e9461SMike Marshall 	/*
122d37c0f30SMike Marshall 	 * Set uses_shared_memory to non zero if this operation uses
123d37c0f30SMike Marshall 	 * shared memory. If true, then a retry on the op must also
124d37c0f30SMike Marshall 	 * get a new shared memory buffer and re-populate it.
125d37c0f30SMike Marshall 	 * Cancels don't care - it only matters for service_operation()
126d37c0f30SMike Marshall 	 * retry logics and cancels don't go through it anymore. It
127d37c0f30SMike Marshall 	 * safely stays non-zero when we use it as slot_to_free.
128575e9461SMike Marshall 	 */
12978699e29SAl Viro 	union {
130575e9461SMike Marshall 		int uses_shared_memory;
13178699e29SAl Viro 		int slot_to_free;
13278699e29SAl Viro 	};
133575e9461SMike Marshall 
134575e9461SMike Marshall 	struct orangefs_upcall_s upcall;
135575e9461SMike Marshall 	struct orangefs_downcall_s downcall;
136575e9461SMike Marshall 
137d2d87a3bSAl Viro 	struct completion waitq;
138575e9461SMike Marshall 	spinlock_t lock;
139575e9461SMike Marshall 
140575e9461SMike Marshall 	int attempts;
141575e9461SMike Marshall 
142575e9461SMike Marshall 	struct list_head list;
143575e9461SMike Marshall };
144575e9461SMike Marshall 
14560831949SAl Viro #define set_op_state_waiting(op)     ((op)->op_state = OP_VFS_STATE_WAITING)
14660831949SAl Viro #define set_op_state_inprogress(op)  ((op)->op_state = OP_VFS_STATE_INPROGR)
1472d4cae0dSMike Marshall #define set_op_state_given_up(op)  ((op)->op_state = OP_VFS_STATE_GIVEN_UP)
set_op_state_serviced(struct orangefs_kernel_op_s * op)14860831949SAl Viro static inline void set_op_state_serviced(struct orangefs_kernel_op_s *op)
14960831949SAl Viro {
15060831949SAl Viro 	op->op_state = OP_VFS_STATE_SERVICED;
151d2d87a3bSAl Viro 	complete(&op->waitq);
15260831949SAl Viro }
15360831949SAl Viro 
15460831949SAl Viro #define op_state_waiting(op)     ((op)->op_state & OP_VFS_STATE_WAITING)
15560831949SAl Viro #define op_state_in_progress(op) ((op)->op_state & OP_VFS_STATE_INPROGR)
15660831949SAl Viro #define op_state_serviced(op)    ((op)->op_state & OP_VFS_STATE_SERVICED)
15760831949SAl Viro #define op_state_purged(op)      ((op)->op_state & OP_VFS_STATE_PURGED)
158ed42fe05SAl Viro #define op_state_given_up(op)    ((op)->op_state & OP_VFS_STATE_GIVEN_UP)
15978699e29SAl Viro #define op_is_cancel(op)         ((op)->upcall.type == ORANGEFS_VFS_OP_CANCEL)
160ed42fe05SAl Viro 
161c1223ca4SAl Viro void op_release(struct orangefs_kernel_op_s *op);
16260831949SAl Viro 
16378699e29SAl Viro extern void orangefs_bufmap_put(int);
put_cancel(struct orangefs_kernel_op_s * op)16478699e29SAl Viro static inline void put_cancel(struct orangefs_kernel_op_s *op)
16578699e29SAl Viro {
16678699e29SAl Viro 	orangefs_bufmap_put(op->slot_to_free);
16778699e29SAl Viro 	op_release(op);
16878699e29SAl Viro }
16978699e29SAl Viro 
set_op_state_purged(struct orangefs_kernel_op_s * op)17078699e29SAl Viro static inline void set_op_state_purged(struct orangefs_kernel_op_s *op)
17178699e29SAl Viro {
17278699e29SAl Viro 	spin_lock(&op->lock);
17378699e29SAl Viro 	if (unlikely(op_is_cancel(op))) {
17405a50a5bSAl Viro 		list_del_init(&op->list);
17578699e29SAl Viro 		spin_unlock(&op->lock);
17678699e29SAl Viro 		put_cancel(op);
17778699e29SAl Viro 	} else {
17878699e29SAl Viro 		op->op_state |= OP_VFS_STATE_PURGED;
179d2d87a3bSAl Viro 		complete(&op->waitq);
18078699e29SAl Viro 		spin_unlock(&op->lock);
18178699e29SAl Viro 	}
18278699e29SAl Viro }
18378699e29SAl Viro 
184575e9461SMike Marshall /* per inode private orangefs info */
185575e9461SMike Marshall struct orangefs_inode_s {
186575e9461SMike Marshall 	struct orangefs_object_kref refn;
187575e9461SMike Marshall 	char link_target[ORANGEFS_NAME_MAX];
188575e9461SMike Marshall 	/*
189575e9461SMike Marshall 	 * Reading/Writing Extended attributes need to acquire the appropriate
190575e9461SMike Marshall 	 * reader/writer semaphore on the orangefs_inode_s structure.
191575e9461SMike Marshall 	 */
192575e9461SMike Marshall 	struct rw_semaphore xattr_sem;
193575e9461SMike Marshall 
194575e9461SMike Marshall 	struct inode vfs_inode;
195575e9461SMike Marshall 	sector_t last_failed_block_index_read;
196575e9461SMike Marshall 
19771680c18SMartin Brandenburg 	unsigned long getattr_time;
1988f04e1beSMartin Brandenburg 	unsigned long mapping_time;
199afd9fb2aSMartin Brandenburg 	int attr_valid;
200afd9fb2aSMartin Brandenburg 	kuid_t attr_uid;
201afd9fb2aSMartin Brandenburg 	kgid_t attr_gid;
2028f04e1beSMartin Brandenburg 	unsigned long bitlock;
203fc2e2e9cSMartin Brandenburg 
204fc2e2e9cSMartin Brandenburg 	DECLARE_HASHTABLE(xattr_cache, 4);
205575e9461SMike Marshall };
206575e9461SMike Marshall 
207575e9461SMike Marshall /* per superblock private orangefs info */
208575e9461SMike Marshall struct orangefs_sb_info_s {
209575e9461SMike Marshall 	struct orangefs_khandle root_khandle;
210575e9461SMike Marshall 	__s32 fs_id;
211575e9461SMike Marshall 	int id;
212575e9461SMike Marshall 	int flags;
213575e9461SMike Marshall #define ORANGEFS_OPT_INTR	0x01
214575e9461SMike Marshall #define ORANGEFS_OPT_LOCAL_LOCK	0x02
215575e9461SMike Marshall 	char devname[ORANGEFS_MAX_SERVER_ADDR_LEN];
216575e9461SMike Marshall 	struct super_block *sb;
217575e9461SMike Marshall 	int mount_pending;
2181ec1688cSMartin Brandenburg 	int no_list;
219575e9461SMike Marshall 	struct list_head list;
220575e9461SMike Marshall };
221575e9461SMike Marshall 
222575e9461SMike Marshall struct orangefs_stats {
223575e9461SMike Marshall 	unsigned long cache_hits;
224575e9461SMike Marshall 	unsigned long cache_misses;
225575e9461SMike Marshall 	unsigned long reads;
226575e9461SMike Marshall 	unsigned long writes;
227575e9461SMike Marshall };
228575e9461SMike Marshall 
229fc2e2e9cSMartin Brandenburg struct orangefs_cached_xattr {
230fc2e2e9cSMartin Brandenburg 	struct hlist_node node;
231fc2e2e9cSMartin Brandenburg 	char key[ORANGEFS_MAX_XATTR_NAMELEN];
232fc2e2e9cSMartin Brandenburg 	char val[ORANGEFS_MAX_XATTR_VALUELEN];
233fc2e2e9cSMartin Brandenburg 	ssize_t length;
234fc2e2e9cSMartin Brandenburg 	unsigned long timeout;
235fc2e2e9cSMartin Brandenburg };
236fc2e2e9cSMartin Brandenburg 
23752e2d0a3SMartin Brandenburg struct orangefs_write_range {
23852e2d0a3SMartin Brandenburg 	loff_t pos;
23952e2d0a3SMartin Brandenburg 	size_t len;
24052e2d0a3SMartin Brandenburg 	kuid_t uid;
24152e2d0a3SMartin Brandenburg 	kgid_t gid;
24252e2d0a3SMartin Brandenburg };
24352e2d0a3SMartin Brandenburg 
244889d5f1bSMartin Brandenburg extern struct orangefs_stats orangefs_stats;
245575e9461SMike Marshall 
246575e9461SMike Marshall /*
24725b532ceSMauro Carvalho Chehab  * NOTE: See Documentation/filesystems/porting.rst for information
248575e9461SMike Marshall  * on implementing FOO_I and properly accessing fs private data
249575e9461SMike Marshall  */
ORANGEFS_I(struct inode * inode)250575e9461SMike Marshall static inline struct orangefs_inode_s *ORANGEFS_I(struct inode *inode)
251575e9461SMike Marshall {
252575e9461SMike Marshall 	return container_of(inode, struct orangefs_inode_s, vfs_inode);
253575e9461SMike Marshall }
254575e9461SMike Marshall 
ORANGEFS_SB(struct super_block * sb)255575e9461SMike Marshall static inline struct orangefs_sb_info_s *ORANGEFS_SB(struct super_block *sb)
256575e9461SMike Marshall {
257575e9461SMike Marshall 	return (struct orangefs_sb_info_s *) sb->s_fs_info;
258575e9461SMike Marshall }
259575e9461SMike Marshall 
260575e9461SMike Marshall /* ino_t descends from "unsigned long", 8 bytes, 64 bits. */
orangefs_khandle_to_ino(struct orangefs_khandle * khandle)261575e9461SMike Marshall static inline ino_t orangefs_khandle_to_ino(struct orangefs_khandle *khandle)
262575e9461SMike Marshall {
263575e9461SMike Marshall 	union {
264575e9461SMike Marshall 		unsigned char u[8];
265575e9461SMike Marshall 		__u64 ino;
266575e9461SMike Marshall 	} ihandle;
267575e9461SMike Marshall 
268575e9461SMike Marshall 	ihandle.u[0] = khandle->u[0] ^ khandle->u[4];
269575e9461SMike Marshall 	ihandle.u[1] = khandle->u[1] ^ khandle->u[5];
270575e9461SMike Marshall 	ihandle.u[2] = khandle->u[2] ^ khandle->u[6];
271575e9461SMike Marshall 	ihandle.u[3] = khandle->u[3] ^ khandle->u[7];
272575e9461SMike Marshall 	ihandle.u[4] = khandle->u[12] ^ khandle->u[8];
273575e9461SMike Marshall 	ihandle.u[5] = khandle->u[13] ^ khandle->u[9];
274575e9461SMike Marshall 	ihandle.u[6] = khandle->u[14] ^ khandle->u[10];
275575e9461SMike Marshall 	ihandle.u[7] = khandle->u[15] ^ khandle->u[11];
276575e9461SMike Marshall 
277575e9461SMike Marshall 	return ihandle.ino;
278575e9461SMike Marshall }
279575e9461SMike Marshall 
get_khandle_from_ino(struct inode * inode)280575e9461SMike Marshall static inline struct orangefs_khandle *get_khandle_from_ino(struct inode *inode)
281575e9461SMike Marshall {
282575e9461SMike Marshall 	return &(ORANGEFS_I(inode)->refn.khandle);
283575e9461SMike Marshall }
284575e9461SMike Marshall 
is_root_handle(struct inode * inode)285575e9461SMike Marshall static inline int is_root_handle(struct inode *inode)
286575e9461SMike Marshall {
287575e9461SMike Marshall 	gossip_debug(GOSSIP_DCACHE_DEBUG,
288575e9461SMike Marshall 		     "%s: root handle: %pU, this handle: %pU:\n",
289575e9461SMike Marshall 		     __func__,
290575e9461SMike Marshall 		     &ORANGEFS_SB(inode->i_sb)->root_khandle,
291575e9461SMike Marshall 		     get_khandle_from_ino(inode));
292575e9461SMike Marshall 
293575e9461SMike Marshall 	if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode->i_sb)->root_khandle),
294575e9461SMike Marshall 			     get_khandle_from_ino(inode)))
295575e9461SMike Marshall 		return 0;
296575e9461SMike Marshall 	else
297575e9461SMike Marshall 		return 1;
298575e9461SMike Marshall }
299575e9461SMike Marshall 
match_handle(struct orangefs_khandle resp_handle,struct inode * inode)300575e9461SMike Marshall static inline int match_handle(struct orangefs_khandle resp_handle,
301575e9461SMike Marshall 			       struct inode *inode)
302575e9461SMike Marshall {
303575e9461SMike Marshall 	gossip_debug(GOSSIP_DCACHE_DEBUG,
304575e9461SMike Marshall 		     "%s: one handle: %pU, another handle:%pU:\n",
305575e9461SMike Marshall 		     __func__,
306575e9461SMike Marshall 		     &resp_handle,
307575e9461SMike Marshall 		     get_khandle_from_ino(inode));
308575e9461SMike Marshall 
309575e9461SMike Marshall 	if (ORANGEFS_khandle_cmp(&resp_handle, get_khandle_from_ino(inode)))
310575e9461SMike Marshall 		return 0;
311575e9461SMike Marshall 	else
312575e9461SMike Marshall 		return 1;
313575e9461SMike Marshall }
314575e9461SMike Marshall 
315575e9461SMike Marshall /*
316575e9461SMike Marshall  * defined in orangefs-cache.c
317575e9461SMike Marshall  */
318575e9461SMike Marshall int op_cache_initialize(void);
319575e9461SMike Marshall int op_cache_finalize(void);
320575e9461SMike Marshall struct orangefs_kernel_op_s *op_alloc(__s32 type);
32178699e29SAl Viro void orangefs_new_tag(struct orangefs_kernel_op_s *op);
322575e9461SMike Marshall char *get_opname_string(struct orangefs_kernel_op_s *new_op);
323575e9461SMike Marshall 
324575e9461SMike Marshall int orangefs_inode_cache_initialize(void);
325575e9461SMike Marshall int orangefs_inode_cache_finalize(void);
326575e9461SMike Marshall 
327575e9461SMike Marshall /*
328575e9461SMike Marshall  * defined in orangefs-mod.c
329575e9461SMike Marshall  */
330575e9461SMike Marshall void purge_inprogress_ops(void);
331575e9461SMike Marshall 
332575e9461SMike Marshall /*
333575e9461SMike Marshall  * defined in waitqueue.c
334575e9461SMike Marshall  */
335575e9461SMike Marshall void purge_waiting_ops(void);
336575e9461SMike Marshall 
337575e9461SMike Marshall /*
338575e9461SMike Marshall  * defined in super.c
339575e9461SMike Marshall  */
340482664ddSMartin Brandenburg extern uint64_t orangefs_features;
341482664ddSMartin Brandenburg 
342575e9461SMike Marshall struct dentry *orangefs_mount(struct file_system_type *fst,
343575e9461SMike Marshall 			   int flags,
344575e9461SMike Marshall 			   const char *devname,
345575e9461SMike Marshall 			   void *data);
346575e9461SMike Marshall 
347575e9461SMike Marshall void orangefs_kill_sb(struct super_block *sb);
34845996492SAl Viro int orangefs_remount(struct orangefs_sb_info_s *);
349575e9461SMike Marshall 
350575e9461SMike Marshall int fsid_key_table_initialize(void);
351575e9461SMike Marshall void fsid_key_table_finalize(void);
352575e9461SMike Marshall 
353575e9461SMike Marshall /*
354575e9461SMike Marshall  * defined in inode.c
355575e9461SMike Marshall  */
35652e2d0a3SMartin Brandenburg vm_fault_t orangefs_page_mkwrite(struct vm_fault *);
357575e9461SMike Marshall struct inode *orangefs_new_inode(struct super_block *sb,
358575e9461SMike Marshall 			      struct inode *dir,
3594053d250SChristian Brauner 			      umode_t mode,
360575e9461SMike Marshall 			      dev_t dev,
361575e9461SMike Marshall 			      struct orangefs_object_kref *ref);
362575e9461SMike Marshall 
363afd9fb2aSMartin Brandenburg int __orangefs_setattr(struct inode *, struct iattr *);
364138060baSChristian Brauner int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr);
365c1632a0fSChristian Brauner int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
366575e9461SMike Marshall 
367b74d24f7SChristian Brauner int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
368549c7297SChristian Brauner 		     struct kstat *stat, u32 request_mask, unsigned int flags);
369575e9461SMike Marshall 
3704609e1f1SChristian Brauner int orangefs_permission(struct mnt_idmap *idmap,
371549c7297SChristian Brauner 			struct inode *inode, int mask);
372933287daSMartin Brandenburg 
373*913e9928SJeff Layton int orangefs_update_time(struct inode *, int);
374a55f2d86SMartin Brandenburg 
375575e9461SMike Marshall /*
376575e9461SMike Marshall  * defined in xattr.c
377575e9461SMike Marshall  */
378575e9461SMike Marshall ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size);
379575e9461SMike Marshall 
380575e9461SMike Marshall /*
381575e9461SMike Marshall  * defined in namei.c
382575e9461SMike Marshall  */
383575e9461SMike Marshall struct inode *orangefs_iget(struct super_block *sb,
384575e9461SMike Marshall 			 struct orangefs_object_kref *ref);
385575e9461SMike Marshall 
386575e9461SMike Marshall /*
387575e9461SMike Marshall  * defined in devorangefs-req.c
388575e9461SMike Marshall  */
389482664ddSMartin Brandenburg extern uint32_t orangefs_userspace_version;
390f2ee3b75SMartin Brandenburg 
391575e9461SMike Marshall int orangefs_dev_init(void);
392575e9461SMike Marshall void orangefs_dev_cleanup(void);
393575e9461SMike Marshall int is_daemon_in_service(void);
39478699e29SAl Viro bool __is_daemon_in_service(void);
395575e9461SMike Marshall 
396575e9461SMike Marshall /*
397c453dcfcSMartin Brandenburg  * defined in file.c
398c453dcfcSMartin Brandenburg  */
3998f04e1beSMartin Brandenburg int orangefs_revalidate_mapping(struct inode *);
400c453dcfcSMartin Brandenburg ssize_t wait_for_direct_io(enum ORANGEFS_io_type, struct inode *, loff_t *,
401f9bbb682SMike Marshall     struct iov_iter *, size_t, loff_t, struct orangefs_write_range *, int *,
402f9bbb682SMike Marshall     struct file *);
403c453dcfcSMartin Brandenburg ssize_t do_readv_writev(enum ORANGEFS_io_type, struct file *, loff_t *,
404c453dcfcSMartin Brandenburg     struct iov_iter *);
405c453dcfcSMartin Brandenburg 
406c453dcfcSMartin Brandenburg /*
407575e9461SMike Marshall  * defined in orangefs-utils.c
408575e9461SMike Marshall  */
409575e9461SMike Marshall __s32 fsid_of_op(struct orangefs_kernel_op_s *op);
410575e9461SMike Marshall 
411575e9461SMike Marshall ssize_t orangefs_inode_getxattr(struct inode *inode,
412575e9461SMike Marshall 			     const char *name,
413575e9461SMike Marshall 			     void *buffer,
414575e9461SMike Marshall 			     size_t size);
415575e9461SMike Marshall 
416575e9461SMike Marshall int orangefs_inode_setxattr(struct inode *inode,
417575e9461SMike Marshall 			 const char *name,
418575e9461SMike Marshall 			 const void *value,
419575e9461SMike Marshall 			 size_t size,
420575e9461SMike Marshall 			 int flags);
421575e9461SMike Marshall 
4228b60785cSMartin Brandenburg #define ORANGEFS_GETATTR_NEW 1
4238b60785cSMartin Brandenburg #define ORANGEFS_GETATTR_SIZE 2
4248b60785cSMartin Brandenburg 
4258b60785cSMartin Brandenburg int orangefs_inode_getattr(struct inode *, int);
426575e9461SMike Marshall 
4275859d77eSMartin Brandenburg int orangefs_inode_check_changed(struct inode *inode);
4285859d77eSMartin Brandenburg 
429afd9fb2aSMartin Brandenburg int orangefs_inode_setattr(struct inode *inode);
430575e9461SMike Marshall 
43178699e29SAl Viro bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op);
432575e9461SMike Marshall 
433575e9461SMike Marshall int orangefs_normalize_to_errno(__s32 error_code);
434575e9461SMike Marshall 
4351d503617SMartin Brandenburg extern struct mutex orangefs_request_mutex;
436575e9461SMike Marshall extern int op_timeout_secs;
437575e9461SMike Marshall extern int slot_timeout_secs;
4388f04e1beSMartin Brandenburg extern int orangefs_cache_timeout_msecs;
4391d503617SMartin Brandenburg extern int orangefs_dcache_timeout_msecs;
4401d503617SMartin Brandenburg extern int orangefs_getattr_timeout_msecs;
441575e9461SMike Marshall extern struct list_head orangefs_superblocks;
442575e9461SMike Marshall extern spinlock_t orangefs_superblocks_lock;
443575e9461SMike Marshall extern struct list_head orangefs_request_list;
444575e9461SMike Marshall extern spinlock_t orangefs_request_list_lock;
445575e9461SMike Marshall extern wait_queue_head_t orangefs_request_list_waitq;
4461d503617SMartin Brandenburg extern struct list_head *orangefs_htable_ops_in_progress;
4471d503617SMartin Brandenburg extern spinlock_t orangefs_htable_ops_in_progress_lock;
448575e9461SMike Marshall extern int hash_table_size;
449575e9461SMike Marshall 
450575e9461SMike Marshall extern const struct file_operations orangefs_file_operations;
4516f3fc107SAl Viro extern const struct inode_operations orangefs_symlink_inode_operations;
4526f3fc107SAl Viro extern const struct inode_operations orangefs_dir_inode_operations;
453575e9461SMike Marshall extern const struct file_operations orangefs_dir_operations;
454575e9461SMike Marshall extern const struct dentry_operations orangefs_dentry_operations;
455575e9461SMike Marshall 
456575e9461SMike Marshall /*
457575e9461SMike Marshall  * misc convenience macros
458575e9461SMike Marshall  */
459575e9461SMike Marshall 
460575e9461SMike Marshall #define ORANGEFS_OP_INTERRUPTIBLE 1   /* service_operation() is interruptible */
461575e9461SMike Marshall #define ORANGEFS_OP_PRIORITY      2   /* service_operation() is high priority */
462575e9461SMike Marshall #define ORANGEFS_OP_CANCELLATION  4   /* this is a cancellation */
463adcf34a2SMike Marshall #define ORANGEFS_OP_NO_MUTEX      8   /* don't acquire request_mutex */
464575e9461SMike Marshall #define ORANGEFS_OP_ASYNC         16  /* Queue it, but don't wait */
4650dcac0f7SMartin Brandenburg #define ORANGEFS_OP_WRITEBACK     32
466575e9461SMike Marshall 
467575e9461SMike Marshall int service_operation(struct orangefs_kernel_op_s *op,
468575e9461SMike Marshall 		      const char *op_name,
469575e9461SMike Marshall 		      int flags);
470575e9461SMike Marshall 
471575e9461SMike Marshall #define get_interruptible_flag(inode) \
472575e9461SMike Marshall 	((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \
473575e9461SMike Marshall 		ORANGEFS_OP_INTERRUPTIBLE : 0)
474575e9461SMike Marshall 
475575e9461SMike Marshall #define fill_default_sys_attrs(sys_attr, type, mode)			\
476575e9461SMike Marshall do {									\
47778fee0b6SJann Horn 	sys_attr.owner = from_kuid(&init_user_ns, current_fsuid()); \
47878fee0b6SJann Horn 	sys_attr.group = from_kgid(&init_user_ns, current_fsgid()); \
479575e9461SMike Marshall 	sys_attr.perms = ORANGEFS_util_translate_mode(mode);		\
48069a23de2SMartin Brandenburg 	sys_attr.mtime = 0;						\
48169a23de2SMartin Brandenburg 	sys_attr.atime = 0;						\
48269a23de2SMartin Brandenburg 	sys_attr.ctime = 0;						\
483575e9461SMike Marshall 	sys_attr.mask = ORANGEFS_ATTR_SYS_ALL_SETABLE;			\
484575e9461SMike Marshall } while (0)
485575e9461SMike Marshall 
orangefs_set_timeout(struct dentry * dentry)486804b1737SMiklos Szeredi static inline void orangefs_set_timeout(struct dentry *dentry)
487804b1737SMiklos Szeredi {
488804b1737SMiklos Szeredi 	unsigned long time = jiffies + orangefs_dcache_timeout_msecs*HZ/1000;
489804b1737SMiklos Szeredi 
490804b1737SMiklos Szeredi 	dentry->d_fsdata = (void *) time;
491804b1737SMiklos Szeredi }
492804b1737SMiklos Szeredi 
493575e9461SMike Marshall #endif /* __ORANGEFSKERNEL_H */
494