Skip to contentSkip to conversation

xfs: various small fixes and cleanups

PATCH In review Darrick J. Wong 4 participants 15 messages Jun 18, 2021 – Jun 21, 2021 XFS filesystem

lore
Share & tools
lore
#0 lore raw

v2 cover xfs: various small fixes and cleanups

Hi all,

I found a couple of small things that looked like they needed cleaning while debugging other problems in my development tree.

v2: more cleanups for shutdown messaging

If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=random-fixes-5.14

---
 fs/xfs/xfs_fsops.c  |   16 ++++++++--------
 fs/xfs/xfs_icache.c |    8 ++++----
 fs/xfs/xfs_icache.h |    6 +++---
 fs/xfs/xfs_trace.h  |    4 ++--
 4 files changed, 17 insertions(+), 17 deletions(-)
#1 lore raw

PATCH v2 1/3 xfs: fix type mismatches in the inode reclaim functions

From: Darrick J. Wong <[email protected]>

It's currently unlikely that we will ever end up with more than 4 billion inodes waiting for reclamation, but the fs object code uses long int for object counts and we're certainly capable of generating that many. Instead of truncating the internal counters, widen them and report the object counts correctly.

---
 fs/xfs/xfs_icache.c |    8 ++++----
 fs/xfs/xfs_icache.h |    6 +++---
 fs/xfs/xfs_trace.h  |    4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
