Merge with Linux 2.5.74.
[linux-2.6/linux-mips.git] / fs / xfs / linux / xfs_super.c
blob0df0d915865f6966494a510688bd3ece5c97a328
1 /*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
26 * http://www.sgi.com
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 #include "xfs.h"
35 #include "xfs_inum.h"
36 #include "xfs_log.h"
37 #include "xfs_clnt.h"
38 #include "xfs_trans.h"
39 #include "xfs_sb.h"
40 #include "xfs_dir.h"
41 #include "xfs_dir2.h"
42 #include "xfs_alloc.h"
43 #include "xfs_dmapi.h"
44 #include "xfs_quota.h"
45 #include "xfs_mount.h"
46 #include "xfs_alloc_btree.h"
47 #include "xfs_bmap_btree.h"
48 #include "xfs_ialloc_btree.h"
49 #include "xfs_btree.h"
50 #include "xfs_ialloc.h"
51 #include "xfs_attr_sf.h"
52 #include "xfs_dir_sf.h"
53 #include "xfs_dir2_sf.h"
54 #include "xfs_dinode.h"
55 #include "xfs_inode.h"
56 #include "xfs_bmap.h"
57 #include "xfs_bit.h"
58 #include "xfs_rtalloc.h"
59 #include "xfs_error.h"
60 #include "xfs_itable.h"
61 #include "xfs_rw.h"
62 #include "xfs_acl.h"
63 #include "xfs_cap.h"
64 #include "xfs_mac.h"
65 #include "xfs_attr.h"
66 #include "xfs_buf_item.h"
67 #include "xfs_utils.h"
68 #include "xfs_version.h"
70 #include <linux/blkdev.h>
71 #include <linux/namei.h>
72 #include <linux/init.h>
73 #include <linux/mount.h>
75 STATIC struct quotactl_ops linvfs_qops;
76 STATIC struct super_operations linvfs_sops;
77 STATIC struct export_operations linvfs_export_ops;
78 STATIC kmem_cache_t * linvfs_inode_cachep;
80 STATIC struct xfs_mount_args *
81 args_allocate(
82 struct super_block *sb)
84 struct xfs_mount_args *args;
86 args = kmem_zalloc(sizeof(struct xfs_mount_args), KM_SLEEP);
87 args->logbufs = args->logbufsize = -1;
88 strncpy(args->fsname, sb->s_id, MAXNAMELEN);
90 /* Copy the already-parsed mount(2) flags we're interested in */
91 if (sb->s_flags & MS_NOATIME)
92 args->flags |= XFSMNT_NOATIME;
94 /* Default to 32 bit inodes on Linux all the time */
95 args->flags |= XFSMNT_32BITINODES;
97 return args;
100 STATIC __inline__ void
101 xfs_set_inodeops(
102 struct inode *inode)
104 vnode_t *vp = LINVFS_GET_VP(inode);
106 if (vp->v_type == VNON) {
107 make_bad_inode(inode);
108 } else if (S_ISREG(inode->i_mode)) {
109 inode->i_op = &linvfs_file_inode_operations;
110 inode->i_fop = &linvfs_file_operations;
111 inode->i_mapping->a_ops = &linvfs_aops;
112 } else if (S_ISDIR(inode->i_mode)) {
113 inode->i_op = &linvfs_dir_inode_operations;
114 inode->i_fop = &linvfs_dir_operations;
115 } else if (S_ISLNK(inode->i_mode)) {
116 inode->i_op = &linvfs_symlink_inode_operations;
117 if (inode->i_blocks)
118 inode->i_mapping->a_ops = &linvfs_aops;
119 } else {
120 inode->i_op = &linvfs_file_inode_operations;
121 init_special_inode(inode, inode->i_mode,
122 kdev_t_to_nr(inode->i_rdev));
126 STATIC __inline__ void
127 xfs_revalidate_inode(
128 xfs_mount_t *mp,
129 vnode_t *vp,
130 xfs_inode_t *ip)
132 struct inode *inode = LINVFS_GET_IP(vp);
134 inode->i_mode = (ip->i_d.di_mode & MODEMASK) | VTTOIF(vp->v_type);
135 inode->i_nlink = ip->i_d.di_nlink;
136 inode->i_uid = ip->i_d.di_uid;
137 inode->i_gid = ip->i_d.di_gid;
138 if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) {
139 inode->i_rdev = NODEV;
140 } else {
141 xfs_dev_t dev = ip->i_df.if_u2.if_rdev;
142 inode->i_rdev = XFS_DEV_TO_KDEVT(dev);
144 inode->i_blksize = PAGE_CACHE_SIZE;
145 inode->i_generation = ip->i_d.di_gen;
146 inode->i_size = ip->i_d.di_size;
147 inode->i_blocks =
148 XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
149 inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
150 inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
151 inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
152 inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
153 inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
154 inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
156 vp->v_flag &= ~VMODIFIED;
159 void
160 xfs_initialize_vnode(
161 bhv_desc_t *bdp,
162 vnode_t *vp,
163 bhv_desc_t *inode_bhv,
164 int unlock)
166 xfs_inode_t *ip = XFS_BHVTOI(inode_bhv);
167 struct inode *inode = LINVFS_GET_IP(vp);
169 if (!inode_bhv->bd_vobj) {
170 vp->v_vfsp = bhvtovfs(bdp);
171 bhv_desc_init(inode_bhv, ip, vp, &xfs_vnodeops);
172 bhv_insert(VN_BHV_HEAD(vp), inode_bhv);
175 vp->v_type = IFTOVT(ip->i_d.di_mode);
177 /* Have we been called during the new inode create process,
178 * in which case we are too early to fill in the Linux inode.
180 if (vp->v_type == VNON)
181 return;
183 xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
185 /* For new inodes we need to set the ops vectors,
186 * and unlock the inode.
188 if (unlock && (inode->i_state & I_NEW)) {
189 xfs_set_inodeops(inode);
190 unlock_new_inode(inode);
195 xfs_blkdev_get(
196 xfs_mount_t *mp,
197 const char *name,
198 struct block_device **bdevp)
200 int error = 0;
202 *bdevp = open_bdev_excl(name, 0, BDEV_FS, mp);
203 if (IS_ERR(*bdevp)) {
204 error = PTR_ERR(*bdevp);
205 printk("XFS: Invalid device [%s], error=%d\n", name, error);
208 return -error;
211 void
212 xfs_blkdev_put(
213 struct block_device *bdev)
215 if (bdev)
216 close_bdev_excl(bdev, BDEV_FS);
219 void
220 xfs_flush_buftarg(
221 xfs_buftarg_t *btp)
223 pagebuf_delwri_flush(btp, PBDF_WAIT, NULL);
226 void
227 xfs_free_buftarg(
228 xfs_buftarg_t *btp)
230 xfs_flush_buftarg(btp);
231 kmem_free(btp, sizeof(*btp));
235 xfs_readonly_buftarg(
236 xfs_buftarg_t *btp)
238 return bdev_read_only(btp->pbr_bdev);
241 void
242 xfs_relse_buftarg(
243 xfs_buftarg_t *btp)
245 invalidate_bdev(btp->pbr_bdev, 1);
246 truncate_inode_pages(btp->pbr_mapping, 0LL);
249 unsigned int
250 xfs_getsize_buftarg(
251 xfs_buftarg_t *btp)
253 return block_size(btp->pbr_bdev);
256 void
257 xfs_setsize_buftarg(
258 xfs_buftarg_t *btp,
259 unsigned int blocksize,
260 unsigned int sectorsize)
262 btp->pbr_bsize = blocksize;
263 btp->pbr_sshift = ffs(sectorsize) - 1;
264 btp->pbr_smask = sectorsize - 1;
266 if (set_blocksize(btp->pbr_bdev, sectorsize)) {
267 printk(KERN_WARNING
268 "XFS: Cannot set_blocksize to %u on device 0x%x\n",
269 sectorsize, btp->pbr_dev);
273 xfs_buftarg_t *
274 xfs_alloc_buftarg(
275 struct block_device *bdev)
277 xfs_buftarg_t *btp;
279 btp = kmem_zalloc(sizeof(*btp), KM_SLEEP);
281 btp->pbr_dev = bdev->bd_dev;
282 btp->pbr_bdev = bdev;
283 btp->pbr_mapping = bdev->bd_inode->i_mapping;
284 xfs_setsize_buftarg(btp, PAGE_CACHE_SIZE, bdev_hardsect_size(bdev));
286 return btp;
289 STATIC __inline__ unsigned int gfp_mask(void)
291 /* If we're not in a transaction, FS activity is ok */
292 if (current->flags & PF_FSTRANS) return GFP_NOFS;
293 return GFP_KERNEL;
296 STATIC struct inode *
297 linvfs_alloc_inode(
298 struct super_block *sb)
300 vnode_t *vp;
302 vp = (vnode_t *)kmem_cache_alloc(linvfs_inode_cachep, gfp_mask());
303 if (!vp)
304 return NULL;
305 return LINVFS_GET_IP(vp);
308 STATIC void
309 linvfs_destroy_inode(
310 struct inode *inode)
312 kmem_cache_free(linvfs_inode_cachep, LINVFS_GET_VP(inode));
315 STATIC void
316 init_once(
317 void *data,
318 kmem_cache_t *cachep,
319 unsigned long flags)
321 vnode_t *vp = (vnode_t *)data;
323 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
324 SLAB_CTOR_CONSTRUCTOR)
325 inode_init_once(LINVFS_GET_IP(vp));
328 STATIC int
329 init_inodecache( void )
331 linvfs_inode_cachep = kmem_cache_create("linvfs_icache",
332 sizeof(vnode_t), 0,
333 SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
334 init_once, NULL);
336 if (linvfs_inode_cachep == NULL)
337 return -ENOMEM;
338 return 0;
341 STATIC void
342 destroy_inodecache( void )
344 if (kmem_cache_destroy(linvfs_inode_cachep))
345 printk(KERN_WARNING "%s: cache still in use!\n", __FUNCTION__);
349 * Attempt to flush the inode, this will actually fail
350 * if the inode is pinned, but we dirty the inode again
351 * at the point when it is unpinned after a log write,
352 * since this is when the inode itself becomes flushable.
354 STATIC void
355 linvfs_write_inode(
356 struct inode *inode,
357 int sync)
359 vnode_t *vp = LINVFS_GET_VP(inode);
360 int error, flags = FLUSH_INODE;
362 if (vp) {
363 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
364 if (sync)
365 flags |= FLUSH_SYNC;
366 VOP_IFLUSH(vp, flags, error);
370 STATIC void
371 linvfs_clear_inode(
372 struct inode *inode)
374 vnode_t *vp = LINVFS_GET_VP(inode);
376 if (vp) {
377 vn_rele(vp);
378 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
380 * Do all our cleanup, and remove this vnode.
382 vn_remove(vp);
387 #define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR)
389 STATIC int
390 syncd(void *arg)
392 vfs_t *vfsp = (vfs_t *) arg;
393 int error;
395 daemonize("xfs_syncd");
397 vfsp->vfs_sync_task = current;
398 wmb();
399 wake_up(&vfsp->vfs_wait_sync_task);
401 for (;;) {
402 set_current_state(TASK_INTERRUPTIBLE);
403 schedule_timeout(xfs_params.sync_interval);
404 if (vfsp->vfs_flag & VFS_UMOUNT)
405 break;
406 if (vfsp->vfs_flag & VFS_RDONLY)
407 continue;
408 VFS_SYNC(vfsp, SYNCD_FLAGS, NULL, error);
411 vfsp->vfs_sync_task = NULL;
412 wmb();
413 wake_up(&vfsp->vfs_wait_sync_task);
415 return 0;
418 STATIC int
419 linvfs_start_syncd(vfs_t *vfsp)
421 int pid;
423 pid = kernel_thread(syncd, (void *) vfsp,
424 CLONE_VM | CLONE_FS | CLONE_FILES);
425 if (pid < 0)
426 return pid;
427 wait_event(vfsp->vfs_wait_sync_task, vfsp->vfs_sync_task);
428 return 0;
431 STATIC void
432 linvfs_stop_syncd(vfs_t *vfsp)
434 vfsp->vfs_flag |= VFS_UMOUNT;
435 wmb();
437 wake_up_process(vfsp->vfs_sync_task);
438 wait_event(vfsp->vfs_wait_sync_task, !vfsp->vfs_sync_task);
441 STATIC void
442 linvfs_put_super(
443 struct super_block *sb)
445 vfs_t *vfsp = LINVFS_GET_VFS(sb);
446 int error;
448 linvfs_stop_syncd(vfsp);
449 VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error);
450 if (!error)
451 VFS_UNMOUNT(vfsp, 0, NULL, error);
452 if (error) {
453 printk("XFS unmount got error %d\n", error);
454 printk("%s: vfsp/0x%p left dangling!\n", __FUNCTION__, vfsp);
455 return;
458 vfs_deallocate(vfsp);
461 STATIC void
462 linvfs_write_super(
463 struct super_block *sb)
465 vfs_t *vfsp = LINVFS_GET_VFS(sb);
466 int error;
468 if (sb->s_flags & MS_RDONLY) {
469 sb->s_dirt = 0; /* paranoia */
470 return;
472 /* Push the log and superblock a little */
473 VFS_SYNC(vfsp, SYNC_FSDATA, NULL, error);
474 sb->s_dirt = 0;
477 STATIC int
478 linvfs_statfs(
479 struct super_block *sb,
480 struct kstatfs *statp)
482 vfs_t *vfsp = LINVFS_GET_VFS(sb);
483 int error;
485 VFS_STATVFS(vfsp, statp, NULL, error);
486 return -error;
489 STATIC int
490 linvfs_remount(
491 struct super_block *sb,
492 int *flags,
493 char *options)
495 vfs_t *vfsp = LINVFS_GET_VFS(sb);
496 struct xfs_mount_args *args = args_allocate(sb);
497 int error;
499 VFS_PARSEARGS(vfsp, options, args, 1, error);
500 if (!error)
501 VFS_MNTUPDATE(vfsp, flags, args, error);
502 kmem_free(args, sizeof(*args));
503 return -error;
506 STATIC void
507 linvfs_freeze_fs(
508 struct super_block *sb)
510 vfs_t *vfsp = LINVFS_GET_VFS(sb);
511 vnode_t *vp;
512 int error;
514 if (sb->s_flags & MS_RDONLY)
515 return;
516 VFS_ROOT(vfsp, &vp, error);
517 VOP_IOCTL(vp, LINVFS_GET_IP(vp), NULL, XFS_IOC_FREEZE, 0, error);
518 VN_RELE(vp);
521 STATIC void
522 linvfs_unfreeze_fs(
523 struct super_block *sb)
525 vfs_t *vfsp = LINVFS_GET_VFS(sb);
526 vnode_t *vp;
527 int error;
529 VFS_ROOT(vfsp, &vp, error);
530 VOP_IOCTL(vp, LINVFS_GET_IP(vp), NULL, XFS_IOC_THAW, 0, error);
531 VN_RELE(vp);
534 STATIC struct dentry *
535 linvfs_get_parent(
536 struct dentry *child)
538 int error;
539 vnode_t *vp, *cvp;
540 struct dentry *parent;
541 struct inode *ip = NULL;
542 struct dentry dotdot;
544 dotdot.d_name.name = "..";
545 dotdot.d_name.len = 2;
546 dotdot.d_inode = 0;
548 cvp = NULL;
549 vp = LINVFS_GET_VP(child->d_inode);
550 VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error);
552 if (!error) {
553 ASSERT(cvp);
554 ip = LINVFS_GET_IP(cvp);
555 if (!ip) {
556 VN_RELE(cvp);
557 return ERR_PTR(-EACCES);
560 if (error)
561 return ERR_PTR(-error);
562 parent = d_alloc_anon(ip);
563 if (!parent) {
564 VN_RELE(cvp);
565 parent = ERR_PTR(-ENOMEM);
567 return parent;
570 STATIC struct dentry *
571 linvfs_get_dentry(
572 struct super_block *sb,
573 void *data)
575 vnode_t *vp;
576 struct inode *inode;
577 struct dentry *result;
578 xfs_fid2_t xfid;
579 vfs_t *vfsp = LINVFS_GET_VFS(sb);
580 int error;
582 xfid.fid_len = sizeof(xfs_fid2_t) - sizeof(xfid.fid_len);
583 xfid.fid_pad = 0;
584 xfid.fid_gen = ((__u32 *)data)[1];
585 xfid.fid_ino = ((__u32 *)data)[0];
587 VFS_VGET(vfsp, &vp, (fid_t *)&xfid, error);
588 if (error || vp == NULL)
589 return ERR_PTR(-ESTALE) ;
591 inode = LINVFS_GET_IP(vp);
592 result = d_alloc_anon(inode);
593 if (!result) {
594 iput(inode);
595 return ERR_PTR(-ENOMEM);
597 return result;
600 STATIC int
601 linvfs_show_options(
602 struct seq_file *m,
603 struct vfsmount *mnt)
605 struct vfs *vfsp = LINVFS_GET_VFS(mnt->mnt_sb);
606 int error;
608 VFS_SHOWARGS(vfsp, m, error);
609 return error;
612 STATIC int
613 linvfs_getxstate(
614 struct super_block *sb,
615 struct fs_quota_stat *fqs)
617 struct vfs *vfsp = LINVFS_GET_VFS(sb);
618 int error;
620 VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error);
621 return -error;
624 STATIC int
625 linvfs_setxstate(
626 struct super_block *sb,
627 unsigned int flags,
628 int op)
630 struct vfs *vfsp = LINVFS_GET_VFS(sb);
631 int error;
633 VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error);
634 return -error;
637 STATIC int
638 linvfs_getxquota(
639 struct super_block *sb,
640 int type,
641 qid_t id,
642 struct fs_disk_quota *fdq)
644 struct vfs *vfsp = LINVFS_GET_VFS(sb);
645 int error, getmode;
647 getmode = (type == GRPQUOTA) ? Q_XGETGQUOTA : Q_XGETQUOTA;
648 VFS_QUOTACTL(vfsp, getmode, id, (caddr_t)fdq, error);
649 return -error;
652 STATIC int
653 linvfs_setxquota(
654 struct super_block *sb,
655 int type,
656 qid_t id,
657 struct fs_disk_quota *fdq)
659 struct vfs *vfsp = LINVFS_GET_VFS(sb);
660 int error, setmode;
662 setmode = (type == GRPQUOTA) ? Q_XSETGQLIM : Q_XSETQLIM;
663 VFS_QUOTACTL(vfsp, setmode, id, (caddr_t)fdq, error);
664 return -error;
667 STATIC int
668 linvfs_fill_super(
669 struct super_block *sb,
670 void *data,
671 int silent)
673 vnode_t *rootvp;
674 struct vfs *vfsp = vfs_allocate();
675 struct xfs_mount_args *args = args_allocate(sb);
676 struct kstatfs statvfs;
677 int error;
679 vfsp->vfs_super = sb;
680 LINVFS_SET_VFS(sb, vfsp);
681 if (sb->s_flags & MS_RDONLY)
682 vfsp->vfs_flag |= VFS_RDONLY;
683 bhv_insert_all_vfsops(vfsp);
685 VFS_PARSEARGS(vfsp, (char *)data, args, 0, error);
686 if (error) {
687 bhv_remove_all_vfsops(vfsp, 1);
688 goto fail_vfsop;
691 sb_min_blocksize(sb, BBSIZE);
692 sb->s_maxbytes = XFS_MAX_FILE_OFFSET;
693 sb->s_export_op = &linvfs_export_ops;
694 sb->s_qcop = &linvfs_qops;
695 sb->s_op = &linvfs_sops;
697 VFS_MOUNT(vfsp, args, NULL, error);
698 if (error) {
699 bhv_remove_all_vfsops(vfsp, 1);
700 goto fail_vfsop;
703 VFS_STATVFS(vfsp, &statvfs, NULL, error);
704 if (error)
705 goto fail_unmount;
707 sb->s_dirt = 1;
708 sb->s_magic = XFS_SB_MAGIC;
709 sb->s_blocksize = statvfs.f_bsize;
710 sb->s_blocksize_bits = ffs(statvfs.f_bsize) - 1;
711 set_posix_acl_flag(sb);
713 VFS_ROOT(vfsp, &rootvp, error);
714 if (error)
715 goto fail_unmount;
717 sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp));
718 if (!sb->s_root)
719 goto fail_vnrele;
720 if (is_bad_inode(sb->s_root->d_inode))
721 goto fail_vnrele;
722 if (linvfs_start_syncd(vfsp))
723 goto fail_vnrele;
724 vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
726 kmem_free(args, sizeof(*args));
727 return 0;
729 fail_vnrele:
730 if (sb->s_root) {
731 dput(sb->s_root);
732 sb->s_root = NULL;
733 } else {
734 VN_RELE(rootvp);
737 fail_unmount:
738 VFS_UNMOUNT(vfsp, 0, NULL, error);
740 fail_vfsop:
741 vfs_deallocate(vfsp);
742 kmem_free(args, sizeof(*args));
743 return -error;
746 STATIC struct super_block *
747 linvfs_get_sb(
748 struct file_system_type *fs_type,
749 int flags,
750 const char *dev_name,
751 void *data)
753 return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super);
757 STATIC struct export_operations linvfs_export_ops = {
758 .get_parent = linvfs_get_parent,
759 .get_dentry = linvfs_get_dentry,
762 STATIC struct super_operations linvfs_sops = {
763 .alloc_inode = linvfs_alloc_inode,
764 .destroy_inode = linvfs_destroy_inode,
765 .write_inode = linvfs_write_inode,
766 .clear_inode = linvfs_clear_inode,
767 .put_super = linvfs_put_super,
768 .write_super = linvfs_write_super,
769 .write_super_lockfs = linvfs_freeze_fs,
770 .unlockfs = linvfs_unfreeze_fs,
771 .statfs = linvfs_statfs,
772 .remount_fs = linvfs_remount,
773 .show_options = linvfs_show_options,
776 STATIC struct quotactl_ops linvfs_qops = {
777 .get_xstate = linvfs_getxstate,
778 .set_xstate = linvfs_setxstate,
779 .get_xquota = linvfs_getxquota,
780 .set_xquota = linvfs_setxquota,
783 STATIC struct file_system_type xfs_fs_type = {
784 .owner = THIS_MODULE,
785 .name = "xfs",
786 .get_sb = linvfs_get_sb,
787 .kill_sb = kill_block_super,
788 .fs_flags = FS_REQUIRES_DEV,
792 STATIC int __init
793 init_xfs_fs( void )
795 int error;
796 struct sysinfo si;
797 static char message[] __initdata =
798 KERN_INFO "SGI XFS " XFS_VERSION_STRING " with "
799 XFS_BUILD_OPTIONS " enabled\n";
801 printk(message);
803 si_meminfo(&si);
804 xfs_physmem = si.totalram;
806 error = init_inodecache();
807 if (error < 0)
808 goto undo_inodecache;
810 error = pagebuf_init();
811 if (error < 0)
812 goto undo_pagebuf;
814 vn_init();
815 xfs_init();
816 uuid_init();
817 vfs_initdmapi();
818 vfs_initquota();
820 error = register_filesystem(&xfs_fs_type);
821 if (error)
822 goto undo_register;
823 return 0;
825 undo_register:
826 pagebuf_terminate();
828 undo_pagebuf:
829 destroy_inodecache();
831 undo_inodecache:
832 return error;
835 STATIC void __exit
836 exit_xfs_fs( void )
838 unregister_filesystem(&xfs_fs_type);
839 xfs_cleanup();
840 vfs_exitquota();
841 vfs_exitdmapi();
842 pagebuf_terminate();
843 destroy_inodecache();
846 module_init(init_xfs_fs);
847 module_exit(exit_xfs_fs);
849 MODULE_AUTHOR("Silicon Graphics, Inc.");
850 MODULE_DESCRIPTION(
851 "SGI XFS " XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
852 MODULE_LICENSE("GPL");