^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) International Business Machines Corp., 2000-2004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Module: jfs_mount.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * note: file system in transition to aggregate/fileset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * file system mount is interpreted as the mount of aggregate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * if not already mounted, and mount of the single/only fileset in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * the aggregate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * a file system/aggregate is represented by an internal inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * (aka mount inode) initialized with aggregate superblock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * each vfs represents a fileset, and points to its "fileset inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * allocation map inode" (aka fileset inode):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * (an aggregate itself is structured recursively as a filset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * an internal vfs is constructed and points to its "fileset inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * allocation map inode" (aka aggregate inode) where each inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * represents a fileset inode) so that inode number is mapped to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * on-disk inode in uniform way at both aggregate and fileset level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * each vnode/inode of a fileset is linked to its vfs (to facilitate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * per fileset inode operations, e.g., unmount of a fileset, etc.);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * each inode points to the mount inode (to facilitate access to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * per aggregate information, e.g., block size, etc.) as well as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * its file set inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * aggregate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * ipmnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * mntvfs -> fileset ipimap+ -> aggregate ipbmap -> aggregate ipaimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * fileset vfs -> vp(1) <-> ... <-> vp(n) <->vproot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/log2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include "jfs_incore.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include "jfs_filsys.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include "jfs_superblock.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include "jfs_dmap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include "jfs_imap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include "jfs_metapage.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #include "jfs_debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * forward references
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static int chkSuper(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static int logMOUNT(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * NAME: jfs_mount(sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * FUNCTION: vfs_mount()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * PARAMETER: sb - super block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * RETURN: -EBUSY - device already mounted or open for write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * -EBUSY - cvrdvp already mounted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * -EBUSY - mount table full
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * -ENOTDIR- cvrdvp not directory on a device mount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * -ENXIO - device open failure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) int jfs_mount(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int rc = 0; /* Return code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct jfs_sb_info *sbi = JFS_SBI(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct inode *ipaimap = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct inode *ipaimap2 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct inode *ipimap = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct inode *ipbmap = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * read/validate superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * (initialize mount inode from the superblock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if ((rc = chkSuper(sb))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ipaimap = diReadSpecial(sb, AGGREGATE_I, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (ipaimap == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) jfs_err("jfs_mount: Failed to read AGGREGATE_I");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) rc = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) sbi->ipaimap = ipaimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) jfs_info("jfs_mount: ipaimap:0x%p", ipaimap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * initialize aggregate inode allocation map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if ((rc = diMount(ipaimap))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) jfs_err("jfs_mount: diMount(ipaimap) failed w/rc = %d", rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) goto err_ipaimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * open aggregate block allocation map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) ipbmap = diReadSpecial(sb, BMAP_I, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (ipbmap == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) rc = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) goto err_umount_ipaimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) jfs_info("jfs_mount: ipbmap:0x%p", ipbmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) sbi->ipbmap = ipbmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * initialize aggregate block allocation map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if ((rc = dbMount(ipbmap))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) jfs_err("jfs_mount: dbMount failed w/rc = %d", rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) goto err_ipbmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * open the secondary aggregate inode allocation map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * This is a duplicate of the aggregate inode allocation map.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * hand craft a vfs in the same fashion as we did to read ipaimap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * By adding INOSPEREXT (32) to the inode number, we are telling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * diReadSpecial that we are reading from the secondary aggregate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * inode table. This also creates a unique entry in the inode hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if ((sbi->mntflag & JFS_BAD_SAIT) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) ipaimap2 = diReadSpecial(sb, AGGREGATE_I, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if (!ipaimap2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) jfs_err("jfs_mount: Failed to read AGGREGATE_I");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) rc = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) goto err_umount_ipbmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) sbi->ipaimap2 = ipaimap2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) jfs_info("jfs_mount: ipaimap2:0x%p", ipaimap2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * initialize secondary aggregate inode allocation map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if ((rc = diMount(ipaimap2))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) jfs_err("jfs_mount: diMount(ipaimap2) failed, rc = %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) goto err_ipaimap2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* Secondary aggregate inode table is not valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) sbi->ipaimap2 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * mount (the only/single) fileset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * open fileset inode allocation map (aka fileset inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ipimap = diReadSpecial(sb, FILESYSTEM_I, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (ipimap == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) jfs_err("jfs_mount: Failed to read FILESYSTEM_I");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* open fileset secondary inode allocation map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) rc = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) goto err_umount_ipaimap2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) jfs_info("jfs_mount: ipimap:0x%p", ipimap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* map further access of per fileset inodes by the fileset inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) sbi->ipimap = ipimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /* initialize fileset inode allocation map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if ((rc = diMount(ipimap))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) jfs_err("jfs_mount: diMount failed w/rc = %d", rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) goto err_ipimap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * unwind on error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) err_ipimap:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* close fileset inode allocation map inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) diFreeSpecial(ipimap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) err_umount_ipaimap2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /* close secondary aggregate inode allocation map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (ipaimap2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) diUnmount(ipaimap2, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) err_ipaimap2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) /* close aggregate inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (ipaimap2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) diFreeSpecial(ipaimap2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) err_umount_ipbmap: /* close aggregate block allocation map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) dbUnmount(ipbmap, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) err_ipbmap: /* close aggregate inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) diFreeSpecial(ipbmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) err_umount_ipaimap: /* close aggregate inode allocation map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) diUnmount(ipaimap, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) err_ipaimap: /* close aggregate inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) diFreeSpecial(ipaimap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) jfs_err("Mount JFS Failure: %d", rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * NAME: jfs_mount_rw(sb, remount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * FUNCTION: Completes read-write mount, or remounts read-only volume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * as read-write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) int jfs_mount_rw(struct super_block *sb, int remount)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct jfs_sb_info *sbi = JFS_SBI(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * If we are re-mounting a previously read-only volume, we want to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * re-read the inode and block maps, since fsck.jfs may have updated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (remount) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if (chkSuper(sb) || (sbi->state != FM_CLEAN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) truncate_inode_pages(sbi->ipimap->i_mapping, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) truncate_inode_pages(sbi->ipbmap->i_mapping, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) diUnmount(sbi->ipimap, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if ((rc = diMount(sbi->ipimap))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) jfs_err("jfs_mount_rw: diMount failed!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) dbUnmount(sbi->ipbmap, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if ((rc = dbMount(sbi->ipbmap))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) jfs_err("jfs_mount_rw: dbMount failed!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * open/initialize log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if ((rc = lmLogOpen(sb)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * update file system superblock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if ((rc = updateSuper(sb, FM_MOUNT))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) jfs_err("jfs_mount: updateSuper failed w/rc = %d", rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) lmLogClose(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * write MOUNT log record of the file system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) logMOUNT(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * chkSuper()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * validate the superblock of the file system to be mounted and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * get the file system parameters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * 0 with fragsize set if check successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * error code if not successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) static int chkSuper(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct jfs_sb_info *sbi = JFS_SBI(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct jfs_superblock *j_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) int AIM_bytesize, AIT_bytesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) int expected_AIM_bytesize, expected_AIT_bytesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) s64 AIM_byte_addr, AIT_byte_addr, fsckwsp_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) s64 byte_addr_diff0, byte_addr_diff1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) s32 bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if ((rc = readSuper(sb, &bh)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) j_sb = (struct jfs_superblock *)bh->b_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * validate superblock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /* validate fs signature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (strncmp(j_sb->s_magic, JFS_MAGIC, 4) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) le32_to_cpu(j_sb->s_version) > JFS_VERSION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) bsize = le32_to_cpu(j_sb->s_bsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #ifdef _JFS_4K
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) if (bsize != PSIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) jfs_err("Currently only 4K block size supported!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #endif /* _JFS_4K */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) jfs_info("superblock: flag:0x%08x state:0x%08x size:0x%Lx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) le32_to_cpu(j_sb->s_flag), le32_to_cpu(j_sb->s_state),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) (unsigned long long) le64_to_cpu(j_sb->s_size));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) /* validate the descriptors for Secondary AIM and AIT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) if ((j_sb->s_flag & cpu_to_le32(JFS_BAD_SAIT)) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) cpu_to_le32(JFS_BAD_SAIT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) expected_AIM_bytesize = 2 * PSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) AIM_bytesize = lengthPXD(&(j_sb->s_aim2)) * bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) expected_AIT_bytesize = 4 * PSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) AIT_bytesize = lengthPXD(&(j_sb->s_ait2)) * bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) AIM_byte_addr = addressPXD(&(j_sb->s_aim2)) * bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) AIT_byte_addr = addressPXD(&(j_sb->s_ait2)) * bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) byte_addr_diff0 = AIT_byte_addr - AIM_byte_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) fsckwsp_addr = addressPXD(&(j_sb->s_fsckpxd)) * bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) byte_addr_diff1 = fsckwsp_addr - AIT_byte_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) if ((AIM_bytesize != expected_AIM_bytesize) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) (AIT_bytesize != expected_AIT_bytesize) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) (byte_addr_diff0 != AIM_bytesize) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) (byte_addr_diff1 <= AIT_bytesize))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) j_sb->s_flag |= cpu_to_le32(JFS_BAD_SAIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if ((j_sb->s_flag & cpu_to_le32(JFS_GROUPCOMMIT)) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) cpu_to_le32(JFS_GROUPCOMMIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) j_sb->s_flag |= cpu_to_le32(JFS_GROUPCOMMIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) /* validate fs state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) if (j_sb->s_state != cpu_to_le32(FM_CLEAN) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) !sb_rdonly(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) jfs_err("jfs_mount: Mount Failure: File System Dirty.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) sbi->state = le32_to_cpu(j_sb->s_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) sbi->mntflag = le32_to_cpu(j_sb->s_flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * JFS always does I/O by 4K pages. Don't tell the buffer cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * that we use anything else (leave s_blocksize alone).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) sbi->bsize = bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) sbi->l2bsize = le16_to_cpu(j_sb->s_l2bsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* check some fields for possible corruption */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (sbi->l2bsize != ilog2((u32)bsize) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) j_sb->pad != 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) le32_to_cpu(j_sb->s_state) > FM_STATE_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) jfs_err("jfs_mount: Mount Failure: superblock is corrupt!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * For now, ignore s_pbsize, l2bfactor. All I/O going through buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) sbi->nbperpage = PSIZE >> sbi->l2bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) sbi->l2nbperpage = L2PSIZE - sbi->l2bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) sbi->l2niperblk = sbi->l2bsize - L2DISIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) if (sbi->mntflag & JFS_INLINELOG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) sbi->logpxd = j_sb->s_logpxd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) sbi->logdev = new_decode_dev(le32_to_cpu(j_sb->s_logdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) uuid_copy(&sbi->uuid, &j_sb->s_uuid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) uuid_copy(&sbi->loguuid, &j_sb->s_loguuid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) sbi->fsckpxd = j_sb->s_fsckpxd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) sbi->ait2 = j_sb->s_ait2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * updateSuper()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * update synchronously superblock if it is mounted read-write.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) int updateSuper(struct super_block *sb, uint state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) struct jfs_superblock *j_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) struct jfs_sb_info *sbi = JFS_SBI(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) if (sbi->flag & JFS_NOINTEGRITY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) if (state == FM_DIRTY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) sbi->p_state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) } else if (state == FM_MOUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) sbi->p_state = sbi->state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) state = FM_DIRTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) } else if (state == FM_CLEAN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) state = sbi->p_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) jfs_err("updateSuper: bad state");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) } else if (sbi->state == FM_DIRTY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) if ((rc = readSuper(sb, &bh)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) j_sb = (struct jfs_superblock *)bh->b_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) j_sb->s_state = cpu_to_le32(state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) sbi->state = state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) if (state == FM_MOUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) /* record log's dev_t and mount serial number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) j_sb->s_logdev = cpu_to_le32(new_encode_dev(sbi->log->bdev->bd_dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) j_sb->s_logserial = cpu_to_le32(sbi->log->serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) } else if (state == FM_CLEAN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) * If this volume is shared with OS/2, OS/2 will need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) * recalculate DASD usage, since we don't deal with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) if (j_sb->s_flag & cpu_to_le32(JFS_DASD_ENABLED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) j_sb->s_flag |= cpu_to_le32(JFS_DASD_PRIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) mark_buffer_dirty(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) sync_dirty_buffer(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * readSuper()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * read superblock by raw sector address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) int readSuper(struct super_block *sb, struct buffer_head **bpp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /* read in primary superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) *bpp = sb_bread(sb, SUPER1_OFF >> sb->s_blocksize_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) if (*bpp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /* read in secondary/replicated superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) *bpp = sb_bread(sb, SUPER2_OFF >> sb->s_blocksize_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) if (*bpp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * logMOUNT()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * function: write a MOUNT log record for file system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) * MOUNT record keeps logredo() from processing log records
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * for this file system past this point in log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * it is harmless if mount fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * note: MOUNT record is at aggregate level, not at fileset level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * since log records of previous mounts of a fileset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * (e.g., AFTER record of extent allocation) have to be processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) * to update block allocation map at aggregate level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) static int logMOUNT(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) struct jfs_log *log = JFS_SBI(sb)->log;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) struct lrd lrd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) lrd.logtid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) lrd.backchain = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) lrd.type = cpu_to_le16(LOG_MOUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) lrd.length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) lrd.aggregate = cpu_to_le32(new_encode_dev(sb->s_bdev->bd_dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) lmLog(log, NULL, &lrd, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }