Commit 7b6259e7 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner
Browse files

xfs: remove block number from inode lookup code



The block number comes from bulkstat based inode lookups to shortcut
the mapping calculations. We ar enot able to trust anything from
bulkstat, so drop the block number as well so that the correct
lookups and mappings are always done.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 1920779e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -133,7 +133,7 @@ xfs_nfs_get_inode(
	 * send invalid file handles and we have to handle it gracefully..
	 * send invalid file handles and we have to handle it gracefully..
	 */
	 */
	error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
	error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
			 XFS_ILOCK_SHARED, &ip, 0);
			 XFS_ILOCK_SHARED, &ip);
	if (error) {
	if (error) {
		/*
		/*
		 * EINVAL means the inode cluster doesn't exist anymore.
		 * EINVAL means the inode cluster doesn't exist anymore.
+2 −3
Original line number Original line Diff line number Diff line
@@ -237,12 +237,11 @@ xfs_bulkstat_one_compat(
	xfs_ino_t	ino,		/* inode number to get data for */
	xfs_ino_t	ino,		/* inode number to get data for */
	void		__user *buffer,	/* buffer to place output in */
	void		__user *buffer,	/* buffer to place output in */
	int		ubsize,		/* size of buffer */
	int		ubsize,		/* size of buffer */
	xfs_daddr_t	bno,		/* starting bno of inode cluster */
	int		*ubused,	/* bytes used by me */
	int		*ubused,	/* bytes used by me */
	int		*stat)		/* BULKSTAT_RV_... */
	int		*stat)		/* BULKSTAT_RV_... */
{
{
	return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
	return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
				    xfs_bulkstat_one_fmt_compat, bno,
				    xfs_bulkstat_one_fmt_compat,
				    ubused, stat);
				    ubused, stat);
}
}


@@ -296,7 +295,7 @@ xfs_compat_ioc_bulkstat(
		int res;
		int res;


		error = xfs_bulkstat_one_compat(mp, inlast, bulkreq.ubuffer,
		error = xfs_bulkstat_one_compat(mp, inlast, bulkreq.ubuffer,
				sizeof(compat_xfs_bstat_t), 0, NULL, &res);
				sizeof(compat_xfs_bstat_t), 0, &res);
	} else if (cmd == XFS_IOC_FSBULKSTAT_32) {
	} else if (cmd == XFS_IOC_FSBULKSTAT_32) {
		error = xfs_bulkstat(mp, &inlast, &count,
		error = xfs_bulkstat(mp, &inlast, &count,
			xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t),
			xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t),
+3 −4
Original line number Original line Diff line number Diff line
@@ -1632,7 +1632,6 @@ xfs_qm_dqusage_adjust(
	xfs_ino_t	ino,		/* inode number to get data for */
	xfs_ino_t	ino,		/* inode number to get data for */
	void		__user *buffer,	/* not used */
	void		__user *buffer,	/* not used */
	int		ubsize,		/* not used */
	int		ubsize,		/* not used */
	xfs_daddr_t	bno,		/* starting block of inode cluster */
	int		*ubused,	/* not used */
	int		*ubused,	/* not used */
	int		*res)		/* result code value */
	int		*res)		/* result code value */
{
{
@@ -1658,7 +1657,7 @@ xfs_qm_dqusage_adjust(
	 * the case in all other instances. It's OK that we do this because
	 * the case in all other instances. It's OK that we do this because
	 * quotacheck is done only at mount time.
	 * quotacheck is done only at mount time.
	 */
	 */
	if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) {
	if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip))) {
		*res = BULKSTAT_RV_NOTHING;
		*res = BULKSTAT_RV_NOTHING;
		return error;
		return error;
	}
	}
