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