Lines Matching +full:xlen +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) International Business Machines Corp., 2000-2004
22 #define MEGABYTE (1 << L2MEGABYTE)
27 (((b) >> 13) + ((b) >> 23) + ((b) >> 33) + 3 + 1)
34 * |-------------------------------|----------|----------|
44 * 1. set new LogSize as specified or default from new LVSize;
46 * 3. set new FSSize as MIN(FSSize, LVSize-(LogSize+FSCKSize)) where
54 struct inode *ipbmap = sbi->ipbmap; in jfs_extendfs()
56 struct inode *ipimap = sbi->ipimap; in jfs_extendfs()
57 struct jfs_log *log = sbi->log; in jfs_extendfs()
58 struct bmap *bmp = sbi->bmap; in jfs_extendfs()
66 int newNpages = 0, nPages, newPage, xlen, t32; in jfs_extendfs() local
69 struct inode *iplist[1]; in jfs_extendfs()
77 if (sbi->mntflag & JFS_INLINELOG) in jfs_extendfs()
78 oldLVSize = addressPXD(&sbi->logpxd) + lengthPXD(&sbi->logpxd); in jfs_extendfs()
80 oldLVSize = addressPXD(&sbi->fsckpxd) + in jfs_extendfs()
81 lengthPXD(&sbi->fsckpxd); in jfs_extendfs()
93 rc = -EINVAL; in jfs_extendfs()
98 bh = sb_bread(sb, newLVSize - 1); in jfs_extendfs()
101 rc = -EINVAL; in jfs_extendfs()
107 /* Can't extend write-protected drive */ in jfs_extendfs()
110 printk(KERN_WARNING "jfs_extendfs: read-only file system\n"); in jfs_extendfs()
111 rc = -EROFS; in jfs_extendfs()
117 * --------------------- in jfs_extendfs()
125 if ((sbi->mntflag & JFS_INLINELOG)) { in jfs_extendfs()
128 * no size specified: default to 1/256 of aggregate in jfs_extendfs()
132 t32 = (1 << (20 - sbi->l2bsize)) - 1; in jfs_extendfs()
135 min(newLogSize, MEGABYTE32 >> sbi->l2bsize); in jfs_extendfs()
143 newLogSize = (newLogSize * MEGABYTE) >> sbi->l2bsize; in jfs_extendfs()
149 newLogAddress = newLVSize - newLogSize; in jfs_extendfs()
157 * - 1 bit per block in aggregate rounded up to BPERDMAP boundary in jfs_extendfs()
158 * - 1 extra page to handle control page and intermediate level pages in jfs_extendfs()
159 * - 50 extra pages for the chkdsk service log in jfs_extendfs()
161 t64 = ((newLVSize - newLogSize + BPERDMAP - 1) >> L2BPERDMAP) in jfs_extendfs()
163 t32 = DIV_ROUND_UP(t64, BITSPERPAGE) + 1 + 50; in jfs_extendfs()
164 newFSCKSize = t32 << sbi->l2nbperpage; in jfs_extendfs()
165 newFSCKAddress = newLogAddress - newFSCKSize; in jfs_extendfs()
170 newFSSize = newLVSize - newLogSize - newFSCKSize; in jfs_extendfs()
173 if (newFSSize < bmp->db_mapsize) { in jfs_extendfs()
174 rc = -EINVAL; in jfs_extendfs()
183 if ((sbi->mntflag & JFS_INLINELOG) && (newLogAddress > oldLVSize)) { in jfs_extendfs()
186 log_formatted = 1; in jfs_extendfs()
195 * on-disk file system is in consistent state and in jfs_extendfs()
201 sbi->direct_inode->i_size = bdev_nr_bytes(sb->s_bdev); in jfs_extendfs()
203 if (sbi->mntflag & JFS_INLINELOG) { in jfs_extendfs()
210 * mark on-disk super block for fs in transition; in jfs_extendfs()
212 * update on-disk superblock for the new space configuration in jfs_extendfs()
226 j_sb = (struct jfs_superblock *)bh->b_data; in jfs_extendfs()
229 j_sb->s_state |= cpu_to_le32(FM_EXTENDFS); in jfs_extendfs()
230 j_sb->s_xsize = cpu_to_le64(newFSSize); in jfs_extendfs()
231 PXDaddress(&j_sb->s_xfsckpxd, newFSCKAddress); in jfs_extendfs()
232 PXDlength(&j_sb->s_xfsckpxd, newFSCKSize); in jfs_extendfs()
233 PXDaddress(&j_sb->s_xlogpxd, newLogAddress); in jfs_extendfs()
234 PXDlength(&j_sb->s_xlogpxd, newLogSize); in jfs_extendfs()
254 log->base = newLogAddress; in jfs_extendfs()
255 log->size = newLogSize >> (L2LOGPSIZE - sb->s_blocksize_bits); in jfs_extendfs()
262 * --------------------------- in jfs_extendfs()
286 * add 1 extra dmap page for next extendfs() in jfs_extendfs()
288 t64 = (newMapSize - 1) + BPERDMAP; in jfs_extendfs()
289 newNpages = BLKTODMAPN(t64) + 1; in jfs_extendfs()
300 mapSize = bmp->db_mapsize; in jfs_extendfs()
302 XSize = newMapSize - mapSize; /* eXtension Size */ in jfs_extendfs()
303 old_agsize = bmp->db_agsize; /* We need to know if this changes */ in jfs_extendfs()
310 rc = -EIO; in jfs_extendfs()
313 nblocks = min(t64 - mapSize, XSize); in jfs_extendfs()
325 agsizechanged |= (bmp->db_agsize != old_agsize); in jfs_extendfs()
331 /* ipbmap->i_mapsize += nblocks; */ in jfs_extendfs()
332 XSize -= nblocks; in jfs_extendfs()
342 nPages = ipbmap->i_size >> L2PSIZE; in jfs_extendfs()
354 * s.t. logredo() can reconstruct pre-extension state in jfs_extendfs()
366 * cached in meta-data cache, and not written out in jfs_extendfs()
369 rc = filemap_fdatawait(ipbmap->i_mapping); in jfs_extendfs()
373 rc = filemap_write_and_wait(ipbmap->i_mapping); in jfs_extendfs()
380 xoff = newPage << sbi->l2nbperpage; in jfs_extendfs()
381 xlen = (newNpages - nPages) << sbi->l2nbperpage; in jfs_extendfs()
382 xlen = min(xlen, (int) nblocks) & ~(sbi->nbperpage - 1); in jfs_extendfs()
387 if ((rc = xtAppend(tid, ipbmap, 0, xoff, nblocks, &xlen, &xaddr, 0))) { in jfs_extendfs()
392 ipbmap->i_size += xlen << sbi->l2bsize; in jfs_extendfs()
393 inode_add_bytes(ipbmap, xlen << sbi->l2bsize); in jfs_extendfs()
396 rc = txCommit(tid, 1, &iplist[0], COMMIT_FORCE); in jfs_extendfs()
423 * --------------------------- in jfs_extendfs()
443 * -------- in jfs_extendfs()
445 * extension is committed when on-disk super block is in jfs_extendfs()
447 * crash before it to pre-extension state; in jfs_extendfs()
451 /* lmLogSync(log, 1); */ in jfs_extendfs()
456 * logredo() will recover to pre-extendfs state; in jfs_extendfs()
458 * logredo() will recover post-extendfs state; in jfs_extendfs()
467 ipbmap2 = diReadSpecial(sb, BMAP_I, 1); in jfs_extendfs()
472 memcpy(&JFS_IP(ipbmap2)->i_xtroot, &JFS_IP(ipbmap)->i_xtroot, 288); in jfs_extendfs()
473 ipbmap2->i_size = ipbmap->i_size; in jfs_extendfs()
474 ipbmap2->i_blocks = ipbmap->i_blocks; in jfs_extendfs()
476 diWriteSpecial(ipbmap2, 1); in jfs_extendfs()
484 j_sb = (struct jfs_superblock *)bh->b_data; in jfs_extendfs()
487 j_sb->s_state &= cpu_to_le32(~FM_EXTENDFS); in jfs_extendfs()
488 j_sb->s_size = cpu_to_le64(bmp->db_mapsize << in jfs_extendfs()
489 le16_to_cpu(j_sb->s_l2bfactor)); in jfs_extendfs()
490 j_sb->s_agsize = cpu_to_le32(bmp->db_agsize); in jfs_extendfs()
493 if (sbi->mntflag & JFS_INLINELOG) { in jfs_extendfs()
494 PXDaddress(&(j_sb->s_logpxd), newLogAddress); in jfs_extendfs()
495 PXDlength(&(j_sb->s_logpxd), newLogSize); in jfs_extendfs()
499 j_sb->s_logserial = cpu_to_le32(log->serial); in jfs_extendfs()
502 PXDaddress(&(j_sb->s_fsckpxd), newFSCKAddress); in jfs_extendfs()
503 PXDlength(&(j_sb->s_fsckpxd), newFSCKSize); in jfs_extendfs()
504 j_sb->s_fscklog = 1; in jfs_extendfs()
505 /* sb->s_fsckloglen remains the same */ in jfs_extendfs()
508 bh2 = sb_bread(sb, SUPER2_OFF >> sb->s_blocksize_bits); in jfs_extendfs()
510 j_sb2 = (struct jfs_superblock *)bh2->b_data; in jfs_extendfs()