Skip to contentSkip to conversation

xfs: inode lockdep annotations broke non-lockdep build

PATCH In review Dave Chinner 3 participants 5 messages Aug 19, 2015 – Aug 21, 2015 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: inode lockdep annotations broke non-lockdep build

From: Dave Chinner <[email protected]>

Fix CONFIG_LOCKDEP=n build, because asserts I put in to ensure we aren't overrunning lockdep subclasses in commit 0952c81 ("xfs:
clean up inode lockdep annotations") use a define that doesn't exist when CONFIG_LOCKDEP=n

Only check the subclass limits when lockdep is actually enabled.

---
 fs/xfs/xfs_inode.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode.c +14 -2
index dd584da..30555f8 100644
@@ -362,6 +362,17 @@ int xfs_lots_retries;
 int xfs_lock_delays;
 #endif
 
+#ifdef CONFIG_LOCKDEP
+static bool
+xfs_lockdep_subclass_ok(
+	int subclass)
+{
+	return subclass < MAX_LOCKDEP_SUBCLASSES;
+}
+#else
+#define xfs_lockdep_subclass_ok(subclass)	(true)
+#endif
+
 /*
  * Bump the subclass so xfs_lock_inodes() acquires each lock with a different
  * value. This can be called for any type of inode lock combination, including
@@ -375,11 +386,12 @@ xfs_lock_inumorder(int lock_mode, int subclass)
 
 	ASSERT(!(lock_mode & (XFS_ILOCK_PARENT | XFS_ILOCK_RTBITMAP |
 			      XFS_ILOCK_RTSUM)));
+	ASSERT(xfs_lockdep_subclass_ok(subclass));
 
 	if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)) {
 		ASSERT(subclass <= XFS_IOLOCK_MAX_SUBCLASS);
-		ASSERT(subclass + XFS_IOLOCK_PARENT_VAL <
-						MAX_LOCKDEP_SUBCLASSES);
+		ASSERT(xfs_lockdep_subclass_ok(subclass +
+						XFS_IOLOCK_PARENT_VAL));
 		class += subclass << XFS_IOLOCK_SHIFT;
 		if (lock_mode & XFS_IOLOCK_PARENT)
 			class += XFS_IOLOCK_PARENT_VAL << XFS_IOLOCK_SHIFT;
Signature · 6 lines
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fix CONFIG_LOCKDEP=n build, because asserts I put in to ensure we aren't overrunning lockdep subclasses in commit 0952c81 ("xfs:
clean up inode lockdep annotations") use a define that doesn't exist when CONFIG_LOCKDEP=n

Only check the subclass limits when lockdep is actually enabled.

Quoted 32 lines
---
 fs/xfs/xfs_inode.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode.c +12 -0
index dd584da..30555f8 100644
@@ -362,6 +362,17 @@ int xfs_lots_retries;
 int xfs_lock_delays;
 #endif
 
+#ifdef CONFIG_LOCKDEP
+static bool
+xfs_lockdep_subclass_ok(
+	int subclass)
+{
+	return subclass < MAX_LOCKDEP_SUBCLASSES;
+}
+#else
+#define xfs_lockdep_subclass_ok(subclass)	(true)
+#endif
+
 /*
  * Bump the subclass so xfs_lock_inodes() acquires each lock with a different
  * value. This can be called for any type of inode lock combination, including
@@ -375,11 +386,12 @@ xfs_lock_inumorder(int lock_mode, int subclass)
 
 	ASSERT(!(lock_mode & (XFS_ILOCK_PARENT | XFS_ILOCK_RTBITMAP |
 			      XFS_ILOCK_RTSUM)));
+	ASSERT(xfs_lockdep_subclass_ok(subclass));

fs/xfs/xfs_inode.c xfs_lock_inumorder(int lock_mode, int subclass) · line 397

Quoted 10 lines
fs/xfs/xfs_inode.c +2 -2
 
 	if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)) {
 		ASSERT(subclass <= XFS_IOLOCK_MAX_SUBCLASS);
-		ASSERT(subclass + XFS_IOLOCK_PARENT_VAL <
-						MAX_LOCKDEP_SUBCLASSES);
+		ASSERT(xfs_lockdep_subclass_ok(subclass +
+						XFS_IOLOCK_PARENT_VAL));
 		class += subclass << XFS_IOLOCK_SHIFT;
 		if (lock_mode & XFS_IOLOCK_PARENT)
 			class += XFS_IOLOCK_PARENT_VAL << XFS_IOLOCK_SHIFT;

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

#2 lore raw
In reply to Dave Chinner
Quoted 23 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fix CONFIG_LOCKDEP=n build, because asserts I put in to ensure we aren't overrunning lockdep subclasses in commit 0952c81 ("xfs:
clean up inode lockdep annotations") use a define that doesn't exist when CONFIG_LOCKDEP=n

Only check the subclass limits when lockdep is actually enabled.

---
 fs/xfs/xfs_inode.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode.c +1 -0
index dd584da..30555f8 100644
@@ -362,6 +362,17 @@ int xfs_lots_retries;
 int xfs_lock_delays;
 #endif
 
+#ifdef CONFIG_LOCKDEP

fs/xfs/xfs_inode.c int xfs_lots_retries; · line 375

Quoted 10 lines
fs/xfs/xfs_inode.c +10 -0
+static bool
+xfs_lockdep_subclass_ok(
+	int subclass)
+{
+	return subclass < MAX_LOCKDEP_SUBCLASSES;
+}
+#else
+#define xfs_lockdep_subclass_ok(subclass)	(true)
+#endif
+

FYI, there's a compile warning with debug and verbose warnings disabled:

...
CC [M] fs/xfs//xfs_super.o
fs/xfs//xfs_inode.c:367:1: warning: ‘xfs_lockdep_subclass_ok’ defined but not used [-Wunused-function]
xfs_lockdep_subclass_ok(
^
...

Perhaps it's best to just use the #define in both cases?

Brian

Quoted 25 lines
fs/xfs/xfs_inode.c +3 -2
 /*
  * Bump the subclass so xfs_lock_inodes() acquires each lock with a different
  * value. This can be called for any type of inode lock combination, including
@@ -375,11 +386,12 @@ xfs_lock_inumorder(int lock_mode, int subclass)
 
 	ASSERT(!(lock_mode & (XFS_ILOCK_PARENT | XFS_ILOCK_RTBITMAP |
 			      XFS_ILOCK_RTSUM)));
+	ASSERT(xfs_lockdep_subclass_ok(subclass));
 
 	if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)) {
 		ASSERT(subclass <= XFS_IOLOCK_MAX_SUBCLASS);
-		ASSERT(subclass + XFS_IOLOCK_PARENT_VAL <
-						MAX_LOCKDEP_SUBCLASSES);
+		ASSERT(xfs_lockdep_subclass_ok(subclass +
+						XFS_IOLOCK_PARENT_VAL));
 		class += subclass << XFS_IOLOCK_SHIFT;
 		if (lock_mode & XFS_IOLOCK_PARENT)
 			class += XFS_IOLOCK_PARENT_VAL << XFS_IOLOCK_SHIFT;
Signature · 6 lines
2.5.0

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

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

#3 lore raw
Quoted 37 lines · Brian Foster
Quoted 23 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Fix CONFIG_LOCKDEP=n build, because asserts I put in to ensure we aren't overrunning lockdep subclasses in commit 0952c81 ("xfs:
clean up inode lockdep annotations") use a define that doesn't exist when CONFIG_LOCKDEP=n

Only check the subclass limits when lockdep is actually enabled.

---
 fs/xfs/xfs_inode.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode.c +1 -0
index dd584da..30555f8 100644
@@ -362,6 +362,17 @@ int xfs_lots_retries;
 int xfs_lock_delays;
 #endif
 
+#ifdef CONFIG_LOCKDEP

fs/xfs/xfs_inode.c int xfs_lots_retries; · line 375

Quoted 10 lines
fs/xfs/xfs_inode.c +10 -0
+static bool
+xfs_lockdep_subclass_ok(
+	int subclass)
+{
+	return subclass < MAX_LOCKDEP_SUBCLASSES;
+}
+#else
+#define xfs_lockdep_subclass_ok(subclass)	(true)
+#endif
+

FYI, there's a compile warning with debug and verbose warnings disabled:

Quoted 6 lines

...
CC [M] fs/xfs//xfs_super.o
fs/xfs//xfs_inode.c:367:1: warning: ‘xfs_lockdep_subclass_ok’ defined but not used [-Wunused-function]
xfs_lockdep_subclass_ok(
^
...

Yeah, I know. I've got another patch to fix that. I didn't test all 6 different combinations of the relevant config parameters before pushing the change. (I turned off CONFIG_XFS_DEBUG, but turned on CONFIG_XFS_WARN, so the function was still used).

I haven't pushed it yet, becuse it's just a useless warning rather than a full build breakage and there's been other stuff I've needed to deal with.

(I don't work at all efficiently when I have to context switch all the time. And there's so many things I nee dto pay attention to that I'm context switching every few minutes...)

Quoted 1 line

Perhaps it's best to just use the #define in both cases?

-#ifdef CONFIG_LOCKDEP
+#if (defined(DEBUG) || defined(XFS_WARN)) && CONFIG_LOCKDEP

is how I fixed it.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw
Quoted 4 lines · Dave Chinner
Quoted 3 lines · Brian Foster
Quoted 2 lines · Dave Chinner

From: Dave Chinner <[email protected]>

...

Quoted 8 lines
Quoted 2 lines

Perhaps it's best to just use the #define in both cases?

(quoted diff) +1 -1
-#ifdef CONFIG_LOCKDEP
+#if (defined(DEBUG) || defined(XFS_WARN)) && CONFIG_LOCKDEP

is how I fixed it.

Sounds good to me.

Brian

Quoted 11 lines

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

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