10 #include <linux/sched.h>
11 #include <linux/slab.h>
17 #include <linux/export.h>
49 static void gfs2_tune_init(
struct gfs2_tune *gt)
135 static int gfs2_check_sb(
struct gfs2_sbd *sdp,
int silent)
152 fs_warn(sdp,
"Unknown on-disk format, unable to mount\n");
157 static void end_bio_io_page(
struct bio *bio,
int error)
159 struct page *
page = bio->bi_private;
162 SetPageUptodate(page);
168 static void gfs2_sb_in(
struct gfs2_sbd *sdp,
const void *
buf)
221 ClearPageUptodate(page);
222 ClearPageDirty(page);
227 bio->bi_bdev = sb->
s_bdev;
230 bio->bi_end_io = end_bio_io_page;
231 bio->bi_private =
page;
233 wait_on_page_locked(page);
235 if (!PageUptodate(page)) {
243 return gfs2_check_sb(sdp, silent);
253 static int gfs2_read_sb(
struct gfs2_sbd *sdp,
int silent)
255 u32 hash_blocks, ind_blocks, leaf_blocks;
263 fs_err(sdp,
"can't read superblock\n");
288 for (tmp_blocks = hash_blocks; tmp_blocks > sdp->
sd_diptrs;) {
290 ind_blocks += tmp_blocks;
338 static int init_names(
struct gfs2_sbd *sdp,
int silent)
343 proto = sdp->
sd_args.ar_lockproto;
344 table = sdp->
sd_args.ar_locktable;
348 if (!proto[0] || !table[0]) {
354 proto = sdp->
sd_sb.sb_lockproto;
356 table = sdp->
sd_sb.sb_locktable;
360 table = sdp->
sd_vfs->s_id;
366 while ((table =
strchr(table,
'/')))
385 fs_err(sdp,
"can't acquire mount glock: %d\n", error);
395 fs_err(sdp,
"can't acquire live glock: %d\n", error);
402 fs_err(sdp,
"can't create rename glock: %d\n", error);
409 fs_err(sdp,
"can't create transaction glock: %d\n", error);
436 fs_err(sdp,
"can't read in %s inode: %ld\n", name, PTR_ERR(inode));
437 return PTR_ERR(inode);
441 fs_err(sdp,
"can't alloc %s dentry\n", name);
448 static int init_sb(
struct gfs2_sbd *sdp,
int silent)
458 fs_err(sdp,
"can't acquire superblock glock: %d\n", ret);
462 ret = gfs2_read_sb(sdp, silent);
464 fs_err(sdp,
"can't read superblock: %d\n", ret);
469 if (sdp->
sd_sb.sb_bsize < bdev_logical_block_size(sb->
s_bdev)) {
471 fs_err(sdp,
"FS block size (%u) is too small for device "
473 sdp->
sd_sb.sb_bsize, bdev_logical_block_size(sb->
s_bdev));
478 fs_err(sdp,
"FS block size (%u) is too big for machine "
486 no_addr = sdp->
sd_sb.sb_root_dir.no_addr;
487 ret = gfs2_lookup_root(sb, &sdp->
sd_root_dir, no_addr,
"root");
492 no_addr = sdp->
sd_sb.sb_master_dir.no_addr;
493 ret = gfs2_lookup_root(sb, &sdp->
sd_master_dir, no_addr,
"master");
521 static int map_journal_extents(
struct gfs2_sbd *sdp)
528 struct buffer_head bh;
533 for (lb = 0; lb < i_size_read(jd->
jd_inode) >> sdp->
sd_sb.sb_bsize_shift; lb++) {
536 bh.b_size = 1 << ip->
i_inode.i_blkbits;
541 "%u db=%llu\n", rc, lb, (
unsigned long long)db);
544 if (!prev_db || db != prev_db + 1) {
549 "mapping journal extents.\n");
565 static void gfs2_others_may_mount(
struct gfs2_sbd *sdp)
567 char *
message =
"FIRSTMOUNT=Done";
570 fs_info(sdp,
"first mount done, others may mount\n");
604 name.hash = gfs2_disk_hash(name.name, name.len);
645 static int init_journal(
struct gfs2_sbd *sdp,
int undo)
660 fs_err(sdp,
"can't lookup journal index: %d\n", error);
666 error = gfs2_jindex_hold(sdp, &ji_gh);
668 fs_err(sdp,
"can't read journal index: %d\n", error);
673 if (!gfs2_jindex_size(sdp)) {
674 fs_err(sdp,
"no journals!\n");
678 if (sdp->
sd_args.ar_spectator) {
685 fs_err(sdp,
"can't mount journal #%u\n",
687 fs_err(sdp,
"there are only %u journals (0 - %u)\n",
688 gfs2_jindex_size(sdp),
689 gfs2_jindex_size(sdp) - 1);
699 fs_err(sdp,
"can't acquire journal glock: %d\n", error);
703 ip = GFS2_I(sdp->
sd_jdesc->jd_inode);
708 fs_err(sdp,
"can't acquire journal inode glock: %d\n",
710 goto fail_journal_gh;
715 fs_err(sdp,
"my journal (%u) is bad: %d\n",
724 map_journal_extents(sdp);
734 fs_err(sdp,
"error recovering journal %u: %d\n",
740 gfs2_others_may_mount(sdp);
741 }
else if (!sdp->
sd_args.ar_spectator) {
744 fs_err(sdp,
"error recovering my journal: %d\n", error);
756 if (!sdp->
sd_args.ar_spectator)
759 if (!sdp->
sd_args.ar_spectator)
772 static int init_inodes(
struct gfs2_sbd *sdp,
int undo)
780 error = init_journal(sdp, undo);
788 fs_err(sdp,
"can't read in statfs inode: %d\n", error);
796 fs_err(sdp,
"can't get resource index inode: %d\n", error);
805 fs_err(sdp,
"can't get quota file inode: %d\n", error);
813 &gfs2_quota_imutex_key);
829 init_journal(sdp,
UNDO);
834 static int init_per_node(
struct gfs2_sbd *sdp,
int undo)
851 fs_err(sdp,
"can't find per_node directory: %d\n", error);
859 fs_err(sdp,
"can't find local \"sc\" file: %d\n", error);
867 fs_err(sdp,
"can't find local \"qc\" file: %d\n", error);
878 fs_err(sdp,
"can't lock local \"sc\" file: %d\n", error);
886 fs_err(sdp,
"can't lock local \"qc\" file: %d\n", error);
906 static int init_threads(
struct gfs2_sbd *sdp,
int undo)
917 fs_err(sdp,
"can't start logd thread: %d\n", error);
925 fs_err(sdp,
"can't start quotad thread: %d\n", error);
946 .lm_proto_name =
"lock_nolock",
948 .lm_tokens = &nolock_tokens,
960 static int gfs2_lm_mount(
struct gfs2_sbd *sdp,
int silent)
970 if (!
strcmp(
"lock_nolock", proto)) {
972 sdp->
sd_args.ar_localflocks = 1;
973 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
974 }
else if (!
strcmp(
"lock_dlm", proto)) {
982 fs_info(sdp,
"Trying to join cluster \"%s\", \"%s\"\n", proto, table);
998 if (ret || option < 0)
1009 if (ret || (option != 0 && option != 1))
1010 goto hostdata_error;
1016 fs_info(sdp,
"unknown hostdata (%s)\n", o);
1022 fs_info(sdp,
"Now mounting FS...\n");
1028 fs_info(sdp,
"Joined cluster. Now mounting FS...\n");
1041 static int gfs2_journalid_wait(
void *
word)
1049 static int wait_on_journal(
struct gfs2_sbd *sdp)
1062 char *envp[] = {
ro, spectator,
NULL };
1064 sprintf(spectator,
"SPECTATOR=%d", sdp->
sd_args.ar_spectator ? 1 : 0);
1090 if (sdp->
sd_args.ar_spectator) {
1094 if (sdp->
sd_args.ar_posix_acl)
1096 if (sdp->
sd_args.ar_nobarrier)
1120 if (sdp->
sd_args.ar_statfs_quantum) {
1121 sdp->
sd_tune.gt_statfs_slow = 0;
1124 sdp->
sd_tune.gt_statfs_slow = 1;
1125 sdp->
sd_tune.gt_statfs_quantum = 30;
1128 error = init_names(sdp, silent);
1153 error = gfs2_lm_mount(sdp, silent);
1157 error = init_locking(sdp, &mount_gh,
DO);
1161 error = init_sb(sdp, silent);
1165 error = wait_on_journal(sdp);
1183 if (sdp->
sd_args.ar_spectator)
1190 error = init_inodes(sdp,
DO);
1194 error = init_per_node(sdp,
DO);
1200 fs_err(sdp,
"can't initialize statfs subsystem: %d\n", error);
1204 error = init_threads(sdp,
DO);
1211 fs_err(sdp,
"can't make FS RW: %d\n", error);
1221 init_threads(sdp,
UNDO);
1223 init_per_node(sdp,
UNDO);
1225 init_inodes(sdp,
UNDO);
1235 init_locking(sdp, &mount_gh,
UNDO);
1258 s->
s_bdi = &bdev_get_queue(s->
s_bdev)->backing_dev_info;
1265 return (bdev == s->
s_bdev);
1283 const char *dev_name,
void *
data)
1297 return ERR_CAST(bdev);
1310 s =
sget(fs_type, test_gfs2_super, set_gfs2_super, flags, bdev);
1319 memset(&args, 0,
sizeof(args));
1335 if ((flags ^ s->
s_flags) & MS_RDONLY)
1343 error = fill_super(s, &args, flags &
MS_SILENT ? 1 : 0);
1358 return ERR_PTR(error);
1361 return ERR_PTR(error);
1364 static int set_meta_super(
struct super_block *s,
void *ptr)
1370 int flags,
const char *dev_name,
void *data)
1381 return ERR_PTR(error);
1390 if ((flags ^ s->
s_flags) & MS_RDONLY) {
1392 return ERR_PTR(-
EBUSY);
1421 .mount = gfs2_mount,
1422 .kill_sb = gfs2_kill_sb,
1429 .mount = gfs2_mount_meta,