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