fs/xfs/xfs_icache.c +4 -4
index 6b44fc734cb5..6007683482c6 100644
@@ -1084,11 +1084,11 @@ xfs_reclaim_inodes(
 long
 xfs_reclaim_inodes_nr(
 	struct xfs_mount	*mp,
-	int			nr_to_scan)
+	unsigned long		nr_to_scan)
 {
 	struct xfs_icwalk	icw = {
 		.icw_flags	= XFS_ICWALK_FLAG_SCAN_LIMIT,
-		.icw_scan_limit	= nr_to_scan,
+		.icw_scan_limit	= min_t(unsigned long, LONG_MAX, nr_to_scan),
 	};
 
 	if (xfs_want_reclaim_sick(mp))
@@ -1106,13 +1106,13 @@ xfs_reclaim_inodes_nr(
  * Return the number of reclaimable inodes in the filesystem for
  * the shrinker to determine how much to reclaim.
  */
-int
+long
 xfs_reclaim_inodes_count(
 	struct xfs_mount	*mp)
 {
 	struct xfs_perag	*pag;
 	xfs_agnumber_t		ag = 0;
-	int			reclaimable = 0;
+	long			reclaimable = 0;
 
 	while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {
 		ag = pag->pag_agno + 1;
fs/xfs/xfs_icache.h +3 -3
index 00dc98a92835..c751cc32dc46 100644
@@ -15,7 +15,7 @@ struct xfs_icwalk {
 	kgid_t		icw_gid;
 	prid_t		icw_prid;
 	__u64		icw_min_file_size;
-	int		icw_scan_limit;
+	long		icw_scan_limit;
 };
 
 /* Flags that reflect xfs_fs_eofblocks functionality. */
@@ -49,8 +49,8 @@ void xfs_inode_free(struct xfs_inode *ip);
 void xfs_reclaim_worker(struct work_struct *work);
 
 void xfs_reclaim_inodes(struct xfs_mount *mp);
-int xfs_reclaim_inodes_count(struct xfs_mount *mp);
-long xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan);
+long xfs_reclaim_inodes_count(struct xfs_mount *mp);
+long xfs_reclaim_inodes_nr(struct xfs_mount *mp, unsigned long nr_to_scan);
 
 void xfs_inode_mark_reclaimable(struct xfs_inode *ip);
 
fs/xfs/xfs_trace.h +2 -2
index 428dc71f7f8b..85fa864f8e2f 100644
@@ -3894,7 +3894,7 @@ DECLARE_EVENT_CLASS(xfs_icwalk_class,
 		__field(uint32_t, gid)
 		__field(prid_t, prid)
 		__field(__u64, min_file_size)
-		__field(int, scan_limit)
+		__field(long, scan_limit)
 		__field(unsigned long, caller_ip)
 	),
 	TP_fast_assign(
@@ -3909,7 +3909,7 @@ DECLARE_EVENT_CLASS(xfs_icwalk_class,
 		__entry->scan_limit = icw ? icw->icw_scan_limit : 0;
 		__entry->caller_ip = caller_ip;
 	),
-	TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %d caller %pS",
+	TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %ld caller %pS",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
 		  __entry->flags,
 		  __entry->uid,
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH 1/3] xfs: fix type mismatches in the inode reclaim functions

Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

It's currently unlikely that we will ever end up with more than 4 billion inodes waiting for reclamation, but the fs object code uses long int for object counts and we're certainly capable of generating that many. Instead of truncating the internal counters, widen them and report the object counts correctly.

Looks good.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw

PATCH v2 2/3 xfs: print name of function causing fs shutdown instead of hex pointer

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

In xfs_do_force_shutdown, print the symbolic name of the function that called us to shut down the filesystem instead of a raw hex pointer. This makes debugging a lot easier:

XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file
fs/xfs/xfs_log.c. Return address = ffffffffa038bc38

becomes:

XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file

	fs/xfs/xfs_log.c. Return address = xfs_trans_mod_sb+0x25
---
 fs/xfs/xfs_fsops.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_fsops.c +1 -1
index 07c745cd483e..b7f979eca1e2 100644
@@ -543,7 +543,7 @@ xfs_do_force_shutdown(
 	}
 
 	xfs_notice(mp,
-"%s(0x%x) called from line %d of file %s. Return address = "PTR_FMT,
+"%s(0x%x) called from line %d of file %s. Return address = %pS",
 		__func__, flags, lnnum, fname, __return_address);
 
 	if (flags & SHUTDOWN_CORRUPT_INCORE) {
Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH 2/3] xfs: print name of function causing fs shutdown instead of hex pointer

Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

In xfs_do_force_shutdown, print the symbolic name of the function that called us to shut down the filesystem instead of a raw hex pointer. This makes debugging a lot easier:

XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file
fs/xfs/xfs_log.c. Return address = ffffffffa038bc38

Quoted 7 lines

becomes:

XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file

	fs/xfs/xfs_log.c. Return address = xfs_trans_mod_sb+0x25

Makes sense.

Signature · 2 lines
Dave Chinner
[email protected]
Reviewed-by on v2 2/3
#5 lore raw

Re: [PATCH 2/3] xfs: print name of function causing fs shutdown instead of hex pointer

In reply to Darrick J. Wong
Quoted 6 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

In xfs_do_force_shutdown, print the symbolic name of the function that called us to shut down the filesystem instead of a raw hex pointer. This makes debugging a lot easier:

Quoted 8 lines

XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file
fs/xfs/xfs_log.c. Return address = ffffffffa038bc38

becomes:

XFS (sda): xfs_do_force_shutdown(0x2) called from line 2440 of file

	fs/xfs/xfs_log.c. Return address = xfs_trans_mod_sb+0x25

Looks good.

Quoted 20 lines
---
 fs/xfs/xfs_fsops.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_fsops.c +1 -1
index 07c745cd483e..b7f979eca1e2 100644
@@ -543,7 +543,7 @@ xfs_do_force_shutdown(
 	}
 
 	xfs_notice(mp,
-"%s(0x%x) called from line %d of file %s. Return address = "PTR_FMT,
+"%s(0x%x) called from line %d of file %s. Return address = %pS",
 		__func__, flags, lnnum, fname, __return_address);
 
 	if (flags & SHUTDOWN_CORRUPT_INCORE) {
Signature · 1 line
chandan
#7 lore raw

PATCH v2 3/3 xfs: shorten the shutdown messages to a single line

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Consolidate the shutdown messages to a single line containing the reason, the passed-in flags, the source of the shutdown, and the end result. This means we now only have one line to look for when debugging, which is useful when the fs goes down while something else is flooding dmesg.

---
 fs/xfs/xfs_fsops.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
fs/xfs/xfs_fsops.c +8 -8
index b7f979eca1e2..6ed29b158312 100644
@@ -538,25 +538,25 @@ xfs_do_force_shutdown(
 
 	if (flags & SHUTDOWN_FORCE_UMOUNT) {
 		xfs_alert(mp,
-"User initiated shutdown received. Shutting down filesystem");
+"User initiated shutdown (0x%x) received. Shutting down filesystem",
+				flags);
 		return;
 	}
 
-	xfs_notice(mp,
-"%s(0x%x) called from line %d of file %s. Return address = %pS",
-		__func__, flags, lnnum, fname, __return_address);
-
 	if (flags & SHUTDOWN_CORRUPT_INCORE) {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_CORRUPT,
-"Corruption of in-memory data detected.  Shutting down filesystem");
+"Corruption of in-memory data (0x%x) detected at %pS (%s:%d).  Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 		if (XFS_ERRLEVEL_HIGH <= xfs_error_level)
 			xfs_stack_trace();
 	} else if (logerror) {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_LOGERROR,
-			"Log I/O Error Detected. Shutting down filesystem");
+"Log I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 	} else {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_IOERROR,
-			"I/O Error Detected. Shutting down filesystem");
+"I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 	}
 
 	xfs_alert(mp,
Reviewed-by on v2 3/3
#8 lore raw

Re: [PATCH 3/3] xfs: shorten the shutdown messages to a single line

Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Consolidate the shutdown messages to a single line containing the reason, the passed-in flags, the source of the shutdown, and the end result. This means we now only have one line to look for when debugging, which is useful when the fs goes down while something else is flooding dmesg.

Seems reasonable. There's enough commonality for log scrapers to easily be able to grab either old or new messages.

Signature · 2 lines
Dave Chinner
[email protected]
Reviewed-by on v2 3/3
#9 lore raw

Re: [PATCH 3/3] xfs: shorten the shutdown messages to a single line

In reply to Darrick J. Wong
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Consolidate the shutdown messages to a single line containing the reason, the passed-in flags, the source of the shutdown, and the end result. This means we now only have one line to look for when debugging, which is useful when the fs goes down while something else is flooding dmesg.

Looks good.

Quoted 44 lines
---
 fs/xfs/xfs_fsops.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
fs/xfs/xfs_fsops.c +8 -8
index b7f979eca1e2..6ed29b158312 100644
@@ -538,25 +538,25 @@ xfs_do_force_shutdown(
 
 	if (flags & SHUTDOWN_FORCE_UMOUNT) {
 		xfs_alert(mp,
-"User initiated shutdown received. Shutting down filesystem");
+"User initiated shutdown (0x%x) received. Shutting down filesystem",
+				flags);
 		return;
 	}
 
-	xfs_notice(mp,
-"%s(0x%x) called from line %d of file %s. Return address = %pS",
-		__func__, flags, lnnum, fname, __return_address);
-
 	if (flags & SHUTDOWN_CORRUPT_INCORE) {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_CORRUPT,
-"Corruption of in-memory data detected.  Shutting down filesystem");
+"Corruption of in-memory data (0x%x) detected at %pS (%s:%d).  Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 		if (XFS_ERRLEVEL_HIGH <= xfs_error_level)
 			xfs_stack_trace();
 	} else if (logerror) {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_LOGERROR,
-			"Log I/O Error Detected. Shutting down filesystem");
+"Log I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 	} else {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_IOERROR,
-			"I/O Error Detected. Shutting down filesystem");
+"I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 	}
 
 	xfs_alert(mp,
Signature · 1 line
chandan
#10 lore raw

Re: [PATCH 3/3] xfs: shorten the shutdown messages to a single line

In reply to Darrick J. Wong
Quoted 19 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Consolidate the shutdown messages to a single line containing the reason, the passed-in flags, the source of the shutdown, and the end result. This means we now only have one line to look for when debugging, which is useful when the fs goes down while something else is flooding dmesg.

---
 fs/xfs/xfs_fsops.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
fs/xfs/xfs_fsops.c +0 -0
index b7f979eca1e2..6ed29b158312 100644

fs/xfs/xfs_fsops.c xfs_do_force_shutdown( · line 544

Quoted 8 lines
fs/xfs/xfs_fsops.c +2 -1
@@ -538,25 +538,25 @@ xfs_do_force_shutdown(
 
 	if (flags & SHUTDOWN_FORCE_UMOUNT) {
 		xfs_alert(mp,
-"User initiated shutdown received. Shutting down filesystem");
+"User initiated shutdown (0x%x) received. Shutting down filesystem",
+				flags);
 		return;
 	}

So SHUTDOWN_FORCE_UMOUNT can actually be used together with SHUTDOWN_LOG_IO_ERROR so printing something more specific could be useful, although I'd prefer text over the hex flags.

Quoted 8 lines
fs/xfs/xfs_fsops.c +2 -1
 	if (flags & SHUTDOWN_CORRUPT_INCORE) {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_CORRUPT,
-"Corruption of in-memory data detected.  Shutting down filesystem");
+"Corruption of in-memory data (0x%x) detected at %pS (%s:%d).  Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 		if (XFS_ERRLEVEL_HIGH <= xfs_error_level)
 			xfs_stack_trace();
 	} else if (logerror) {

fs/xfs/xfs_fsops.c xfs_do_force_shutdown( · line 560

Quoted 10 lines
fs/xfs/xfs_fsops.c +4 -2
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_LOGERROR,
-			"Log I/O Error Detected. Shutting down filesystem");
+"Log I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 	} else {
 		xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_IOERROR,
-			"I/O Error Detected. Shutting down filesystem");
+"I/O error (0x%x) detected at %pS (%s:%d). Shutting down filesystem",
+				flags, __return_address, fname, lnnum);
 	}

