linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/4] bsg: Kconfig updates
@ 2007-06-08 15:12 FUJITA Tomonori
  0 siblings, 0 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2007-06-08 15:12 UTC (permalink / raw)
  To: jens.axboe; +Cc: linux-scsi

- bsg supports sg v4
- bsg depends on SCSI
- it might be better to mark it experimental for a while

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 block/Kconfig |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/block/Kconfig b/block/Kconfig
index 4d1cd1b..22dc027 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -53,9 +53,10 @@ endif
 
 config BLK_DEV_BSG
 	bool "Block layer SG support"
+	depends on SCSI && EXPERIMENTAL
 	default y
 	---help---
-	Saying Y here will enable generic SG (SCSI generic) v3
+	Saying Y here will enable generic SG (SCSI generic) v4
 	support for any block device.
 
 source block/Kconfig.iosched
-- 
1.4.3.2


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

* [PATCH 4/4] bsg: Kconfig updates
@ 2007-07-09 13:02 FUJITA Tomonori
  0 siblings, 0 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2007-07-09 13:02 UTC (permalink / raw)
  To: jens.axboe; +Cc: linux-scsi, tomof

This updates bsg entry in Kconfig:

- bsg supports sg v4
- bsg depends on SCSI
- it might be better to mark it experimental for a while

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 block/Kconfig |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/block/Kconfig b/block/Kconfig
index 4d1cd1b..22dc027 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -53,9 +53,10 @@ endif
 
 config BLK_DEV_BSG
 	bool "Block layer SG support"
+	depends on SCSI && EXPERIMENTAL
 	default y
 	---help---
-	Saying Y here will enable generic SG (SCSI generic) v3
+	Saying Y here will enable generic SG (SCSI generic) v4
 	support for any block device.
 
 source block/Kconfig.iosched
-- 
1.4.4.4


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

* [PATCH 1/4] bsg: fix initialization error handling bugs
@ 2007-07-17 10:08 FUJITA Tomonori
  2007-07-17 10:08 ` [PATCH 2/4] bsg: device hash table cleanup FUJITA Tomonori
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2007-07-17 10:08 UTC (permalink / raw)
  To: jens.axboe; +Cc: linux-scsi, akpm, tomof

This fixes the following bugs and cleans up the initialization code:

- cdev_del is missing.
- unregister_chrdev_region should be used instead of unregister_chrdev.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 block/bsg.c |   38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index cdb00e5..b253784 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -1057,39 +1057,37 @@ static int __init bsg_init(void)
 
 	bsg_class = class_create(THIS_MODULE, "bsg");
 	if (IS_ERR(bsg_class)) {
-		kmem_cache_destroy(bsg_cmd_cachep);
-		return PTR_ERR(bsg_class);
+		ret = PTR_ERR(bsg_class);
+		goto destroy_kmemcache;
 	}
 
 	ret = alloc_chrdev_region(&devid, 0, BSG_MAX_DEVS, "bsg");
-	if (ret) {
-		kmem_cache_destroy(bsg_cmd_cachep);
-		class_destroy(bsg_class);
-		return ret;
-	}
+	if (ret)
+		goto destroy_bsg_class;
 
 	bsg_major = MAJOR(devid);
 
 	cdev_init(&bsg_cdev, &bsg_fops);
 	ret = cdev_add(&bsg_cdev, MKDEV(bsg_major, 0), BSG_MAX_DEVS);
-	if (ret) {
-		kmem_cache_destroy(bsg_cmd_cachep);
-		class_destroy(bsg_class);
-		unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS);
-		return ret;
-	}
+	if (ret)
+		goto unregister_chrdev;
 
 	ret = scsi_register_interface(&bsg_intf);
-	if (ret) {
-		printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret);
-		kmem_cache_destroy(bsg_cmd_cachep);
-		class_destroy(bsg_class);
-		unregister_chrdev(bsg_major, "bsg");
-		return ret;
-	}
+	if (ret)
+		goto remove_cdev;
 
 	printk(KERN_INFO "%s loaded (major %d)\n", bsg_version, bsg_major);
 	return 0;
+remove_cdev:
+	printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret);
+	cdev_del(&bsg_cdev);
+unregister_chrdev:
+	unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS);
+destroy_bsg_class:
+	class_destroy(bsg_class);
+destroy_kmemcache:
+	kmem_cache_destroy(bsg_cmd_cachep);
+	return ret;
 }
 
 MODULE_AUTHOR("Jens Axboe");
-- 
1.4.3.2


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

* [PATCH 2/4] bsg: device hash table cleanup
  2007-07-17 10:08 [PATCH 1/4] bsg: fix initialization error handling bugs FUJITA Tomonori
@ 2007-07-17 10:08 ` FUJITA Tomonori
  2007-07-17 10:08 ` [PATCH 3/4] bsg: minor cleanup FUJITA Tomonori
  2007-07-17 10:08 ` [PATCH 4/4] bsg: Kconfig updates FUJITA Tomonori
  2 siblings, 0 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2007-07-17 10:08 UTC (permalink / raw)
  To: jens.axboe; +Cc: linux-scsi, akpm, tomof

