Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * (C) 2001 Clemson University and The University of Chicago
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * See COPYING in top-level directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "protocol.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "orangefs-kernel.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "orangefs-bufmap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/parser.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/hashtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* a cache for orangefs-inode objects (i.e. orangefs inode private data) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) static struct kmem_cache *orangefs_inode_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* list for storing orangefs specific superblocks in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) LIST_HEAD(orangefs_superblocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) DEFINE_SPINLOCK(orangefs_superblocks_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	Opt_intr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	Opt_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	Opt_local_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	Opt_err
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static const match_table_t tokens = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	{ Opt_acl,		"acl" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	{ Opt_intr,		"intr" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	{ Opt_local_lock,	"local_lock" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	{ Opt_err,	NULL }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) uint64_t orangefs_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static int orangefs_show_options(struct seq_file *m, struct dentry *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(root->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	if (root->d_sb->s_flags & SB_POSIXACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		seq_puts(m, ",acl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	if (orangefs_sb->flags & ORANGEFS_OPT_INTR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		seq_puts(m, ",intr");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	if (orangefs_sb->flags & ORANGEFS_OPT_LOCAL_LOCK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		seq_puts(m, ",local_lock");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static int parse_mount_options(struct super_block *sb, char *options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		int silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	substring_t args[MAX_OPT_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 * Force any potential flags that might be set from the mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 * to zero, ie, initialize to unset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	sb->s_flags &= ~SB_POSIXACL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	orangefs_sb->flags &= ~ORANGEFS_OPT_INTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	orangefs_sb->flags &= ~ORANGEFS_OPT_LOCAL_LOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	while ((p = strsep(&options, ",")) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		int token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		if (!*p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		token = match_token(p, tokens, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		switch (token) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		case Opt_acl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			sb->s_flags |= SB_POSIXACL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		case Opt_intr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			orangefs_sb->flags |= ORANGEFS_OPT_INTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		case Opt_local_lock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			orangefs_sb->flags |= ORANGEFS_OPT_LOCAL_LOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		gossip_err("Error: mount option [%s] is not supported.\n", p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static void orangefs_inode_cache_ctor(void *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	struct orangefs_inode_s *orangefs_inode = req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	inode_init_once(&orangefs_inode->vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	init_rwsem(&orangefs_inode->xattr_sem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static struct inode *orangefs_alloc_inode(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	struct orangefs_inode_s *orangefs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (!orangefs_inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	 * We want to clear everything except for rw_semaphore and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	 * vfs_inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	memset(&orangefs_inode->refn.khandle, 0, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	orangefs_inode->refn.fs_id = ORANGEFS_FS_ID_NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	orangefs_inode->last_failed_block_index_read = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	memset(orangefs_inode->link_target, 0, sizeof(orangefs_inode->link_target));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		     "orangefs_alloc_inode: allocated %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		     &orangefs_inode->vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	return &orangefs_inode->vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static void orangefs_free_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct orangefs_cached_xattr *cx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	struct hlist_node *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	hash_for_each_safe(orangefs_inode->xattr_cache, i, tmp, cx, node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		hlist_del(&cx->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		kfree(cx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	kmem_cache_free(orangefs_inode_cache, orangefs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static void orangefs_destroy_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			"%s: deallocated %p destroying inode %pU\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			__func__, orangefs_inode, get_khandle_from_ino(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static int orangefs_write_inode(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				struct writeback_control *wbc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_write_inode\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return orangefs_inode_setattr(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * NOTE: information filled in here is typically reflected in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * output of the system command 'df'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	int ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	struct orangefs_kernel_op_s *new_op = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	struct super_block *sb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	sb = dentry->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			"%s: called on sb %p (fs_id is %d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			__func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 			sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			(int)(ORANGEFS_SB(sb)->fs_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	new_op = op_alloc(ORANGEFS_VFS_OP_STATFS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if (!new_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	new_op->upcall.req.statfs.fs_id = ORANGEFS_SB(sb)->fs_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	if (ORANGEFS_SB(sb)->flags & ORANGEFS_OPT_INTR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		flags = ORANGEFS_OP_INTERRUPTIBLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	ret = service_operation(new_op, "orangefs_statfs", flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (new_op->downcall.status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		goto out_op_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		     "%s: got %ld blocks available | "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		     "%ld blocks total | %ld block size | "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		     "%ld files total | %ld files avail\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		     __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		     (long)new_op->downcall.resp.statfs.blocks_avail,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		     (long)new_op->downcall.resp.statfs.blocks_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		     (long)new_op->downcall.resp.statfs.block_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		     (long)new_op->downcall.resp.statfs.files_total,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		     (long)new_op->downcall.resp.statfs.files_avail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	buf->f_type = sb->s_magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	memcpy(&buf->f_fsid, &ORANGEFS_SB(sb)->fs_id, sizeof(buf->f_fsid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	buf->f_bsize = new_op->downcall.resp.statfs.block_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	buf->f_namelen = ORANGEFS_NAME_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	buf->f_blocks = (sector_t) new_op->downcall.resp.statfs.blocks_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	buf->f_bfree = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	buf->f_bavail = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	buf->f_files = (sector_t) new_op->downcall.resp.statfs.files_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	buf->f_ffree = (sector_t) new_op->downcall.resp.statfs.files_avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	buf->f_frsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) out_op_release:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	op_release(new_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	gossip_debug(GOSSIP_SUPER_DEBUG, "%s: returning %d\n", __func__, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * Remount as initiated by VFS layer.  We just need to reparse the mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * options, no need to signal pvfs2-client-core about it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static int orangefs_remount_fs(struct super_block *sb, int *flags, char *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount_fs: called\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	return parse_mount_options(sb, data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * Remount as initiated by pvfs2-client-core on restart.  This is used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  * repopulate mount information left from previous pvfs2-client-core.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * the idea here is that given a valid superblock, we're
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * re-initializing the user space client with the initial mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * information specified when the super block was first initialized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * this is very different than the first initialization/creation of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  * superblock.  we use the special service_priority_operation to make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  * sure that the mount gets ahead of any other pending operation that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  * is waiting for servicing.  this means that the pvfs2-client won't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * fail to start several times for all other pending operations before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  * the client regains all of the mount information from us.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * NOTE: this function assumes that the request_mutex is already acquired!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct orangefs_kernel_op_s *new_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount: called\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (!new_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		orangefs_sb->devname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		ORANGEFS_MAX_SERVER_ADDR_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		     "Attempting ORANGEFS Remount via host %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		     new_op->upcall.req.fs_mount.orangefs_config_server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	 * we assume that the calling function has already acquired the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	 * request_mutex to prevent other operations from bypassing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	 * this one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	ret = service_operation(new_op, "orangefs_remount",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		     "orangefs_remount: mount got return value of %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		     ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	if (ret == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		 * store the id assigned to this sb -- it's just a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		 * short-lived mapping that the system interface uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		 * to map this superblock to a particular mount entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		orangefs_sb->id = new_op->downcall.resp.fs_mount.id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		orangefs_sb->mount_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	op_release(new_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	if (orangefs_userspace_version >= 20906) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		if (!new_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		new_op->upcall.req.features.features = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		ret = service_operation(new_op, "orangefs_features",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		    ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			orangefs_features =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 			    new_op->downcall.resp.features.features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 			orangefs_features = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		op_release(new_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		orangefs_features = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) int fsid_key_table_initialize(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) void fsid_key_table_finalize(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) static const struct super_operations orangefs_s_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	.alloc_inode = orangefs_alloc_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	.free_inode = orangefs_free_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	.destroy_inode = orangefs_destroy_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	.write_inode = orangefs_write_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	.drop_inode = generic_delete_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	.statfs = orangefs_statfs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	.remount_fs = orangefs_remount_fs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	.show_options = orangefs_show_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) static struct dentry *orangefs_fh_to_dentry(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 				  struct fid *fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 				  int fh_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 				  int fh_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	struct orangefs_object_kref refn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	if (fh_len < 5 || fh_type > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	ORANGEFS_khandle_from(&(refn.khandle), fid->raw, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	refn.fs_id = (u32) fid->raw[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		     "fh_to_dentry: handle %pU, fs_id %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		     &refn.khandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		     refn.fs_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	return d_obtain_alias(orangefs_iget(sb, &refn));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static int orangefs_encode_fh(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		    __u32 *fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		    int *max_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		    struct inode *parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	int len = parent ? 10 : 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	int type = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	struct orangefs_object_kref refn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	if (*max_len < len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		gossip_err("fh buffer is too small for encoding\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		*max_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		type = 255;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	refn = ORANGEFS_I(inode)->refn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	ORANGEFS_khandle_to(&refn.khandle, fh, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	fh[4] = refn.fs_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		     "Encoding fh: handle %pU, fsid %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		     &refn.khandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		     refn.fs_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	if (parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		refn = ORANGEFS_I(parent)->refn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		ORANGEFS_khandle_to(&refn.khandle, (char *) fh + 20, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		fh[9] = refn.fs_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		type = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 			     "Encoding parent: handle %pU, fsid %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			     &refn.khandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 			     refn.fs_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	*max_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	return type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) static const struct export_operations orangefs_export_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	.encode_fh = orangefs_encode_fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	.fh_to_dentry = orangefs_fh_to_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	struct orangefs_kernel_op_s *op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	op = op_alloc(ORANGEFS_VFS_OP_FS_UMOUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	if (!op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	op->upcall.req.fs_umount.id = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	op->upcall.req.fs_umount.fs_id = fs_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	strncpy(op->upcall.req.fs_umount.orangefs_config_server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	    devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	r = service_operation(op, "orangefs_fs_umount", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	/* Not much to do about an error here. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	if (r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		gossip_err("orangefs_unmount: service_operation %d\n", r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	op_release(op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) static int orangefs_fill_sb(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		struct orangefs_fs_mount_response *fs_mount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		void *data, int silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	struct inode *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	struct dentry *root_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	struct orangefs_object_kref root_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	ORANGEFS_SB(sb)->sb = sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	ORANGEFS_SB(sb)->root_khandle = fs_mount->root_khandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	ORANGEFS_SB(sb)->fs_id = fs_mount->fs_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	ORANGEFS_SB(sb)->id = fs_mount->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	if (data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		ret = parse_mount_options(sb, data, silent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	/* Hang the xattr handlers off the superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	sb->s_xattr = orangefs_xattr_handlers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	sb->s_magic = ORANGEFS_SUPER_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	sb->s_op = &orangefs_s_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	sb->s_d_op = &orangefs_dentry_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	sb->s_blocksize = PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	sb->s_blocksize_bits = PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	sb->s_maxbytes = MAX_LFS_FILESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	ret = super_setup_bdi(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	root_object.khandle = ORANGEFS_SB(sb)->root_khandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	root_object.fs_id = ORANGEFS_SB(sb)->fs_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 		     "get inode %pU, fsid %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		     &root_object.khandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		     root_object.fs_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	root = orangefs_iget(sb, &root_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	if (IS_ERR(root))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		return PTR_ERR(root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		     "Allocated root inode [%p] with mode %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		     root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		     root->i_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	/* allocates and places root dentry in dcache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	root_dentry = d_make_root(root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	if (!root_dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	sb->s_export_op = &orangefs_export_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	sb->s_root = root_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) struct dentry *orangefs_mount(struct file_system_type *fst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 			   int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 			   const char *devname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 			   void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	struct super_block *sb = ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	struct orangefs_kernel_op_s *new_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	struct dentry *d = ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		     "orangefs_mount: called with devname %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		     devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	if (!devname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 		gossip_err("ERROR: device name not specified.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	if (!new_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 		devname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		     "Attempting ORANGEFS Mount via host %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		     new_op->upcall.req.fs_mount.orangefs_config_server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	ret = service_operation(new_op, "orangefs_mount", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		     "orangefs_mount: mount got return value of %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		goto free_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	if (new_op->downcall.resp.fs_mount.fs_id == ORANGEFS_FS_ID_NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		gossip_err("ERROR: Retrieved null fs_id\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		goto free_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	sb = sget(fst, NULL, set_anon_super, flags, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	if (IS_ERR(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		d = ERR_CAST(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		orangefs_unmount(new_op->downcall.resp.fs_mount.id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		    new_op->downcall.resp.fs_mount.fs_id, devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		goto free_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	/* alloc and init our private orangefs sb info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	sb->s_fs_info = kzalloc(sizeof(struct orangefs_sb_info_s), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	if (!ORANGEFS_SB(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		d = ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		goto free_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	ret = orangefs_fill_sb(sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	      &new_op->downcall.resp.fs_mount, data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	      flags & SB_SILENT ? 1 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 		d = ERR_PTR(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 		goto free_sb_and_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	 * on successful mount, store the devname and data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	 * used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	strncpy(ORANGEFS_SB(sb)->devname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		devname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	/* mount_pending must be cleared */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	ORANGEFS_SB(sb)->mount_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	 * finally, add this sb to our list of known orangefs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	 * sb's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	gossip_debug(GOSSIP_SUPER_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 		     "Adding SB %p to orangefs superblocks\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 		     ORANGEFS_SB(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	spin_lock(&orangefs_superblocks_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	list_add_tail(&ORANGEFS_SB(sb)->list, &orangefs_superblocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	spin_unlock(&orangefs_superblocks_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	op_release(new_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	/* Must be removed from the list now. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	ORANGEFS_SB(sb)->no_list = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	if (orangefs_userspace_version >= 20906) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 		new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		if (!new_op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 			return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 		new_op->upcall.req.features.features = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 		ret = service_operation(new_op, "orangefs_features", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		orangefs_features = new_op->downcall.resp.features.features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		op_release(new_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 		orangefs_features = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	return dget(sb->s_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) free_sb_and_op:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	/* Will call orangefs_kill_sb with sb not in list. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	ORANGEFS_SB(sb)->no_list = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	/* ORANGEFS_VFS_OP_FS_UMOUNT is done by orangefs_kill_sb. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	deactivate_locked_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) free_op:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	gossip_err("orangefs_mount: mount request failed with %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	if (ret == -EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		gossip_err("Ensure that all orangefs-servers have the same FS configuration files\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 		gossip_err("Look at pvfs2-client-core log file (typically /tmp/pvfs2-client.log) for more details\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	op_release(new_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	return d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) void orangefs_kill_sb(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_kill_sb: called\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	/* provided sb cleanup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	kill_anon_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	if (!ORANGEFS_SB(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		mutex_lock(&orangefs_request_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 		mutex_unlock(&orangefs_request_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	 * issue the unmount to userspace to tell it to remove the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	 * dynamic mount info it has for this superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	r = orangefs_unmount(ORANGEFS_SB(sb)->id, ORANGEFS_SB(sb)->fs_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	    ORANGEFS_SB(sb)->devname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	if (!r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 		ORANGEFS_SB(sb)->mount_pending = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	if (!ORANGEFS_SB(sb)->no_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		/* remove the sb from our list of orangefs specific sb's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		spin_lock(&orangefs_superblocks_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 		/* not list_del_init */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 		__list_del_entry(&ORANGEFS_SB(sb)->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		ORANGEFS_SB(sb)->list.prev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 		spin_unlock(&orangefs_superblocks_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	 * make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	 * gets completed before we free the dang thing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	mutex_lock(&orangefs_request_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	mutex_unlock(&orangefs_request_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	/* free the orangefs superblock private data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	kfree(ORANGEFS_SB(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) int orangefs_inode_cache_initialize(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	orangefs_inode_cache = kmem_cache_create_usercopy(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 					"orangefs_inode_cache",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 					sizeof(struct orangefs_inode_s),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 					0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 					ORANGEFS_CACHE_CREATE_FLAGS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 					offsetof(struct orangefs_inode_s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 						link_target),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 					sizeof_field(struct orangefs_inode_s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 						link_target),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 					orangefs_inode_cache_ctor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	if (!orangefs_inode_cache) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 		gossip_err("Cannot create orangefs_inode_cache\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) int orangefs_inode_cache_finalize(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	kmem_cache_destroy(orangefs_inode_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) }