Skip to contentSkip to conversation

xfs: Remove redundant return error from xfs_difree()

PATCH In review Jeff Liu 2 participants 3 messages Oct 25, 2012 – Nov 3, 2012 XFS filesystem

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH 1/1 xfs: Remove redundant return error from xfs_difree()

If we can not fetch the related a.g. info when freeing a disk inode, it mostly like a fatal issue was occurred and with ASSERT(0) is fine, however, return XFS_ERROR(EINVAL) does not make sense here.

---
 fs/xfs/xfs_ialloc.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
fs/xfs/xfs_ialloc.c +0 -3
index 445bf1a..b7ea965 100644
@@ -1065,7 +1065,6 @@ xfs_difree(
 		xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).",
 			__func__, agno, mp->m_sb.sb_agcount);
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);
 	}
 	agino = XFS_INO_TO_AGINO(mp, inode);
 	if (inode != XFS_AGINO_TO_INO(mp, agno, agino))  {
@@ -1073,14 +1072,12 @@ xfs_difree(
 			__func__, (unsigned long long)inode,
 			(unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino));
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);
 	}
 	agbno = XFS_AGINO_TO_AGBNO(mp, agino);
 	if (agbno >= mp->m_sb.sb_agblocks)  {
 		xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).",
 			__func__, agbno, mp->m_sb.sb_agblocks);
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);
 	}
 	/*
 	 * Get the allocation group header.
Signature · 6 lines
1.7.4.1

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw

Hey Jeff,

Quoted 27 lines · Jeff Liu

If we can not fetch the related a.g. info when freeing a disk inode, it mostly like a fatal issue was occurred and with ASSERT(0) is fine, however, return XFS_ERROR(EINVAL) does not make sense here.

---
 fs/xfs/xfs_ialloc.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
fs/xfs/xfs_ialloc.c +0 -2
index 445bf1a..b7ea965 100644
@@ -1065,7 +1065,6 @@ xfs_difree(
 		xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).",
 			__func__, agno, mp->m_sb.sb_agcount);
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);
 	}
 	agino = XFS_INO_TO_AGINO(mp, inode);
 	if (inode != XFS_AGINO_TO_INO(mp, agno, agino))  {
@@ -1073,14 +1072,12 @@ xfs_difree(
 			__func__, (unsigned long long)inode,
 			(unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino));
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);

fs/xfs/xfs_ialloc.c xfs_difree( · line 1083

Quoted 10 lines
fs/xfs/xfs_ialloc.c +0 -1
 	}
 	agbno = XFS_AGINO_TO_AGBNO(mp, agino);
 	if (agbno >= mp->m_sb.sb_agblocks)  {
 		xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).",
 			__func__, agbno, mp->m_sb.sb_agblocks);
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);
 	}
 	/*
 	 * Get the allocation group header.

Here the return of EINVAL is serving a useful purpose. The ASSERT is only activated when xfs debug is configured on, so there is a very real chance that you might exercise this code.

My read on this is if you pass bad args to xfs_difree it will return EINVAL. It's just a little defensive coding but it's worth keeping. In this case it will result in forced shutdown of the filesystem, which is much better than the [unspecified] baddness that could happen later in xfs_difree if you have passed in garbage args.

There... I got my FUD in for the day. ;)

Thanks for the patch, but I think we need to pass on this one.

Regards,
Ben

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

author
#2 lore raw

Hi Ben,

Quoted 36 lines · Ben Myers

Hey Jeff,

Quoted 33 lines · Jeff Liu

If we can not fetch the related a.g. info when freeing a disk inode, it mostly like a fatal issue was occurred and with ASSERT(0) is fine, however, return XFS_ERROR(EINVAL) does not make sense here.

---
 fs/xfs/xfs_ialloc.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
fs/xfs/xfs_ialloc.c +0 -2
index 445bf1a..b7ea965 100644
@@ -1065,7 +1065,6 @@ xfs_difree(
 		xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).",
 			__func__, agno, mp->m_sb.sb_agcount);
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);
 	}
 	agino = XFS_INO_TO_AGINO(mp, inode);
 	if (inode != XFS_AGINO_TO_INO(mp, agno, agino))  {
@@ -1073,14 +1072,12 @@ xfs_difree(
 			__func__, (unsigned long long)inode,
 			(unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino));
 		ASSERT(0);
-		return XFS_ERROR(EINVAL);
 	}
 	agbno = XFS_AGINO_TO_AGBNO(mp, agino);
 	if (agbno >= mp->m_sb.sb_agblocks)  {
 		xfs_warn(mp, "%s: agbno >= mp->m_sb.sb_agblocks (%d >= %d).",
 			__func__, agbno, mp->m_sb.sb_agblocks);
 		ASSERT(0);
Quoted 8 lines

fs/xfs/xfs_ialloc.c xfs_difree( · line 1083

Quoted 4 lines
fs/xfs/xfs_ialloc.c +0 -1
-		return XFS_ERROR(EINVAL);
 	}
 	/*
 	 * Get the allocation group header.

Here the return of EINVAL is serving a useful purpose. The ASSERT is only activated when xfs debug is configured on, so there is a very real chance that you might exercise this code.

Ah, I haven't realized that the ASSERT in XFS is configurable..:(

Quoted 6 lines

My read on this is if you pass bad args to xfs_difree it will return EINVAL. It's just a little defensive coding but it's worth keeping. In this case it will result in forced shutdown of the filesystem, which is much better than the [unspecified] baddness that could happen later in xfs_difree if you have passed in garbage args.

Definitely.

Quoted 2 lines

There... I got my FUD in for the day. ;)

Sorry for my false alarm, and thanks your for your teaching!

Regards,
-Jeff

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs