Skip to contentSkip to conversation

Annotating xfs_lock_inodes

DISCUSSION Nathan Scott 1 participant 1 message Jul 18, 2006 2 messages not in the archive Locking primitives

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi Ingo,

Quoted 7 lines · Ingo Molnar

...
you can do a subclass++ in the inode locking loop in xfs_lock_inodes(), and pass that subclass index into a new function:

	xfs_ilock_nested(..., subclass)

or something like that.

I have something like that working now, and on to investigating the next issue reported (unrelated to xfs_lock_inodes). I found that I needed to have the rwsem trylock variants available with a subclass argument too though (like the non-trylock variants are currently) in order to get that part of xfs_lock_inodes to play ball.

Could you look over this change for me, and queue it up for lockdep checking in mainline (no rush) if it looks OK?

thanks!

Signature · 1 line
Nathan
include/linux/rwsem.h +7 -3
index 658afb3..d6d7d47 100644
@@ -64,7 +64,9 @@ #ifdef CONFIG_DEBUG_LOCK_ALLOC
  * nested locking:
  */
 extern void down_read_nested(struct rw_semaphore *sem, int subclass);
+extern int down_read_trylock_nested(struct rw_semaphore *sem, int subclass);
 extern void down_write_nested(struct rw_semaphore *sem, int subclass);
+extern int down_write_trylock_nested(struct rw_semaphore *sem, int subclass);
 /*
  * Take/release a lock when not the owner will release it:
  */
@@ -72,9 +74,11 @@ extern void down_read_non_owner(struct r
 extern void up_read_non_owner(struct rw_semaphore *sem);
 #else
 # define down_read_nested(sem, subclass)		down_read(sem)
-# define down_write_nested(sem, subclass)	down_write(sem)
-# define down_read_non_owner(sem)		down_read(sem)
-# define up_read_non_owner(sem)			up_read(sem)
+# define down_read_trylock_nested(sem, subclass)	down_read_trylock(sem)
+# define down_write_nested(sem, subclass)		down_write(sem)
+# define down_write_trylock_nested(sem, subclass)	down_write_trylock(sem)
+# define down_read_non_owner(sem)			down_read(sem)
+# define up_read_non_owner(sem)				up_read(sem)
 #endif
 
 #endif /* __KERNEL__ */
kernel/rwsem.c +22 -0
index 291ded5..4b7eb74 100644
@@ -116,6 +116,17 @@ void down_read_nested(struct rw_semaphor
 
 EXPORT_SYMBOL(down_read_nested);
 
+int down_read_trylock_nested(struct rw_semaphore *sem, int subclass)
+{
+	int ret = __down_read_trylock(sem);
+
+	if (ret == 1)
+		rwsem_acquire_read(&sem->dep_map, subclass, 1, _RET_IP_);
+	return ret;
+}
+
+EXPORT_SYMBOL(down_read_trylock_nested);
+
 void down_read_non_owner(struct rw_semaphore *sem)
 {
 	might_sleep();
@@ -135,6 +146,17 @@ void down_write_nested(struct rw_semapho
 
 EXPORT_SYMBOL(down_write_nested);
 
+int down_write_trylock_nested(struct rw_semaphore *sem, int subclass)
+{
+	int ret = __down_write_trylock(sem);
+
+	if (ret == 1)
+		rwsem_acquire(&sem->dep_map, subclass, 0, _RET_IP_);
+	return ret;
+}
+
+EXPORT_SYMBOL(down_write_trylock_nested);
+
 void up_read_non_owner(struct rw_semaphore *sem)
 {
 	__up_read(sem);