Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d2194f6 authored by Carlos Maiolino's avatar Carlos Maiolino Committed by Ben Myers
Browse files

xfs: reduce code duplication handling inode32/64 options



Add xfs_set_inode32() to be used to enable inode32 allocation mode. this
will reduce the amount of duplicated code needed to mount/remount a
filesystem with inode32 option.  This patch also changes
xfs_set_inode64() to return the maximum AG number that inodes can be
allocated instead of set mp->m_maxagi by itself, so that the behaviour
is the same as xfs_set_inode32().  This simplifies code that calls these
functions and needs to know the maximum AG that inodes can be allocated
in.

Signed-off-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 08bf5404
Loading
Loading
Loading
Loading
+5 −38
Original line number Original line Diff line number Diff line
@@ -440,7 +440,7 @@ xfs_initialize_perag(
	xfs_agnumber_t	agcount,
	xfs_agnumber_t	agcount,
	xfs_agnumber_t	*maxagi)
	xfs_agnumber_t	*maxagi)
{
{
	xfs_agnumber_t	index, max_metadata;
	xfs_agnumber_t	index;
	xfs_agnumber_t	first_initialised = 0;
	xfs_agnumber_t	first_initialised = 0;
	xfs_perag_t	*pag;
	xfs_perag_t	*pag;
	xfs_agino_t	agino;
	xfs_agino_t	agino;
@@ -500,43 +500,10 @@ xfs_initialize_perag(
	else
	else
		mp->m_flags &= ~XFS_MOUNT_32BITINODES;
		mp->m_flags &= ~XFS_MOUNT_32BITINODES;


	if (mp->m_flags & XFS_MOUNT_32BITINODES) {
	if (mp->m_flags & XFS_MOUNT_32BITINODES)
		/*
		index = xfs_set_inode32(mp);
		 * Calculate how much should be reserved for inodes to meet
	else
		 * the max inode percentage.
		index = xfs_set_inode64(mp);
		 */
		if (mp->m_maxicount) {
			__uint64_t	icount;

			icount = sbp->sb_dblocks * sbp->sb_imax_pct;
			do_div(icount, 100);
			icount += sbp->sb_agblocks - 1;
			do_div(icount, sbp->sb_agblocks);
			max_metadata = icount;
		} else {
			max_metadata = agcount;
		}

		for (index = 0; index < agcount; index++) {
			ino = XFS_AGINO_TO_INO(mp, index, agino);
			if (ino > XFS_MAXINUMBER_32) {
				index++;
				break;
			}

			pag = xfs_perag_get(mp, index);
			pag->pagi_inodeok = 1;
			if (index < max_metadata)
				pag->pagf_metadata = 1;
			xfs_perag_put(pag);
		}
	} else {
		for (index = 0; index < agcount; index++) {
			pag = xfs_perag_get(mp, index);
			pag->pagi_inodeok = 1;
			xfs_perag_put(pag);
		}
	}


	if (maxagi)
	if (maxagi)
		*maxagi = index;
		*maxagi = index;
+65 −24
Original line number Original line Diff line number Diff line
@@ -599,6 +599,71 @@ xfs_max_file_offset(
	return (((__uint64_t)pagefactor) << bitshift) - 1;
	return (((__uint64_t)pagefactor) << bitshift) - 1;
}
}


xfs_agnumber_t
xfs_set_inode32(struct xfs_mount *mp)
{
	xfs_agnumber_t	index = 0;
	xfs_sb_t	*sbp = &mp->m_sb;
	xfs_agnumber_t	max_metadata;
	xfs_agino_t	agino =	XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks -1, 0);
	xfs_ino_t	ino = XFS_AGINO_TO_INO(mp, sbp->sb_agcount -1, agino);
	xfs_perag_t	*pag;

	/* Calculate how much should be reserved for inodes to meet
	 * the max inode percentage.
	 */
	if (mp->m_maxicount) {
		__uint64_t	icount;

		icount = sbp->sb_dblocks * sbp->sb_imax_pct;
		do_div(icount, 100);
		icount += sbp->sb_agblocks - 1;
		do_div(icount, sbp->sb_agblocks);
		max_metadata = icount;
	} else {
		max_metadata = sbp->sb_agcount;
	}

	for (index = 0; index < sbp->sb_agcount; index++) {
		ino = XFS_AGINO_TO_INO(mp, index, agino);
		if (ino > XFS_MAXINUMBER_32) {
			index++;
			break;
		}

		pag = xfs_perag_get(mp, index);
		pag->pagi_inodeok = 1;
		if (index < max_metadata)
			pag->pagf_metadata = 1;
		xfs_perag_put(pag);
	}
	return index;
}

xfs_agnumber_t
xfs_set_inode64(struct xfs_mount *mp)
{
	xfs_agnumber_t index = 0;

	for (index = 0; index < mp->m_sb.sb_agcount; index++) {
		struct xfs_perag	*pag;

		pag = xfs_perag_get(mp, index);
		pag->pagi_inodeok = 1;
		pag->pagf_metadata = 0;
		xfs_perag_put(pag);
	}

	/* There is no need for lock protection on m_flags,
	 * the rw_semaphore of the VFS superblock is locked
	 * during mount/umount/remount operations, so this is
	 * enough to avoid concurency on the m_flags field
	 */
	mp->m_flags &= ~(XFS_MOUNT_32BITINODES |
			 XFS_MOUNT_SMALL_INUMS);
	return index;
}

STATIC int
STATIC int
xfs_blkdev_get(
xfs_blkdev_get(
	xfs_mount_t		*mp,
	xfs_mount_t		*mp,
@@ -1039,30 +1104,6 @@ xfs_restore_resvblks(struct xfs_mount *mp)
	xfs_reserve_blocks(mp, &resblks, NULL);
	xfs_reserve_blocks(mp, &resblks, NULL);
}
}


STATIC void
xfs_set_inode64(struct xfs_mount *mp)
{
	int i = 0;

	for (i = 0; i < mp->m_sb.sb_agcount; i++) {
		struct xfs_perag	*pag;

		pag = xfs_perag_get(mp, i);
		pag->pagi_inodeok = 1;
		pag->pagf_metadata = 0;
		xfs_perag_put(pag);
	}

	/* There is no need for lock protection on m_flags,
	 * the rw_semaphore of the VFS superblock is locked
	 * during mount/umount/remount operations, so this is
	 * enough to avoid concurency on the m_flags field
	 */
	mp->m_flags &= ~(XFS_MOUNT_32BITINODES |
			 XFS_MOUNT_SMALL_INUMS);
	mp->m_maxagi = i;
}

STATIC int
STATIC int
xfs_fs_remount(
xfs_fs_remount(
	struct super_block	*sb,
	struct super_block	*sb,
+2 −0
Original line number Original line Diff line number Diff line
@@ -75,6 +75,8 @@ struct block_device;
extern __uint64_t xfs_max_file_offset(unsigned int);
extern __uint64_t xfs_max_file_offset(unsigned int);


extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
extern xfs_agnumber_t xfs_set_inode32(struct xfs_mount *);
extern xfs_agnumber_t xfs_set_inode64(struct xfs_mount *);


extern const struct export_operations xfs_export_operations;
extern const struct export_operations xfs_export_operations;
extern const struct xattr_handler *xfs_xattr_handlers[];
extern const struct xattr_handler *xfs_xattr_handlers[];