@@ -1888,14 +1887,14 @@ xfs_qm_init_quotainos(
		    mp->m_sb.sb_uquotino != NULLFSINO) {
		    mp->m_sb.sb_uquotino != NULLFSINO) {
			ASSERT(mp->m_sb.sb_uquotino > 0);
			ASSERT(mp->m_sb.sb_uquotino > 0);
			if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
			if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
					     0, 0, &uip, 0)))
					     0, 0, &uip)))
				return XFS_ERROR(error);
				return XFS_ERROR(error);
		}
		}
		if (XFS_IS_OQUOTA_ON(mp) &&
		if (XFS_IS_OQUOTA_ON(mp) &&
		    mp->m_sb.sb_gquotino != NULLFSINO) {
		    mp->m_sb.sb_gquotino != NULLFSINO) {
			ASSERT(mp->m_sb.sb_gquotino > 0);
			ASSERT(mp->m_sb.sb_gquotino > 0);
			if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
			if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
					     0, 0, &gip, 0))) {
					     0, 0, &gip))) {
				if (uip)
				if (uip)
					IRELE(uip);
					IRELE(uip);
				return XFS_ERROR(error);
				return XFS_ERROR(error);
+5 −6
Original line number Original line Diff line number Diff line
@@ -262,7 +262,7 @@ xfs_qm_scall_trunc_qfiles(
	}
	}


	if ((flags & XFS_DQ_USER) && mp->m_sb.sb_uquotino != NULLFSINO) {
	if ((flags & XFS_DQ_USER) && mp->m_sb.sb_uquotino != NULLFSINO) {
		error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip, 0);
		error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip);
		if (!error) {
		if (!error) {
			error = xfs_truncate_file(mp, qip);
			error = xfs_truncate_file(mp, qip);
			IRELE(qip);
			IRELE(qip);
@@ -271,7 +271,7 @@ xfs_qm_scall_trunc_qfiles(


	if ((flags & (XFS_DQ_GROUP|XFS_DQ_PROJ)) &&
	if ((flags & (XFS_DQ_GROUP|XFS_DQ_PROJ)) &&
	    mp->m_sb.sb_gquotino != NULLFSINO) {
	    mp->m_sb.sb_gquotino != NULLFSINO) {
		error2 = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip, 0);
		error2 = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip);
		if (!error2) {
		if (!error2) {
			error2 = xfs_truncate_file(mp, qip);
			error2 = xfs_truncate_file(mp, qip);
			IRELE(qip);
			IRELE(qip);
@@ -417,12 +417,12 @@ xfs_qm_scall_getqstat(
	}
	}
	if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) {
	if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) {
		if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
		if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
					0, 0, &uip, 0) == 0)
					0, 0, &uip) == 0)
			tempuqip = B_TRUE;
			tempuqip = B_TRUE;
	}
	}
	if (!gip && mp->m_sb.sb_gquotino != NULLFSINO) {
	if (!gip && mp->m_sb.sb_gquotino != NULLFSINO) {
		if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
		if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
					0, 0, &gip, 0) == 0)
					0, 0, &gip) == 0)
			tempgqip = B_TRUE;
			tempgqip = B_TRUE;
	}
	}
	if (uip) {
	if (uip) {
@@ -1109,7 +1109,6 @@ xfs_qm_internalqcheck_adjust(
	xfs_ino_t	ino,		/* inode number to get data for */
	xfs_ino_t	ino,		/* inode number to get data for */
	void		__user *buffer,	/* not used */
	void		__user *buffer,	/* not used */
	int		ubsize,		/* not used */
	int		ubsize,		/* not used */
	xfs_daddr_t	bno,		/* starting block of inode cluster */
	int		*ubused,	/* not used */
	int		*ubused,	/* not used */
	int		*res)		/* bulkstat result code */
	int		*res)		/* bulkstat result code */
{
{
@@ -1132,7 +1131,7 @@ xfs_qm_internalqcheck_adjust(
	ipreleased = B_FALSE;
	ipreleased = B_FALSE;
 again:
 again:
	lock_flags = XFS_ILOCK_SHARED;
	lock_flags = XFS_ILOCK_SHARED;
	if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip, bno))) {
	if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip))) {
		*res = BULKSTAT_RV_NOTHING;
		*res = BULKSTAT_RV_NOTHING;
		return (error);
		return (error);
	}
	}
+0 −16
Original line number Original line Diff line number Diff line
@@ -1354,22 +1354,6 @@ xfs_imap(
		return 0;
		return 0;
	}
	}


	/*
	 * If we get a block number passed we can use it to
	 * find the buffer easily.
	 */
	if (imap->im_blkno) {
		offset = XFS_INO_TO_OFFSET(mp, ino);
		ASSERT(offset < mp->m_sb.sb_inopblock);

		cluster_agbno = xfs_daddr_to_agbno(mp, imap->im_blkno);
		offset += (agbno - cluster_agbno) * mp->m_sb.sb_inopblock;

		imap->im_len = XFS_FSB_TO_BB(mp, blks_per_cluster);
		imap->im_boffset = (ushort)(offset << mp->m_sb.sb_inodelog);
		return 0;
	}

	/*
	/*
	 * If the inode chunks are aligned then use simple maths to
	 * If the inode chunks are aligned then use simple maths to
	 * find the location. Otherwise we have to do a btree
	 * find the location. Otherwise we have to do a btree
Loading