[Btrfs-devel] [PATCH 3/4] btrfs: Add workaround for bd_mount_sem

Jeff Mahoney jeffm at suse.com
Wed Feb 6 14:14:47 PST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 Versions prior to 2.6.20 used mutexes for bd_mount_sem.

Signed-off-by: Jeff Mahoney <jeffm at suse.com>

- ---
 compat.h |    8 ++++++++
 super.c  |    5 +++--
 2 files changed, 11 insertions(+), 2 deletions(-)

- --- a/compat.h	2008-02-06 16:42:49.000000000 -0500
+++ b/compat.h	2008-02-06 16:44:42.000000000 -0500
@@ -16,4 +16,12 @@
 # endif
 #endif

+/* Versions earlier than 2.6.20 used mutex */
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,19)
+#define bd_mount_sem_down(bdev)	mutex_lock(&(bdev)->bd_mount_mutex)
+#define bd_mount_sem_up(bdev)	mutex_unlock(&(bdev)->bd_mount_mutex)
+#else
+#define bd_mount_sem_down(bdev)	down(&(bdev)->bd_mount_sem)
+#define bd_mount_sem_up(bdev)	up(&(bdev)->bd_mount_sem)
+#endif
 #endif /* _COMPAT_H_ */
- --- a/super.c	2008-02-06 11:37:39.000000000 -0500
+++ b/super.c	2008-02-06 16:44:42.000000000 -0500
@@ -43,6 +43,7 @@
 #include "ioctl.h"
 #include "print-tree.h"
 #include "xattr.h"
+#include "compat.h"

 #define BTRFS_SUPER_MAGIC 0x9123683E

@@ -345,9 +346,9 @@ int btrfs_get_sb_bdev(struct file_system
 	 * will protect the lockfs code from trying to start a snapshot
 	 * while we are mounting
 	 */
- -	down(&bdev->bd_mount_sem);
+	bd_mount_sem_down(bdev);
 	s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
- -	up(&bdev->bd_mount_sem);
+	bd_mount_sem_up(bdev);
 	if (IS_ERR(s))
 		goto error_s;


- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFHqjFWLPWxlyuTD7IRAk84AKCiaPXAF3pvaCzZGjuv+G3X19B9/QCfZIux
rNBN8Ayo7KTBFWSNSVbClLM=
=jSLB
-----END PGP SIGNATURE-----



More information about the Btrfs-devel mailing list