However once we get here, flags can have exactly one specific value, so printing it (especially as unreadable hex value) is completely pointless.

#11 lore raw

Re: [PATCH 3/3] xfs: shorten the shutdown messages to a single line

Quoted 21 lines · Christoph Hellwig
Quoted 20 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Consolidate the shutdown messages to a single line containing the reason, the passed-in flags, the source of the shutdown, and the end result. This means we now only have one line to look for when debugging, which is useful when the fs goes down while something else is flooding dmesg.

---
 fs/xfs/xfs_fsops.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
fs/xfs/xfs_fsops.c +0 -0
index b7f979eca1e2..6ed29b158312 100644
@@ -538,25 +538,25 @@ xfs_do_force_shutdown(
 
Quoted 11 lines

fs/xfs/xfs_fsops.c xfs_do_force_shutdown( · line 544

Quoted 7 lines
fs/xfs/xfs_fsops.c +2 -1
 	if (flags & SHUTDOWN_FORCE_UMOUNT) {
 		xfs_alert(mp,
-"User initiated shutdown received. Shutting down filesystem");
+"User initiated shutdown (0x%x) received. Shutting down filesystem",
+				flags);
 		return;
 	}

So SHUTDOWN_FORCE_UMOUNT can actually be used together with SHUTDOWN_LOG_IO_ERROR so printing something more specific could be useful, although I'd prefer text over the hex flags.

I'm in the process of reworking the shutdown code because shutdown is so, so very broken. Can we just fix the message and stop moving the goal posts on me while I try to fix bugs?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#12 lore raw

Re: [PATCH 3/3] xfs: shorten the shutdown messages to a single line

Quoted 12 lines · Dave Chinner
Quoted 11 lines

fs/xfs/xfs_fsops.c xfs_do_force_shutdown( · line 544

Quoted 7 lines
fs/xfs/xfs_fsops.c +2 -1
 	if (flags & SHUTDOWN_FORCE_UMOUNT) {
 		xfs_alert(mp,
-"User initiated shutdown received. Shutting down filesystem");
+"User initiated shutdown (0x%x) received. Shutting down filesystem",
+				flags);
 		return;
 	}

So SHUTDOWN_FORCE_UMOUNT can actually be used together with SHUTDOWN_LOG_IO_ERROR so printing something more specific could be useful, although I'd prefer text over the hex flags.

Quoted 3 lines

I'm in the process of reworking the shutdown code because shutdown is so, so very broken. Can we just fix the message and stop moving the goal posts on me while I try to fix bugs?

I suggest just not adding these not very useful flags. That is not moving the goal post. And I'm growing really tried of this pointlessly aggressive attitude.

#13 lore raw

Re: [PATCH 3/3] xfs: shorten the shutdown messages to a single line

Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Dave Chinner
Quoted 11 lines

fs/xfs/xfs_fsops.c xfs_do_force_shutdown( · line 544

Quoted 7 lines
fs/xfs/xfs_fsops.c +2 -1
 	if (flags & SHUTDOWN_FORCE_UMOUNT) {
 		xfs_alert(mp,
-"User initiated shutdown received. Shutting down filesystem");
+"User initiated shutdown (0x%x) received. Shutting down filesystem",
+				flags);
 		return;
 	}

So SHUTDOWN_FORCE_UMOUNT can actually be used together with SHUTDOWN_LOG_IO_ERROR so printing something more specific could be useful, although I'd prefer text over the hex flags.

Quoted 7 lines
Quoted 3 lines

I'm in the process of reworking the shutdown code because shutdown is so, so very broken. Can we just fix the message and stop moving the goal posts on me while I try to fix bugs?

I suggest just not adding these not very useful flags. That is not moving the goal post. And I'm growing really tried of this pointlessly aggressive attitude.

Aggressive? Not at all. I'm being realistic.

We've still got bugs in the for-next tree that need to be fixed and this code is part of the problem. It's already -rc7 and we need to focus on understanding the bugs in for-next well enough to either fix them or revert them.

Cosmetic concerns about the code are extremely low priority right now, so can you please just have a little patience here and wait for me to deal with the bugs rather than bikeshedding log messages that might not even exist in a couple of days time?

-Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#14 lore raw

Re: [PATCH 3/3] xfs: shorten the shutdown messages to a single line

Quoted 29 lines · Dave Chinner
Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Dave Chinner
Quoted 11 lines

fs/xfs/xfs_fsops.c xfs_do_force_shutdown( · line 544

Quoted 7 lines
fs/xfs/xfs_fsops.c +2 -1
 	if (flags & SHUTDOWN_FORCE_UMOUNT) {
 		xfs_alert(mp,
-"User initiated shutdown received. Shutting down filesystem");
+"User initiated shutdown (0x%x) received. Shutting down filesystem",
+				flags);
 		return;
 	}

So SHUTDOWN_FORCE_UMOUNT can actually be used together with SHUTDOWN_LOG_IO_ERROR so printing something more specific could be useful, although I'd prefer text over the hex flags.

Quoted 7 lines
Quoted 3 lines

I'm in the process of reworking the shutdown code because shutdown is so, so very broken. Can we just fix the message and stop moving the goal posts on me while I try to fix bugs?

I suggest just not adding these not very useful flags. That is not moving the goal post. And I'm growing really tried of this pointlessly aggressive attitude.

Aggressive? Not at all. I'm being realistic.

We've still got bugs in the for-next tree that need to be fixed and this code is part of the problem. It's already -rc7 and we need to focus on understanding the bugs in for-next well enough to either fix them or revert them.

Quoted 4 lines

Cosmetic concerns about the code are extremely low priority right now, so can you please just have a little patience here and wait for me to deal with the bugs rather than bikeshedding log messages that might not even exist in a couple of days time?

FWIW I /did/ notice that the flags usage could be turned into an enum and intentionally left that cleanup (and the "int logerror" sprinkled everywhere) for 5.15. Maybe Dave will beat me to it, who knows.

--D

Quoted 5 lines

-Dave.

Signature · 2 lines
Dave Chinner
[email protected]