- kill unused bsg_list_idx macro.
- add bsg_dev_idx_hash() that returns an appropriate hlist_head.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 block/bsg.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index b253784..55a4303 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -72,7 +72,6 @@ static DEFINE_MUTEX(bsg_mutex);
 static int bsg_device_nr, bsg_minor_idx;
 
 #define BSG_LIST_ARRAY_SIZE	8
-#define bsg_list_idx(minor)	((minor) & (BSG_LIST_ARRAY_SIZE - 1))
 static struct hlist_head bsg_device_list[BSG_LIST_ARRAY_SIZE];
 
 static struct class *bsg_class;
@@ -139,9 +138,9 @@ out:
 	return bc;
 }
 
-static inline void
-bsg_add_done_cmd(struct bsg_device *bd, struct bsg_command *bc)
+static inline struct hlist_head *bsg_dev_idx_hash(int index)
 {
+	return &bsg_device_list[index & (BSG_LIST_ARRAY_SIZE - 1)];
 }
 
 static int bsg_io_schedule(struct bsg_device *bd)
@@ -748,8 +747,7 @@ #endif
 	atomic_set(&bd->ref_count, 1);
 	bd->minor = iminor(inode);
 	mutex_lock(&bsg_mutex);
-	hlist_add_head(&bd->dev_list,
-		&bsg_device_list[bd->minor & (BSG_LIST_ARRAY_SIZE - 1)]);
+	hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(bd->minor));
 
 	strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1);
 	dprintk("bound to <%s>, max queue %d\n",
@@ -761,14 +759,12 @@ #endif
 
 static struct bsg_device *__bsg_get_device(int minor)
 {
-	struct hlist_head *list;
 	struct bsg_device *bd = NULL;
 	struct hlist_node *entry;
 
 	mutex_lock(&bsg_mutex);
 
-	list = &bsg_device_list[minor & (BSG_LIST_ARRAY_SIZE - 1)];
-	hlist_for_each(entry, list) {
+	hlist_for_each(entry, bsg_dev_idx_hash(minor)) {
 		bd = hlist_entry(entry, struct bsg_device, dev_list);
 		if (bd->minor == minor) {
 			atomic_inc(&bd->ref_count);
-- 
1.4.3.2


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

* [PATCH 3/4] bsg: minor cleanup
  2007-07-17 10:08 [PATCH 1/4] bsg: fix initialization error handling bugs FUJITA Tomonori
  2007-07-17 10:08 ` [PATCH 2/4] bsg: device hash table cleanup FUJITA Tomonori
@ 2007-07-17 10:08 ` FUJITA Tomonori
  2007-07-17 10:08 ` [PATCH 4/4] bsg: Kconfig updates FUJITA Tomonori
  2 siblings, 0 replies; 7+ messages in thread
From: FUJITA Tomonori @ 2007-07-17 10:08 UTC (permalink / raw)
  To: jens.axboe; +Cc: linux-scsi, akpm, tomof

- fix MODULE_DESCRIPTION typo.
- unify MODULE_DESCRIPTION and bsg_version.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 block/bsg.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index 55a4303..8e5fcf2 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -33,7 +33,8 @@ #include <scsi/scsi_device.h>
 #include <scsi/scsi_driver.h>
 #include <scsi/sg.h>
 
-const static char bsg_version[] = "block layer sg (bsg) 0.4";
+#define BSG_DESCRIPTION	"Block layer SCSI generic (bsg) driver"
+#define BSG_VERSION	"0.4"
 
 struct bsg_device {
 	request_queue_t *queue;
@@ -1072,7 +1073,8 @@ static int __init bsg_init(void)
 	if (ret)
 		goto remove_cdev;
 
-	printk(KERN_INFO "%s loaded (major %d)\n", bsg_version, bsg_major);
+	printk(KERN_INFO BSG_DESCRIPTION "version " BSG_VERSION
+	       " loaded (major %d)\n", bsg_major);
 	return 0;
 remove_cdev:
 	printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret);
@@ -1087,7 +1089,7 @@ destroy_kmemcache:
 }
 
 MODULE_AUTHOR("Jens Axboe");
-MODULE_DESCRIPTION("Block layer SGSI generic (sg) driver");
+MODULE_DESCRIPTION(BSG_DESCRIPTION);
 MODULE_LICENSE("GPL");
 
 device_initcall(bsg_init);
-- 
1.4.3.2


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

* [PATCH 4/4] bsg: Kconfig updates
  2007-07-17 10:08 [PATCH 1/4] bsg: fix initialization error handling bugs FUJITA Tomonori
  2007-07-17 10:08 ` [PATCH 2/4] bsg: device hash table cleanup FUJITA Tomonori
  2007-07-17 10:08 ` [PATCH 3/4] bsg: minor cleanup FUJITA Tomonori
@ 2007-07-17 10:08 ` FUJITA Tomonori
  2007-07-17 10:22   ` Jens Axboe
  2 siblings, 1 reply; 7+ messages in thread
From: FUJITA Tomonori @ 2007-07-17 10:08 UTC (permalink / raw)
  To: jens.axboe; +Cc: linux-scsi, akpm, tomof

- add the detailed explanation.
- remove 'default y'.
- make 'EXPERIMENTAL' keyword visible to the user in menu.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 block/Kconfig |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/block/Kconfig b/block/Kconfig
index 6597b60..0768741 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -52,11 +52,16 @@ config LSF
 endif # BLOCK
 
 config BLK_DEV_BSG
-	bool "Block layer SG support"
+	bool "Block layer SG support v4 (EXPERIMENTAL)"
 	depends on (SCSI=y) && EXPERIMENTAL
-	default y
 	---help---
-	Saying Y here will enable generic SG (SCSI generic) v4
-	support for any block device.
+	Saying Y here will enable generic SG (SCSI generic) v4 support
+	for any block device.
+
+	Unlike SG v3 (aka block/scsi_ioctl.c drivers/scsi/sg.c), SG v4
+	can handle complicated SCSI commands: tagged variable length cdbs
+	with bidirectional data transfers and generic request/response
+	protocols (e.g. Task Management Functions and SMP in Serial
+	Attached SCSI).
 
 source block/Kconfig.iosched
-- 
1.4.3.2


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

* Re: [PATCH 4/4] bsg: Kconfig updates
  2007-07-17 10:08 ` [PATCH 4/4] bsg: Kconfig updates FUJITA Tomonori
@ 2007-07-17 10:22   ` Jens Axboe
  0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2007-07-17 10:22 UTC (permalink / raw)
  To: FUJITA Tomonori; +Cc: linux-scsi, akpm, tomof

On Tue, Jul 17 2007, FUJITA Tomonori wrote:
> - add the detailed explanation.
> - remove 'default y'.
> - make 'EXPERIMENTAL' keyword visible to the user in menu.

Applied all 4, thanks!


-- 
Jens Axboe


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

end of thread, other threads:[~2007-07-17 10:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-17 10:08 [PATCH 1/4] bsg: fix initialization error handling bugs FUJITA Tomonori
2007-07-17 10:08 ` [PATCH 2/4] bsg: device hash table cleanup FUJITA Tomonori
2007-07-17 10:08 ` [PATCH 3/4] bsg: minor cleanup FUJITA Tomonori
2007-07-17 10:08 ` [PATCH 4/4] bsg: Kconfig updates FUJITA Tomonori
2007-07-17 10:22   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2007-07-09 13:02 FUJITA Tomonori
2007-06-08 15:12 FUJITA Tomonori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).