public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [HACK] convert i_alloc_sem for direct_io.c craziness!
@ 2007-09-24 21:14 Steven Rostedt
  2007-09-25 12:42 ` Peter Zijlstra
  2007-10-01 19:52 ` [HACK] convert i_alloc_sem for direct_io.c craziness! Zach Brown
  0 siblings, 2 replies; 8+ messages in thread
From: Steven Rostedt @ 2007-09-24 21:14 UTC (permalink / raw)
  To: LKML; +Cc: linux-rt-users, mingo, Thomas Gleixner


Hopefully I will get some attention from those that are responsible for
fs/direct_io.c

Ingo and Thomas,

This patch converts the i_alloc_sem into a compat_rw_semaphore for the -rt
patch.  Seems that the code in fs/direct_io.c does some nasty logic with
the i_alloc_sem.  For DIO_LOCKING, I'm assuming that the i_alloc_sem is
used as a reference counter for pending requests. When the request is
made, the down_read is performed. When the request is handled by the block
softirq, then that softirq does an up on the request. So the owner is not
the same between down and up. When all requests are handled, the semaphore
counter should be zero. This keeps away any write access while requests
are pending.

Now this may all be well and dandy for vanilla Linux, but it breaks
miserbly when converted to -rt.

1) In RT rw_semaphores must be up'd by the same thread that down's it.

2) We can't do PI on the correct processes.

This patch converts (for now) the i_alloc_sem into a compat_rw_semaphore
to give back the old features to the sem. This fixes deadlocks that we've
been having WRT direct_io.  But unfortunately, it now opens up
unbonded priority inversion with this semaphore.  But really, those that
can be affected by this, shouldn't be doing disk IO anyway.

The real fix would be to get rid of the read semaphore trickery in
direct_io.c.

Signed-off-by: Steve Rostedt <rostedt@goodmis.org>

Index: linux-2.6.23-rc4-rt1/include/linux/fs.h
===================================================================
--- linux-2.6.23-rc4-rt1.orig/include/linux/fs.h	2007-09-24 16:58:59.000000000 -0400
+++ linux-2.6.23-rc4-rt1/include/linux/fs.h	2007-09-24 16:59:11.000000000 -0400
@@ -577,7 +577,7 @@ struct inode {
 	umode_t			i_mode;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	struct mutex		i_mutex;
-	struct rw_semaphore	i_alloc_sem;
+	struct compat_rw_semaphore	i_alloc_sem;
 	const struct inode_operations	*i_op;
 	const struct file_operations	*i_fop;	/* former ->i_op->default_file_ops */
 	struct super_block	*i_sb;

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-10-02 18:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-24 21:14 [HACK] convert i_alloc_sem for direct_io.c craziness! Steven Rostedt
2007-09-25 12:42 ` Peter Zijlstra
2007-09-25 15:29   ` [PATCH RT] Don't let -rt rw_semaphors do _non_owner locks Steven Rostedt
2007-10-01 19:52 ` [HACK] convert i_alloc_sem for direct_io.c craziness! Zach Brown
2007-10-01 20:39   ` Peter Zijlstra
2007-10-02 18:03     ` Zach Brown
2007-10-02 18:12       ` Steven Rostedt
2007-10-02 18:18         ` Zach Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox