All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH 10/20] hpfs: replace BKL with a global mutex
Date: Tue, 25 Jan 2011 23:17:24 +0100	[thread overview]
Message-ID: <1295993854-4971-11-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1295993854-4971-1-git-send-email-arnd@arndb.de>

This removes the BKL in hpfs in a rather awful
way, by replacing it with a mutex that basically
serializes the entire file system.

The only reason I hope to get away with this
is because there don't seem to be any real
users left, and the file system is going out
through the staging door anyways.

Since the mutex code is not even tested and
I don't expect anyone to do that, I'm marking
it as broken on SMP and PREEMPT kernels, so
it won't actually get used.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: linux-fsdevel@vger.kernel.org
---
 fs/hpfs/Kconfig   |    2 +-
 fs/hpfs/hpfs_fn.h |   30 ++++++++++++++++++++++++++----
 fs/hpfs/super.c   |    1 +
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/fs/hpfs/Kconfig b/fs/hpfs/Kconfig
index 63b6f56..73476c1 100644
--- a/fs/hpfs/Kconfig
+++ b/fs/hpfs/Kconfig
@@ -1,7 +1,7 @@
 config HPFS_FS
 	tristate "OS/2 HPFS file system support"
 	depends on BLOCK
-	depends on BKL # nontrivial to fix
+	depends on BROKEN || !(SMP || PREEMPT)
 	help
 	  OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS
 	  is the file system used for organizing files on OS/2 hard disk
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 6761cb3..ffdb16e 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -13,7 +13,6 @@
 #include <linux/pagemap.h>
 #include <linux/buffer_head.h>
 #include <linux/slab.h>
-#include <linux/smp_lock.h>
 
 #include "hpfs.h"
 
@@ -90,6 +89,7 @@ struct hpfs_sb_info {
 	unsigned sb_max_fwd_alloc;	/* max forwad allocation */
 	struct mutex hpfs_creation_de;	/* when creating dirents, nobody else
 					   can alloc blocks */
+	struct mutex global_mutex;	/* replaces BKL, serializes everything on SMP */
 	/*unsigned sb_mounting : 1;*/
 	int sb_timeshift;
 };
@@ -345,14 +345,36 @@ static inline time32_t gmt_to_local(struct super_block *s, time_t t)
 }
 
 /*
- * Locking
+ * Locking:
+ *
+ * hpfs_lock() is a leftover from the big kernel lock.
+ * This mutex is used as the outermost lock in hpfs,
+ * all other mutexes (inode->i_mutex, hpfs_inode_info->i_mutex,
+ * hpfs_inode_info->i_parent_mutex, hpfs_creation_de and
+ * lock_super) can get taken while hpfs_lock is held already.
+ *
+ * Code inspection has shown that hpfs_lock never gets taken
+ * recursively, and that it never nests inside one of the
+ * mutexes above, so there should be no deadlocks.
+ *
+ * However, it is frequently held while wait_for_buffer
+ * sleeps, which probably causes a huge slowdown, since
+ * that serializes all operations on a file system.
+ *
+ * Moreover, the locking code is entirely untested, use at
+ * your own risk.
  */
 static inline void hpfs_lock(struct super_block *s)
 {
-	lock_kernel();
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
+#warning HPFS is likely broken on SMP configurations
+	mutex_lock(&hpfs_sb(s)->global_mutex);
+#endif
 }
 
 static inline void hpfs_unlock(struct super_block *s)
 {
-	unlock_kernel();
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
+	mutex_unlock(&hpfs_sb(s)->global_mutex);
+#endif
 }
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 501ea86..694a683 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -491,6 +491,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
 	sbi->sb_cp_table = NULL;
 
 	mutex_init(&sbi->hpfs_creation_de);
+	mutex_init(&sbi->global_mutex);
 
 	uid = current_uid();
 	gid = current_gid();
-- 
1.7.1


  parent reply	other threads:[~2011-01-25 22:19 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25 22:17 [RFC 00/20] Proposal for remaining BKL users Arnd Bergmann
2011-01-25 22:17 ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 01/20] drm/i810: remove the BKL Arnd Bergmann
2011-01-25 22:17 ` [PATCH 02/20] drm: remove i830 driver Arnd Bergmann
2011-01-25 22:17 ` [PATCH 03/20] staging/usbip: convert to kthread Arnd Bergmann
2011-01-28 17:53   ` Max Vozeler
2011-01-28 18:48     ` Arnd Bergmann
2011-03-01 22:15     ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 04/20] staging/cx25721: serialize access to devlist Arnd Bergmann
2011-01-26 16:23   ` Palash Bandyopadhyay
2011-01-31 21:37   ` Greg KH
2011-01-25 22:17 ` [PATCH 05/20] staging/go7007: remove the BKL Arnd Bergmann
2011-01-25 22:17 ` [PATCH 06/20] staging: Remove autofs3 Arnd Bergmann
2011-01-26  7:41   ` H. Peter Anvin
2011-01-25 22:17 ` [PATCH 07/20] staging: remove smbfs Arnd Bergmann
2011-01-25 22:17 ` [PATCH 08/20] adfs: remove the big kernel lock Arnd Bergmann
2011-01-25 22:20   ` Russell King
2011-01-25 22:17 ` [PATCH 09/20] hpfs: rename big kernel lock to hpfs_lock Arnd Bergmann
2011-01-25 22:17 ` Arnd Bergmann [this message]
2011-01-26  0:15   ` [PATCH 10/20] hpfs: replace BKL with a global mutex Andi Kleen
2011-01-26  0:19   ` Andi Kleen
2011-01-26 12:48     ` [PATCH v2] hpfs: remove the BKL Arnd Bergmann
2011-01-26 12:50     ` [PATCH 10/20] hpfs: replace BKL with a global mutex Arnd Bergmann
2011-01-26 16:52       ` Andi Kleen
2011-01-27  5:01         ` Nick Piggin
2011-01-27 10:57           ` Miklos Szeredi
2011-01-25 22:17 ` [PATCH 11/20] hpfs: move to drivers/staging Arnd Bergmann
2011-02-07 16:17   ` Mikulas Patocka
2011-02-07 19:31     ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 12/20] x25: remove the BKL Arnd Bergmann
2011-01-27 10:07   ` Andrew Hendry
2011-01-27 12:17     ` Arnd Bergmann
2011-01-27 12:38       ` [PATCH v2] " Arnd Bergmann
2011-01-27 13:20         ` Eric Dumazet
2011-01-27 13:43           ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 13/20] appletalk: move to staging Arnd Bergmann
2011-01-25 22:17 ` [PATCH 14/20] staging/appletalk: remove the BKL Arnd Bergmann
2011-01-25 22:29   ` David Miller
2011-01-26 12:57     ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 15/20] ufs: " Arnd Bergmann
2011-01-26  2:30   ` Nick Bowler
2011-01-26 12:53     ` Arnd Bergmann
2011-01-27  5:47   ` Nick Piggin
2011-01-27 13:13     ` Arnd Bergmann
2011-01-25 22:17 ` [PATCH 16/20] ipx: " Arnd Bergmann
2011-01-25 22:17 ` [PATCH 17/20] tracing: don't trace " Arnd Bergmann
2011-01-25 22:28   ` Frederic Weisbecker
2011-01-25 22:17 ` [PATCH 18/20] rtmutex-tester: remove BKL tests Arnd Bergmann
2011-01-26 15:00   ` [tip:core/locking] rtmutex-tester: Remove " tip-bot for Arnd Bergmann
2011-02-22 20:57   ` [tip:irq/core] rtmutex: tester: " tip-bot for Arnd Bergmann
2011-01-25 22:17 ` [PATCH 19/20] drivers: remove extraneous includes of smp_lock.h Arnd Bergmann
2011-01-25 22:17 ` [PATCH 20/20] BKL: That's all, folks Arnd Bergmann
2011-01-26  6:19   ` Ingo Molnar
2011-01-26  8:47     ` Alan Cox
2011-01-26 11:01       ` Ingo Molnar
2011-01-26 11:22   ` Thomas Gleixner
2011-01-26  2:22 ` [RFC 00/20] Proposal for remaining BKL users Greg KH
2011-01-26  2:22   ` Greg KH
2011-01-26 11:31   ` Arnd Bergmann
2011-01-26 11:31     ` Arnd Bergmann
2011-01-26 11:58     ` Mauro Carvalho Chehab
2011-01-26 13:45       ` Arnd Bergmann
2011-01-26 13:45         ` Arnd Bergmann
2011-01-26 13:45         ` Arnd Bergmann
2011-01-26 16:24         ` Palash Bandyopadhyay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1295993854-4971-11-git-send-email-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.