
From: Alasdair G Kergon <agk@redhat.com>

Improve performance by optionally bypassing some code that uses bdget.

Signed-Off-By: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/md/dm-ioctl.c    |   27 +++++++++++++++------------
 25-akpm/include/linux/dm-ioctl.h |   11 ++++++++---
 2 files changed, 23 insertions(+), 15 deletions(-)

diff -puN drivers/md/dm-ioctl.c~device-mapper-optionally-bypass-a-bdget drivers/md/dm-ioctl.c
--- 25/drivers/md/dm-ioctl.c~device-mapper-optionally-bypass-a-bdget	2005-01-22 23:31:36.425849584 -0800
+++ 25-akpm/drivers/md/dm-ioctl.c	2005-01-22 23:31:36.430848824 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
- * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004 - 2005 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the GPL.
  */
@@ -520,19 +520,22 @@ static int __dev_status(struct mapped_de
 	if (dm_suspended(md))
 		param->flags |= DM_SUSPEND_FLAG;
 
-	bdev = bdget_disk(disk, 0);
-	if (!bdev)
-		return -ENXIO;
-
 	param->dev = huge_encode_dev(MKDEV(disk->major, disk->first_minor));
 
-	/*
-	 * Yes, this will be out of date by the time it gets back
-	 * to userland, but it is still very useful ofr
-	 * debugging.
-	 */
-	param->open_count = bdev->bd_openers;
-	bdput(bdev);
+	if (!(param->flags & DM_SKIP_BDGET_FLAG)) {
+		bdev = bdget_disk(disk, 0);
+		if (!bdev)
+			return -ENXIO;
+
+		/*
+		 * Yes, this will be out of date by the time it gets back
+		 * to userland, but it is still very useful for
+		 * debugging.
+		 */
+		param->open_count = bdev->bd_openers;
+		bdput(bdev);
+	} else
+		param->open_count = -1;
 
 	if (disk->policy)
 		param->flags |= DM_READONLY_FLAG;
diff -puN include/linux/dm-ioctl.h~device-mapper-optionally-bypass-a-bdget include/linux/dm-ioctl.h
--- 25/include/linux/dm-ioctl.h~device-mapper-optionally-bypass-a-bdget	2005-01-22 23:31:36.426849432 -0800
+++ 25-akpm/include/linux/dm-ioctl.h	2005-01-22 23:31:36.431848672 -0800
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
- * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004 - 2005 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the LGPL.
  */
@@ -272,9 +272,9 @@ typedef char ioctl_struct[308];
 #define DM_TARGET_MSG	 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR	4
-#define DM_VERSION_MINOR	3
+#define DM_VERSION_MINOR	4
 #define DM_VERSION_PATCHLEVEL	0
-#define DM_VERSION_EXTRA	"-ioctl (2004-09-30)"
+#define DM_VERSION_EXTRA	"-ioctl (2005-01-12)"
 
 /* Status bits */
 #define DM_READONLY_FLAG	(1 << 0) /* In/Out */
@@ -300,4 +300,9 @@ typedef char ioctl_struct[308];
  */
 #define DM_BUFFER_FULL_FLAG	(1 << 8) /* Out */
 
+/*
+ * Set this to improve performance when you aren't going to use open_count
+ */
+#define DM_SKIP_BDGET_FLAG	(1 << 9) /* In */
+
 #endif				/* _LINUX_DM_IOCTL_H */
_
