Skip to contentSkip to conversation

Print when ENOSPC due to lack of inodes.

PATCH Superseded [email protected] 2 participants 5 messages Jun 3, 2012 – Jun 5, 2012 XFS filesystem

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Print when ENOSPC due to lack of inodes.

From: Raghavendra D Prabhu <[email protected]>

Currently, when there are no free inodes left / free space to allocate them (usually without inode64), there is no indication anywhere of this case, making it harder to diagnose this case.

Hence, this three-part patch series to print errors to kernel log with reasons, when such a situation arises.

Raghavendra D Prabhu (3):
XFS: Print error when xfs_ialloc_ag_select fails to find continuous
free space.
XFS: Print error when unable to allocate inodes.
XFS: Print error when there are no free AGs.

 fs/xfs/xfs_ialloc.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
Signature · 6 lines
1.7.10.3

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

PATCH 1/3 XFS: Print error when xfs_ialloc_ag_select fails to find continuous free space.

From: Raghavendra D Prabhu <[email protected]>

When xfs_ialloc_ag_select fails to find any AG with continuous free blocks for needed inode allocation, printk error about it once.

---
 fs/xfs/xfs_ialloc.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/xfs_ialloc.c +4 -1
index 177a21a..a02180a 100644
@@ -543,8 +543,11 @@ nextag:
 		if (agno >= agcount)
 			agno = 0;
 		if (agno == pagno) {
-			if (flags == 0)
+			if (flags == 0) {
+				pr_err_once("XFS (%s): Out of continuous free blocks for inode allocation",
+						mp->m_fsname);
 				return NULL;
+			}
 			flags = 0;
 		}
 	}
Signature · 6 lines
1.7.10.3

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

Re: [PATCH 1/3] XFS: Print error when xfs_ialloc_ag_select fails to find continuous free space.

Quoted 15 lines · On Sun, Jun 03, 2012 at 04:42:47PM +0530, [email protected] wrote:

From: Raghavendra D Prabhu <[email protected]>

When xfs_ialloc_ag_select fails to find any AG with continuous free blocks for needed inode allocation, printk error about it once.

---
 fs/xfs/xfs_ialloc.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/xfs_ialloc.c +0 -0
index 177a21a..a02180a 100644

fs/xfs/xfs_ialloc.c nextag: · line 548

Quoted 7 lines
fs/xfs/xfs_ialloc.c +3 -1
@@ -543,8 +543,11 @@ nextag:
 		if (agno >= agcount)
 			agno = 0;
 		if (agno == pagno) {
-			if (flags == 0)
+			if (flags == 0) {
+				pr_err_once("XFS (%s): Out of continuous free blocks for inode allocation",
+						mp->m_fsname);

Couple of things for all 3 patches. Firstly - 80 columns. We tend to keep the pformat string on a single line so it is easy to grep for like so:

				pr_err_once(mp,
		"Insufficient contiguous free space for inode allocation");

Secondly, I'm not sure "print once and once only" is the right behaviour here. This will only warn on one filesystem and only once for the uptime of the system. So if you hit this 5 minutes after boot, then clean up, you'll never get it emitted again even when the condition reappears 6 months later. hence I think this should be a rate-limited print, not a print once.

And finally, you should add a xfs_err_ratelimited wrapper, not not use pr_err_ratelimited() directly and open code the identifier prefixes.

i.e. something like:

#define xfs_printk_ratelimited(func, mp, fmt, ...) \

({								\
	static DEFINE_RATELIMIT_STATE(_rs,			\
				DEFAULT_RATELIMIT_INTERVAL,	\
				DEFAULT_RATELIMIT_BURST);	\
								\
	if (__ratelimit(&_rs))					\
		(func)((mp), fmt, ##__VA_ARGS__);		\
})
#define xfs_err_once(mp, fmt, ...)			\
		xfs_printk_ratelimited(xfs_err, (mp), fmt, ##__VA_ARGS__); 

So we can easily extend it to other logging levels as needed.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

PATCH 2/3 XFS: Print error when unable to allocate inodes.

In reply to [email protected]

From: Raghavendra D Prabhu <[email protected]>

When xfs_ialloc_ag_alloc is unable to allocate required number of inodes, printk error about it once.

---
 fs/xfs/xfs_ialloc.c |    2 ++
 1 file changed, 2 insertions(+)
fs/xfs/xfs_ialloc.c +2 -0
index a02180a..343d7a8 100644
@@ -744,6 +744,8 @@ xfs_dialloc(
 				xfs_trans_brelse(tp, agbp);
 				if (error == ENOSPC) {
 					*inop = NULLFSINO;
+					pr_err_once("XFS (%s): Unable to allocate inodes: Required %d, Current %llu, Maximum %llu",
+							mp->m_fsname, XFS_IALLOC_INODES(mp), mp->m_sb.sb_icount, mp->m_maxicount);
 					return 0;
 				} else
 					return error;
Signature · 6 lines
1.7.10.3

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

PATCH 3/3 XFS: Print error when there are no free AGs.

In reply to [email protected]

From: Raghavendra D Prabhu <[email protected]>

After looping through all the AGs and failing to find any with free inodes, printk once about lack of AGs with free inodes.

---
 fs/xfs/xfs_ialloc.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/xfs/xfs_ialloc.c +5 -1
index 343d7a8..b24ffa3 100644
@@ -776,7 +776,11 @@ nextag:
 			tagno = 0;
 		if (tagno == agno) {
 			*inop = NULLFSINO;
-			return noroom ? ENOSPC : 0;
+			if (noroom) {
+				pr_err_once("XFS (%s): Out of AGs with free inodes: Required %d, Current %llu, Maximum %llu",
+						mp->m_fsname, XFS_IALLOC_INODES(mp), mp->m_sb.sb_icount, mp->m_maxicount);
+				return 0;
+			}
 		}
 		pag = xfs_perag_get(mp, tagno);
 		if (pag->pagi_inodeok == 0) {
Signature · 6 lines
1.7.10.3

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