2 * Copyright (C) International Business Machines Corp., 2000-2004
3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/module.h>
22 #include <linux/parser.h>
23 #include <linux/completion.h>
24 #include <linux/vfs.h>
25 #include <linux/quotaops.h>
26 #include <linux/mount.h>
27 #include <linux/moduleparam.h>
28 #include <linux/kthread.h>
29 #include <linux/posix_acl.h>
30 #include <linux/buffer_head.h>
31 #include <linux/exportfs.h>
32 #include <linux/crc32.h>
33 #include <linux/slab.h>
34 #include <linux/uaccess.h>
35 #include <linux/seq_file.h>
36 #include <linux/blkdev.h>
38 #include "jfs_incore.h"
39 #include "jfs_filsys.h"
40 #include "jfs_inode.h"
41 #include "jfs_metapage.h"
42 #include "jfs_superblock.h"
46 #include "jfs_debug.h"
47 #include "jfs_xattr.h"
48 #include "jfs_dinode.h"
50 MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
51 MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
52 MODULE_LICENSE("GPL");
54 static struct kmem_cache
*jfs_inode_cachep
;
56 static const struct super_operations jfs_super_operations
;
57 static const struct export_operations jfs_export_operations
;
58 static struct file_system_type jfs_fs_type
;
60 #define MAX_COMMIT_THREADS 64
61 static int commit_threads
;
62 module_param(commit_threads
, int, 0);
63 MODULE_PARM_DESC(commit_threads
, "Number of commit threads");
65 static struct task_struct
*jfsCommitThread
[MAX_COMMIT_THREADS
];
66 struct task_struct
*jfsIOthread
;
67 struct task_struct
*jfsSyncThread
;
69 #ifdef CONFIG_JFS_DEBUG
70 int jfsloglevel
= JFS_LOGLEVEL_WARN
;
71 module_param(jfsloglevel
, int, 0644);
72 MODULE_PARM_DESC(jfsloglevel
, "Specify JFS loglevel (0, 1 or 2)");
75 static void jfs_handle_error(struct super_block
*sb
)
77 struct jfs_sb_info
*sbi
= JFS_SBI(sb
);
82 updateSuper(sb
, FM_DIRTY
);
84 if (sbi
->flag
& JFS_ERR_PANIC
)
85 panic("JFS (device %s): panic forced after error\n",
87 else if (sbi
->flag
& JFS_ERR_REMOUNT_RO
) {
88 jfs_err("ERROR: (device %s): remounting filesystem as read-only",
90 sb
->s_flags
|= SB_RDONLY
;
93 /* nothing is done for continue beyond marking the superblock dirty */
96 void jfs_error(struct super_block
*sb
, const char *fmt
, ...)
106 pr_err("ERROR: (device %s): %ps: %pV\n",
107 sb
->s_id
, __builtin_return_address(0), &vaf
);
111 jfs_handle_error(sb
);
114 static struct inode
*jfs_alloc_inode(struct super_block
*sb
)
116 struct jfs_inode_info
*jfs_inode
;
118 jfs_inode
= kmem_cache_alloc(jfs_inode_cachep
, GFP_NOFS
);
122 memset(&jfs_inode
->i_dquot
, 0, sizeof(jfs_inode
->i_dquot
));
124 return &jfs_inode
->vfs_inode
;
127 static void jfs_free_inode(struct inode
*inode
)
129 kmem_cache_free(jfs_inode_cachep
, JFS_IP(inode
));
132 static int jfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
134 struct jfs_sb_info
*sbi
= JFS_SBI(dentry
->d_sb
);
136 struct inomap
*imap
= JFS_IP(sbi
->ipimap
)->i_imap
;
138 jfs_info("In jfs_statfs");
139 buf
->f_type
= JFS_SUPER_MAGIC
;
140 buf
->f_bsize
= sbi
->bsize
;
141 buf
->f_blocks
= sbi
->bmap
->db_mapsize
;
142 buf
->f_bfree
= sbi
->bmap
->db_nfree
;
143 buf
->f_bavail
= sbi
->bmap
->db_nfree
;
145 * If we really return the number of allocated & free inodes, some
146 * applications will fail because they won't see enough free inodes.
147 * We'll try to calculate some guess as to how many inodes we can
150 * buf->f_files = atomic_read(&imap->im_numinos);
151 * buf->f_ffree = atomic_read(&imap->im_numfree);
153 maxinodes
= min((s64
) atomic_read(&imap
->im_numinos
) +
154 ((sbi
->bmap
->db_nfree
>> imap
->im_l2nbperiext
)
155 << L2INOSPEREXT
), (s64
) 0xffffffffLL
);
156 buf
->f_files
= maxinodes
;
157 buf
->f_ffree
= maxinodes
- (atomic_read(&imap
->im_numinos
) -
158 atomic_read(&imap
->im_numfree
));
159 buf
->f_fsid
.val
[0] = crc32_le(0, (char *)&sbi
->uuid
,
160 sizeof(sbi
->uuid
)/2);
161 buf
->f_fsid
.val
[1] = crc32_le(0,
162 (char *)&sbi
->uuid
+ sizeof(sbi
->uuid
)/2,
163 sizeof(sbi
->uuid
)/2);
165 buf
->f_namelen
= JFS_NAME_MAX
;
170 static int jfs_quota_off(struct super_block
*sb
, int type
);
171 static int jfs_quota_on(struct super_block
*sb
, int type
, int format_id
,
172 const struct path
*path
);
174 static void jfs_quota_off_umount(struct super_block
*sb
)
178 for (type
= 0; type
< MAXQUOTAS
; type
++)
179 jfs_quota_off(sb
, type
);
182 static const struct quotactl_ops jfs_quotactl_ops
= {
183 .quota_on
= jfs_quota_on
,
184 .quota_off
= jfs_quota_off
,
185 .quota_sync
= dquot_quota_sync
,
186 .get_state
= dquot_get_state
,
187 .set_info
= dquot_set_dqinfo
,
188 .get_dqblk
= dquot_get_dqblk
,
189 .set_dqblk
= dquot_set_dqblk
,
190 .get_nextdqblk
= dquot_get_next_dqblk
,
193 static inline void jfs_quota_off_umount(struct super_block
*sb
)
198 static void jfs_put_super(struct super_block
*sb
)
200 struct jfs_sb_info
*sbi
= JFS_SBI(sb
);
203 jfs_info("In jfs_put_super");
205 jfs_quota_off_umount(sb
);
209 jfs_err("jfs_umount failed with return code %d", rc
);
211 unload_nls(sbi
->nls_tab
);
213 truncate_inode_pages(sbi
->direct_inode
->i_mapping
, 0);
214 iput(sbi
->direct_inode
);
220 Opt_integrity
, Opt_nointegrity
, Opt_iocharset
, Opt_resize
,
221 Opt_resize_nosize
, Opt_errors
, Opt_ignore
, Opt_err
, Opt_quota
,
222 Opt_usrquota
, Opt_grpquota
, Opt_uid
, Opt_gid
, Opt_umask
,
223 Opt_discard
, Opt_nodiscard
, Opt_discard_minblk
226 static const match_table_t tokens
= {
227 {Opt_integrity
, "integrity"},
228 {Opt_nointegrity
, "nointegrity"},
229 {Opt_iocharset
, "iocharset=%s"},
230 {Opt_resize
, "resize=%u"},
231 {Opt_resize_nosize
, "resize"},
232 {Opt_errors
, "errors=%s"},
233 {Opt_ignore
, "noquota"},
234 {Opt_quota
, "quota"},
235 {Opt_usrquota
, "usrquota"},
236 {Opt_grpquota
, "grpquota"},
239 {Opt_umask
, "umask=%u"},
240 {Opt_discard
, "discard"},
241 {Opt_nodiscard
, "nodiscard"},
242 {Opt_discard_minblk
, "discard=%u"},
246 static int parse_options(char *options
, struct super_block
*sb
, s64
*newLVSize
,
249 void *nls_map
= (void *)-1; /* -1: no change; NULL: none */
251 struct jfs_sb_info
*sbi
= JFS_SBI(sb
);
258 while ((p
= strsep(&options
, ",")) != NULL
) {
259 substring_t args
[MAX_OPT_ARGS
];
264 token
= match_token(p
, tokens
, args
);
267 *flag
&= ~JFS_NOINTEGRITY
;
269 case Opt_nointegrity
:
270 *flag
|= JFS_NOINTEGRITY
;
273 /* Silently ignore the quota options */
274 /* Don't do anything ;-) */
277 if (nls_map
&& nls_map
!= (void *) -1)
279 if (!strcmp(args
[0].from
, "none"))
282 nls_map
= load_nls(args
[0].from
);
284 pr_err("JFS: charset not found\n");
291 char *resize
= args
[0].from
;
292 int rc
= kstrtoll(resize
, 0, newLVSize
);
298 case Opt_resize_nosize
:
300 *newLVSize
= i_size_read(sb
->s_bdev
->bd_inode
) >>
301 sb
->s_blocksize_bits
;
303 pr_err("JFS: Cannot determine volume size\n");
308 char *errors
= args
[0].from
;
309 if (!errors
|| !*errors
)
311 if (!strcmp(errors
, "continue")) {
312 *flag
&= ~JFS_ERR_REMOUNT_RO
;
313 *flag
&= ~JFS_ERR_PANIC
;
314 *flag
|= JFS_ERR_CONTINUE
;
315 } else if (!strcmp(errors
, "remount-ro")) {
316 *flag
&= ~JFS_ERR_CONTINUE
;
317 *flag
&= ~JFS_ERR_PANIC
;
318 *flag
|= JFS_ERR_REMOUNT_RO
;
319 } else if (!strcmp(errors
, "panic")) {
320 *flag
&= ~JFS_ERR_CONTINUE
;
321 *flag
&= ~JFS_ERR_REMOUNT_RO
;
322 *flag
|= JFS_ERR_PANIC
;
324 pr_err("JFS: %s is an invalid error handler\n",
334 *flag
|= JFS_USRQUOTA
;
337 *flag
|= JFS_GRPQUOTA
;
343 pr_err("JFS: quota operations not supported\n");
348 char *uid
= args
[0].from
;
350 int rc
= kstrtouint(uid
, 0, &val
);
354 sbi
->uid
= make_kuid(current_user_ns(), val
);
355 if (!uid_valid(sbi
->uid
))
362 char *gid
= args
[0].from
;
364 int rc
= kstrtouint(gid
, 0, &val
);
368 sbi
->gid
= make_kgid(current_user_ns(), val
);
369 if (!gid_valid(sbi
->gid
))
376 char *umask
= args
[0].from
;
377 int rc
= kstrtouint(umask
, 8, &sbi
->umask
);
381 if (sbi
->umask
& ~0777) {
382 pr_err("JFS: Invalid value of umask\n");
390 struct request_queue
*q
= bdev_get_queue(sb
->s_bdev
);
391 /* if set to 1, even copying files will cause
393 * -> user has more control over the online trimming
395 sbi
->minblks_trim
= 64;
396 if (blk_queue_discard(q
))
397 *flag
|= JFS_DISCARD
;
399 pr_err("JFS: discard option not supported on device\n");
404 *flag
&= ~JFS_DISCARD
;
407 case Opt_discard_minblk
:
409 struct request_queue
*q
= bdev_get_queue(sb
->s_bdev
);
410 char *minblks_trim
= args
[0].from
;
412 if (blk_queue_discard(q
)) {
413 *flag
|= JFS_DISCARD
;
414 rc
= kstrtouint(minblks_trim
, 0,
419 pr_err("JFS: discard option not supported on device\n");
424 printk("jfs: Unrecognized mount option \"%s\" or missing value\n",
430 if (nls_map
!= (void *) -1) {
431 /* Discard old (if remount) */
432 unload_nls(sbi
->nls_tab
);
433 sbi
->nls_tab
= nls_map
;
438 if (nls_map
&& nls_map
!= (void *) -1)
443 static int jfs_remount(struct super_block
*sb
, int *flags
, char *data
)
447 int flag
= JFS_SBI(sb
)->flag
;
451 if (!parse_options(data
, sb
, &newLVSize
, &flag
))
456 pr_err("JFS: resize requires volume to be mounted read-write\n");
459 rc
= jfs_extendfs(sb
, newLVSize
, 0);
464 if (sb_rdonly(sb
) && !(*flags
& SB_RDONLY
)) {
466 * Invalidate any previously read metadata. fsck may have
467 * changed the on-disk data since we mounted r/o
469 truncate_inode_pages(JFS_SBI(sb
)->direct_inode
->i_mapping
, 0);
471 JFS_SBI(sb
)->flag
= flag
;
472 ret
= jfs_mount_rw(sb
, 1);
474 /* mark the fs r/w for quota activity */
475 sb
->s_flags
&= ~SB_RDONLY
;
477 dquot_resume(sb
, -1);
480 if (!sb_rdonly(sb
) && (*flags
& SB_RDONLY
)) {
481 rc
= dquot_suspend(sb
, -1);
484 rc
= jfs_umount_rw(sb
);
485 JFS_SBI(sb
)->flag
= flag
;
488 if ((JFS_SBI(sb
)->flag
& JFS_NOINTEGRITY
) != (flag
& JFS_NOINTEGRITY
))
489 if (!sb_rdonly(sb
)) {
490 rc
= jfs_umount_rw(sb
);
494 JFS_SBI(sb
)->flag
= flag
;
495 ret
= jfs_mount_rw(sb
, 1);
498 JFS_SBI(sb
)->flag
= flag
;
503 static int jfs_fill_super(struct super_block
*sb
, void *data
, int silent
)
505 struct jfs_sb_info
*sbi
;
509 int flag
, ret
= -EINVAL
;
511 jfs_info("In jfs_read_super: s_flags=0x%lx", sb
->s_flags
);
513 sbi
= kzalloc(sizeof(struct jfs_sb_info
), GFP_KERNEL
);
518 sb
->s_max_links
= JFS_LINK_MAX
;
520 sbi
->uid
= INVALID_UID
;
521 sbi
->gid
= INVALID_GID
;
524 /* initialize the mount flag and determine the default error handler */
525 flag
= JFS_ERR_REMOUNT_RO
;
527 if (!parse_options((char *) data
, sb
, &newLVSize
, &flag
))
531 #ifdef CONFIG_JFS_POSIX_ACL
532 sb
->s_flags
|= SB_POSIXACL
;
536 pr_err("resize option for remount only\n");
541 * Initialize blocksize to 4K.
543 sb_set_blocksize(sb
, PSIZE
);
546 * Set method vectors.
548 sb
->s_op
= &jfs_super_operations
;
549 sb
->s_export_op
= &jfs_export_operations
;
550 sb
->s_xattr
= jfs_xattr_handlers
;
552 sb
->dq_op
= &dquot_operations
;
553 sb
->s_qcop
= &jfs_quotactl_ops
;
554 sb
->s_quota_types
= QTYPE_MASK_USR
| QTYPE_MASK_GRP
;
558 * Initialize direct-mapping inode/address-space
560 inode
= new_inode(sb
);
566 inode
->i_size
= i_size_read(sb
->s_bdev
->bd_inode
);
567 inode
->i_mapping
->a_ops
= &jfs_metapage_aops
;
568 inode_fake_hash(inode
);
569 mapping_set_gfp_mask(inode
->i_mapping
, GFP_NOFS
);
571 sbi
->direct_inode
= inode
;
576 jfs_err("jfs_mount failed w/return code = %d", rc
);
577 goto out_mount_failed
;
582 rc
= jfs_mount_rw(sb
, 0);
585 jfs_err("jfs_mount_rw failed, return code = %d",
592 sb
->s_magic
= JFS_SUPER_MAGIC
;
594 if (sbi
->mntflag
& JFS_OS2
)
595 sb
->s_d_op
= &jfs_ci_dentry_operations
;
597 inode
= jfs_iget(sb
, ROOT_I
);
599 ret
= PTR_ERR(inode
);
602 sb
->s_root
= d_make_root(inode
);
606 /* logical blocks are represented by 40 bits in pxd_t, etc.
607 * and page cache is indexed by long
609 sb
->s_maxbytes
= min(((loff_t
)sb
->s_blocksize
) << 40, MAX_LFS_FILESIZE
);
614 jfs_err("jfs_read_super: get root dentry failed");
619 jfs_err("jfs_umount failed with return code %d", rc
);
621 filemap_write_and_wait(sbi
->direct_inode
->i_mapping
);
622 truncate_inode_pages(sbi
->direct_inode
->i_mapping
, 0);
623 make_bad_inode(sbi
->direct_inode
);
624 iput(sbi
->direct_inode
);
625 sbi
->direct_inode
= NULL
;
627 unload_nls(sbi
->nls_tab
);
633 static int jfs_freeze(struct super_block
*sb
)
635 struct jfs_sb_info
*sbi
= JFS_SBI(sb
);
636 struct jfs_log
*log
= sbi
->log
;
639 if (!sb_rdonly(sb
)) {
641 rc
= lmLogShutdown(log
);
643 jfs_error(sb
, "lmLogShutdown failed\n");
645 /* let operations fail rather than hang */
650 rc
= updateSuper(sb
, FM_CLEAN
);
652 jfs_err("jfs_freeze: updateSuper failed");
654 * Don't fail here. Everything succeeded except
655 * marking the superblock clean, so there's really
656 * no harm in leaving it frozen for now.
663 static int jfs_unfreeze(struct super_block
*sb
)
665 struct jfs_sb_info
*sbi
= JFS_SBI(sb
);
666 struct jfs_log
*log
= sbi
->log
;
669 if (!sb_rdonly(sb
)) {
670 rc
= updateSuper(sb
, FM_MOUNT
);
672 jfs_error(sb
, "updateSuper failed\n");
677 jfs_error(sb
, "lmLogInit failed\n");
684 static struct dentry
*jfs_do_mount(struct file_system_type
*fs_type
,
685 int flags
, const char *dev_name
, void *data
)
687 return mount_bdev(fs_type
, flags
, dev_name
, data
, jfs_fill_super
);
690 static int jfs_sync_fs(struct super_block
*sb
, int wait
)
692 struct jfs_log
*log
= JFS_SBI(sb
)->log
;
694 /* log == NULL indicates read-only mount */
697 * Write quota structures to quota file, sync_blockdev() will
698 * write them to disk later
700 dquot_writeback_dquots(sb
, -1);
701 jfs_flush_journal(log
, wait
);
708 static int jfs_show_options(struct seq_file
*seq
, struct dentry
*root
)
710 struct jfs_sb_info
*sbi
= JFS_SBI(root
->d_sb
);
712 if (uid_valid(sbi
->uid
))
713 seq_printf(seq
, ",uid=%d", from_kuid(&init_user_ns
, sbi
->uid
));
714 if (gid_valid(sbi
->gid
))
715 seq_printf(seq
, ",gid=%d", from_kgid(&init_user_ns
, sbi
->gid
));
716 if (sbi
->umask
!= -1)
717 seq_printf(seq
, ",umask=%03o", sbi
->umask
);
718 if (sbi
->flag
& JFS_NOINTEGRITY
)
719 seq_puts(seq
, ",nointegrity");
720 if (sbi
->flag
& JFS_DISCARD
)
721 seq_printf(seq
, ",discard=%u", sbi
->minblks_trim
);
723 seq_printf(seq
, ",iocharset=%s", sbi
->nls_tab
->charset
);
724 if (sbi
->flag
& JFS_ERR_CONTINUE
)
725 seq_printf(seq
, ",errors=continue");
726 if (sbi
->flag
& JFS_ERR_PANIC
)
727 seq_printf(seq
, ",errors=panic");
730 if (sbi
->flag
& JFS_USRQUOTA
)
731 seq_puts(seq
, ",usrquota");
733 if (sbi
->flag
& JFS_GRPQUOTA
)
734 seq_puts(seq
, ",grpquota");
742 /* Read data from quotafile - avoid pagecache and such because we cannot afford
743 * acquiring the locks... As quota files are never truncated and quota code
744 * itself serializes the operations (and no one else should touch the files)
745 * we don't have to be afraid of races */
746 static ssize_t
jfs_quota_read(struct super_block
*sb
, int type
, char *data
,
747 size_t len
, loff_t off
)
749 struct inode
*inode
= sb_dqopt(sb
)->files
[type
];
750 sector_t blk
= off
>> sb
->s_blocksize_bits
;
752 int offset
= off
& (sb
->s_blocksize
- 1);
755 struct buffer_head tmp_bh
;
756 struct buffer_head
*bh
;
757 loff_t i_size
= i_size_read(inode
);
761 if (off
+len
> i_size
)
765 tocopy
= sb
->s_blocksize
- offset
< toread
?
766 sb
->s_blocksize
- offset
: toread
;
769 tmp_bh
.b_size
= i_blocksize(inode
);
770 err
= jfs_get_block(inode
, blk
, &tmp_bh
, 0);
773 if (!buffer_mapped(&tmp_bh
)) /* A hole? */
774 memset(data
, 0, tocopy
);
776 bh
= sb_bread(sb
, tmp_bh
.b_blocknr
);
779 memcpy(data
, bh
->b_data
+offset
, tocopy
);
790 /* Write to quotafile */
791 static ssize_t
jfs_quota_write(struct super_block
*sb
, int type
,
792 const char *data
, size_t len
, loff_t off
)
794 struct inode
*inode
= sb_dqopt(sb
)->files
[type
];
795 sector_t blk
= off
>> sb
->s_blocksize_bits
;
797 int offset
= off
& (sb
->s_blocksize
- 1);
799 size_t towrite
= len
;
800 struct buffer_head tmp_bh
;
801 struct buffer_head
*bh
;
804 while (towrite
> 0) {
805 tocopy
= sb
->s_blocksize
- offset
< towrite
?
806 sb
->s_blocksize
- offset
: towrite
;
809 tmp_bh
.b_size
= i_blocksize(inode
);
810 err
= jfs_get_block(inode
, blk
, &tmp_bh
, 1);
813 if (offset
|| tocopy
!= sb
->s_blocksize
)
814 bh
= sb_bread(sb
, tmp_bh
.b_blocknr
);
816 bh
= sb_getblk(sb
, tmp_bh
.b_blocknr
);
822 memcpy(bh
->b_data
+offset
, data
, tocopy
);
823 flush_dcache_page(bh
->b_page
);
824 set_buffer_uptodate(bh
);
825 mark_buffer_dirty(bh
);
834 if (len
== towrite
) {
838 if (inode
->i_size
< off
+len
-towrite
)
839 i_size_write(inode
, off
+len
-towrite
);
840 inode
->i_mtime
= inode
->i_ctime
= current_time(inode
);
841 mark_inode_dirty(inode
);
843 return len
- towrite
;
846 static struct dquot
**jfs_get_dquots(struct inode
*inode
)
848 return JFS_IP(inode
)->i_dquot
;
851 static int jfs_quota_on(struct super_block
*sb
, int type
, int format_id
,
852 const struct path
*path
)
857 err
= dquot_quota_on(sb
, type
, format_id
, path
);
861 inode
= d_inode(path
->dentry
);
863 JFS_IP(inode
)->mode2
|= JFS_NOATIME_FL
| JFS_IMMUTABLE_FL
;
864 inode_set_flags(inode
, S_NOATIME
| S_IMMUTABLE
,
865 S_NOATIME
| S_IMMUTABLE
);
867 mark_inode_dirty(inode
);
872 static int jfs_quota_off(struct super_block
*sb
, int type
)
874 struct inode
*inode
= sb_dqopt(sb
)->files
[type
];
877 if (!inode
|| !igrab(inode
))
880 err
= dquot_quota_off(sb
, type
);
885 JFS_IP(inode
)->mode2
&= ~(JFS_NOATIME_FL
| JFS_IMMUTABLE_FL
);
886 inode_set_flags(inode
, 0, S_NOATIME
| S_IMMUTABLE
);
888 mark_inode_dirty(inode
);
893 return dquot_quota_off(sb
, type
);
897 static const struct super_operations jfs_super_operations
= {
898 .alloc_inode
= jfs_alloc_inode
,
899 .free_inode
= jfs_free_inode
,
900 .dirty_inode
= jfs_dirty_inode
,
901 .write_inode
= jfs_write_inode
,
902 .evict_inode
= jfs_evict_inode
,
903 .put_super
= jfs_put_super
,
904 .sync_fs
= jfs_sync_fs
,
905 .freeze_fs
= jfs_freeze
,
906 .unfreeze_fs
= jfs_unfreeze
,
907 .statfs
= jfs_statfs
,
908 .remount_fs
= jfs_remount
,
909 .show_options
= jfs_show_options
,
911 .quota_read
= jfs_quota_read
,
912 .quota_write
= jfs_quota_write
,
913 .get_dquots
= jfs_get_dquots
,
917 static const struct export_operations jfs_export_operations
= {
918 .fh_to_dentry
= jfs_fh_to_dentry
,
919 .fh_to_parent
= jfs_fh_to_parent
,
920 .get_parent
= jfs_get_parent
,
923 static struct file_system_type jfs_fs_type
= {
924 .owner
= THIS_MODULE
,
926 .mount
= jfs_do_mount
,
927 .kill_sb
= kill_block_super
,
928 .fs_flags
= FS_REQUIRES_DEV
,
930 MODULE_ALIAS_FS("jfs");
932 static void init_once(void *foo
)
934 struct jfs_inode_info
*jfs_ip
= (struct jfs_inode_info
*) foo
;
936 memset(jfs_ip
, 0, sizeof(struct jfs_inode_info
));
937 INIT_LIST_HEAD(&jfs_ip
->anon_inode_list
);
938 init_rwsem(&jfs_ip
->rdwrlock
);
939 mutex_init(&jfs_ip
->commit_mutex
);
940 init_rwsem(&jfs_ip
->xattr_sem
);
941 spin_lock_init(&jfs_ip
->ag_lock
);
942 jfs_ip
->active_ag
= -1;
943 inode_init_once(&jfs_ip
->vfs_inode
);
946 static int __init
init_jfs_fs(void)
952 kmem_cache_create_usercopy("jfs_ip", sizeof(struct jfs_inode_info
),
953 0, SLAB_RECLAIM_ACCOUNT
|SLAB_MEM_SPREAD
|SLAB_ACCOUNT
,
954 offsetof(struct jfs_inode_info
, i_inline
), IDATASIZE
,
956 if (jfs_inode_cachep
== NULL
)
960 * Metapage initialization
962 rc
= metapage_init();
964 jfs_err("metapage_init failed w/rc = %d", rc
);
969 * Transaction Manager initialization
973 jfs_err("txInit failed w/rc = %d", rc
);
978 * I/O completion thread (endio)
980 jfsIOthread
= kthread_run(jfsIOWait
, NULL
, "jfsIO");
981 if (IS_ERR(jfsIOthread
)) {
982 rc
= PTR_ERR(jfsIOthread
);
983 jfs_err("init_jfs_fs: fork failed w/rc = %d", rc
);
987 if (commit_threads
< 1)
988 commit_threads
= num_online_cpus();
989 if (commit_threads
> MAX_COMMIT_THREADS
)
990 commit_threads
= MAX_COMMIT_THREADS
;
992 for (i
= 0; i
< commit_threads
; i
++) {
993 jfsCommitThread
[i
] = kthread_run(jfs_lazycommit
, NULL
,
995 if (IS_ERR(jfsCommitThread
[i
])) {
996 rc
= PTR_ERR(jfsCommitThread
[i
]);
997 jfs_err("init_jfs_fs: fork failed w/rc = %d", rc
);
999 goto kill_committask
;
1003 jfsSyncThread
= kthread_run(jfs_sync
, NULL
, "jfsSync");
1004 if (IS_ERR(jfsSyncThread
)) {
1005 rc
= PTR_ERR(jfsSyncThread
);
1006 jfs_err("init_jfs_fs: fork failed w/rc = %d", rc
);
1007 goto kill_committask
;
1014 rc
= register_filesystem(&jfs_fs_type
);
1021 kthread_stop(jfsSyncThread
);
1023 for (i
= 0; i
< commit_threads
; i
++)
1024 kthread_stop(jfsCommitThread
[i
]);
1025 kthread_stop(jfsIOthread
);
1031 kmem_cache_destroy(jfs_inode_cachep
);
1035 static void __exit
exit_jfs_fs(void)
1039 jfs_info("exit_jfs_fs called");
1044 kthread_stop(jfsIOthread
);
1045 for (i
= 0; i
< commit_threads
; i
++)
1046 kthread_stop(jfsCommitThread
[i
]);
1047 kthread_stop(jfsSyncThread
);
1051 unregister_filesystem(&jfs_fs_type
);
1054 * Make sure all delayed rcu free inodes are flushed before we
1058 kmem_cache_destroy(jfs_inode_cachep
);
1061 module_init(init_jfs_fs
)
1062 module_exit(exit_jfs_fs
)