Re: [PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-02 Thread Jens Axboe

On 2014-11-01 17:48, Ben Hutchings wrote:

On Sat, 2014-11-01 at 17:18 -0600, Jens Axboe wrote:

On 2014-11-01 16:28, Ben Hutchings wrote:

3.2.64-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Keith Busch 

commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.

Releases the dev_t minor when all references are closed to prevent
another device from acquiring the same major/minor.

Since the partition's release may be invoked from call_rcu's soft-irq
context, the ext_dev_idr's mutex had to be replaced with a spinlock so
as not so sleep.

Signed-off-by: Keith Busch 
Signed-off-by: Jens Axboe 
[bwh: Backported to 3.2:
   - Adjust filename
   - idr insertion API is different, and blk_alloc_devt() is preallocating
 a node in a different way]


As I've noted for pretty much every stable branch so far, you have to
backport commit 46f341ffcfb5 as well, if you backport this one.


I'm not caught up on reading the stable list, so I missed that.  Thanks
for pointing it out again; I'll add it.


Thanks, it keeps biting me in the ass that I didn't get a Fixes: added 
to that patch...



--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-02 Thread Jens Axboe

On 2014-11-01 17:48, Ben Hutchings wrote:

On Sat, 2014-11-01 at 17:18 -0600, Jens Axboe wrote:

On 2014-11-01 16:28, Ben Hutchings wrote:

3.2.64-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Keith Busch keith.bu...@intel.com

commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.

Releases the dev_t minor when all references are closed to prevent
another device from acquiring the same major/minor.

Since the partition's release may be invoked from call_rcu's soft-irq
context, the ext_dev_idr's mutex had to be replaced with a spinlock so
as not so sleep.

Signed-off-by: Keith Busch keith.bu...@intel.com
Signed-off-by: Jens Axboe ax...@fb.com
[bwh: Backported to 3.2:
   - Adjust filename
   - idr insertion API is different, and blk_alloc_devt() is preallocating
 a node in a different way]


As I've noted for pretty much every stable branch so far, you have to
backport commit 46f341ffcfb5 as well, if you backport this one.


I'm not caught up on reading the stable list, so I missed that.  Thanks
for pointing it out again; I'll add it.


Thanks, it keeps biting me in the ass that I didn't get a Fixes: added 
to that patch...



--
Jens Axboe

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-01 Thread Ben Hutchings
On Sat, 2014-11-01 at 17:18 -0600, Jens Axboe wrote:
> On 2014-11-01 16:28, Ben Hutchings wrote:
> > 3.2.64-rc1 review patch.  If anyone has any objections, please let me know.
> >
> > --
> >
> > From: Keith Busch 
> >
> > commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.
> >
> > Releases the dev_t minor when all references are closed to prevent
> > another device from acquiring the same major/minor.
> >
> > Since the partition's release may be invoked from call_rcu's soft-irq
> > context, the ext_dev_idr's mutex had to be replaced with a spinlock so
> > as not so sleep.
> >
> > Signed-off-by: Keith Busch 
> > Signed-off-by: Jens Axboe 
> > [bwh: Backported to 3.2:
> >   - Adjust filename
> >   - idr insertion API is different, and blk_alloc_devt() is preallocating
> > a node in a different way]
> 
> As I've noted for pretty much every stable branch so far, you have to 
> backport commit 46f341ffcfb5 as well, if you backport this one.

I'm not caught up on reading the stable list, so I missed that.  Thanks
for pointing it out again; I'll add it.

Ben.

-- 
Ben Hutchings
Kids!  Bringing about Armageddon can be dangerous.  Do not attempt it in
your own home. - Terry Pratchett and Neil Gaiman, `Good Omens'


signature.asc
Description: This is a digitally signed message part


Re: [PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-01 Thread Jens Axboe

On 2014-11-01 16:28, Ben Hutchings wrote:

3.2.64-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Keith Busch 

commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.

Releases the dev_t minor when all references are closed to prevent
another device from acquiring the same major/minor.

Since the partition's release may be invoked from call_rcu's soft-irq
context, the ext_dev_idr's mutex had to be replaced with a spinlock so
as not so sleep.

Signed-off-by: Keith Busch 
Signed-off-by: Jens Axboe 
[bwh: Backported to 3.2:
  - Adjust filename
  - idr insertion API is different, and blk_alloc_devt() is preallocating
a node in a different way]


As I've noted for pretty much every stable branch so far, you have to 
backport commit 46f341ffcfb5 as well, if you backport this one.


--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-01 Thread Ben Hutchings
3.2.64-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Keith Busch 

commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.

Releases the dev_t minor when all references are closed to prevent
another device from acquiring the same major/minor.

Since the partition's release may be invoked from call_rcu's soft-irq
context, the ext_dev_idr's mutex had to be replaced with a spinlock so
as not so sleep.

Signed-off-by: Keith Busch 
Signed-off-by: Jens Axboe 
[bwh: Backported to 3.2:
 - Adjust filename
 - idr insertion API is different, and blk_alloc_devt() is preallocating
   a node in a different way]
Signed-off-by: Ben Hutchings 
---
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -28,10 +28,10 @@ struct kobject *block_depr;
 /* for extended dynamic devt allocation, currently only one major is used */
 #define NR_EXT_DEVT(1 << MINORBITS)
 
-/* For extended devt allocation.  ext_devt_mutex prevents look up
+/* For extended devt allocation.  ext_devt_lock prevents look up
  * results from going away underneath its user.
  */
-static DEFINE_MUTEX(ext_devt_mutex);
+static DEFINE_SPINLOCK(ext_devt_lock);
 static DEFINE_IDR(ext_devt_idr);
 
 static struct device_type disk_type;
@@ -421,13 +421,13 @@ int blk_alloc_devt(struct hd_struct *par
do {
if (!idr_pre_get(_devt_idr, GFP_KERNEL))
return -ENOMEM;
-   mutex_lock(_devt_mutex);
+   spin_lock(_devt_lock);
rc = idr_get_new(_devt_idr, part, );
if (!rc && idx >= NR_EXT_DEVT) {
idr_remove(_devt_idr, idx);
rc = -EBUSY;
}
-   mutex_unlock(_devt_mutex);
+   spin_unlock(_devt_lock);
} while (rc == -EAGAIN);
 
if (rc)
@@ -454,9 +454,9 @@ void blk_free_devt(dev_t devt)
return;
 
if (MAJOR(devt) == BLOCK_EXT_MAJOR) {
-   mutex_lock(_devt_mutex);
+   spin_lock(_devt_lock);
idr_remove(_devt_idr, blk_mangle_minor(MINOR(devt)));
-   mutex_unlock(_devt_mutex);
+   spin_unlock(_devt_lock);
}
 }
 
@@ -663,7 +663,6 @@ void del_gendisk(struct gendisk *disk)
if (!sysfs_deprecated)
sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
device_del(disk_to_dev(disk));
-   blk_free_devt(disk_to_dev(disk)->devt);
 }
 EXPORT_SYMBOL(del_gendisk);
 
@@ -688,13 +687,13 @@ struct gendisk *get_gendisk(dev_t devt,
} else {
struct hd_struct *part;
 
-   mutex_lock(_devt_mutex);
+   spin_lock(_devt_lock);
part = idr_find(_devt_idr, blk_mangle_minor(MINOR(devt)));
if (part && get_disk(part_to_disk(part))) {
*partno = part->partno;
disk = part_to_disk(part);
}
-   mutex_unlock(_devt_mutex);
+   spin_unlock(_devt_lock);
}
 
return disk;
@@ -1102,6 +1101,7 @@ static void disk_release(struct device *
 {
struct gendisk *disk = dev_to_disk(dev);
 
+   blk_free_devt(dev->devt);
disk_release_events(disk);
kfree(disk->random);
disk_replace_part_tbl(disk, NULL);
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -361,6 +361,7 @@ static const struct attribute_group *par
 static void part_release(struct device *dev)
 {
struct hd_struct *p = dev_to_part(dev);
+   blk_free_devt(dev->devt);
free_part_stats(p);
free_part_info(p);
kfree(p);
@@ -403,7 +404,6 @@ void delete_partition(struct gendisk *di
rcu_assign_pointer(ptbl->last_lookup, NULL);
kobject_put(part->holder_dir);
device_del(part_to_dev(part));
-   blk_free_devt(part_devt(part));
 
hd_struct_put(part);
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-01 Thread Ben Hutchings
3.2.64-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Keith Busch keith.bu...@intel.com

commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.

Releases the dev_t minor when all references are closed to prevent
another device from acquiring the same major/minor.

Since the partition's release may be invoked from call_rcu's soft-irq
context, the ext_dev_idr's mutex had to be replaced with a spinlock so
as not so sleep.

Signed-off-by: Keith Busch keith.bu...@intel.com
Signed-off-by: Jens Axboe ax...@fb.com
[bwh: Backported to 3.2:
 - Adjust filename
 - idr insertion API is different, and blk_alloc_devt() is preallocating
   a node in a different way]
Signed-off-by: Ben Hutchings b...@decadent.org.uk
---
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -28,10 +28,10 @@ struct kobject *block_depr;
 /* for extended dynamic devt allocation, currently only one major is used */
 #define NR_EXT_DEVT(1  MINORBITS)
 
-/* For extended devt allocation.  ext_devt_mutex prevents look up
+/* For extended devt allocation.  ext_devt_lock prevents look up
  * results from going away underneath its user.
  */
-static DEFINE_MUTEX(ext_devt_mutex);
+static DEFINE_SPINLOCK(ext_devt_lock);
 static DEFINE_IDR(ext_devt_idr);
 
 static struct device_type disk_type;
@@ -421,13 +421,13 @@ int blk_alloc_devt(struct hd_struct *par
do {
if (!idr_pre_get(ext_devt_idr, GFP_KERNEL))
return -ENOMEM;
-   mutex_lock(ext_devt_mutex);
+   spin_lock(ext_devt_lock);
rc = idr_get_new(ext_devt_idr, part, idx);
if (!rc  idx = NR_EXT_DEVT) {
idr_remove(ext_devt_idr, idx);
rc = -EBUSY;
}
-   mutex_unlock(ext_devt_mutex);
+   spin_unlock(ext_devt_lock);
} while (rc == -EAGAIN);
 
if (rc)
@@ -454,9 +454,9 @@ void blk_free_devt(dev_t devt)
return;
 
if (MAJOR(devt) == BLOCK_EXT_MAJOR) {
-   mutex_lock(ext_devt_mutex);
+   spin_lock(ext_devt_lock);
idr_remove(ext_devt_idr, blk_mangle_minor(MINOR(devt)));
-   mutex_unlock(ext_devt_mutex);
+   spin_unlock(ext_devt_lock);
}
 }
 
@@ -663,7 +663,6 @@ void del_gendisk(struct gendisk *disk)
if (!sysfs_deprecated)
sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
device_del(disk_to_dev(disk));
-   blk_free_devt(disk_to_dev(disk)-devt);
 }
 EXPORT_SYMBOL(del_gendisk);
 
@@ -688,13 +687,13 @@ struct gendisk *get_gendisk(dev_t devt,
} else {
struct hd_struct *part;
 
-   mutex_lock(ext_devt_mutex);
+   spin_lock(ext_devt_lock);
part = idr_find(ext_devt_idr, blk_mangle_minor(MINOR(devt)));
if (part  get_disk(part_to_disk(part))) {
*partno = part-partno;
disk = part_to_disk(part);
}
-   mutex_unlock(ext_devt_mutex);
+   spin_unlock(ext_devt_lock);
}
 
return disk;
@@ -1102,6 +1101,7 @@ static void disk_release(struct device *
 {
struct gendisk *disk = dev_to_disk(dev);
 
+   blk_free_devt(dev-devt);
disk_release_events(disk);
kfree(disk-random);
disk_replace_part_tbl(disk, NULL);
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -361,6 +361,7 @@ static const struct attribute_group *par
 static void part_release(struct device *dev)
 {
struct hd_struct *p = dev_to_part(dev);
+   blk_free_devt(dev-devt);
free_part_stats(p);
free_part_info(p);
kfree(p);
@@ -403,7 +404,6 @@ void delete_partition(struct gendisk *di
rcu_assign_pointer(ptbl-last_lookup, NULL);
kobject_put(part-holder_dir);
device_del(part_to_dev(part));
-   blk_free_devt(part_devt(part));
 
hd_struct_put(part);
 }

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-01 Thread Jens Axboe

On 2014-11-01 16:28, Ben Hutchings wrote:

3.2.64-rc1 review patch.  If anyone has any objections, please let me know.

--

From: Keith Busch keith.bu...@intel.com

commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.

Releases the dev_t minor when all references are closed to prevent
another device from acquiring the same major/minor.

Since the partition's release may be invoked from call_rcu's soft-irq
context, the ext_dev_idr's mutex had to be replaced with a spinlock so
as not so sleep.

Signed-off-by: Keith Busch keith.bu...@intel.com
Signed-off-by: Jens Axboe ax...@fb.com
[bwh: Backported to 3.2:
  - Adjust filename
  - idr insertion API is different, and blk_alloc_devt() is preallocating
a node in a different way]


As I've noted for pretty much every stable branch so far, you have to 
backport commit 46f341ffcfb5 as well, if you backport this one.


--
Jens Axboe

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3.2 023/102] block: Fix dev_t minor allocation lifetime

2014-11-01 Thread Ben Hutchings
On Sat, 2014-11-01 at 17:18 -0600, Jens Axboe wrote:
 On 2014-11-01 16:28, Ben Hutchings wrote:
  3.2.64-rc1 review patch.  If anyone has any objections, please let me know.
 
  --
 
  From: Keith Busch keith.bu...@intel.com
 
  commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.
 
  Releases the dev_t minor when all references are closed to prevent
  another device from acquiring the same major/minor.
 
  Since the partition's release may be invoked from call_rcu's soft-irq
  context, the ext_dev_idr's mutex had to be replaced with a spinlock so
  as not so sleep.
 
  Signed-off-by: Keith Busch keith.bu...@intel.com
  Signed-off-by: Jens Axboe ax...@fb.com
  [bwh: Backported to 3.2:
- Adjust filename
- idr insertion API is different, and blk_alloc_devt() is preallocating
  a node in a different way]
 
 As I've noted for pretty much every stable branch so far, you have to 
 backport commit 46f341ffcfb5 as well, if you backport this one.

I'm not caught up on reading the stable list, so I missed that.  Thanks
for pointing it out again; I'll add it.

Ben.

-- 
Ben Hutchings
Kids!  Bringing about Armageddon can be dangerous.  Do not attempt it in
your own home. - Terry Pratchett and Neil Gaiman, `Good Omens'


signature.asc
Description: This is a digitally signed message part