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