]> www.infradead.org Git - users/jedix/linux-maple.git/commit
block: fix bdi vs gendisk lifetime mismatch
authorDan Williams <dan.j.williams@intel.com>
Sat, 15 Sep 2018 00:34:35 +0000 (17:34 -0700)
committerBrian Maly <brian.maly@oracle.com>
Tue, 30 Oct 2018 17:27:27 +0000 (13:27 -0400)
commit8bd274934987c2af04c2fe862009c026c5ba4910
tree17a5b6f18a49715cf25543984464c850547cd572
parentdd40df4059e2e34b4f4180c4aec03817cafc0857
block: fix bdi vs gendisk lifetime mismatch

Orabug: 28645416

The name for a bdi of a gendisk is derived from the gendisk's devt.
However, since the gendisk is destroyed before the bdi it leaves a
window where a new gendisk could dynamically reuse the same devt
while a bdi with the same name is still live.  Arrange for the bdi to hold a
reference against its "owner" disk device while it is registered.
Otherwise we can hit sysfs duplicate name collisions like the
following:

WARNING: CPU: 10 PID: 2078 at fs/sysfs/dir.c:31
sysfs_warn_dup+0x64/0x80
sysfs: cannot create duplicate filename
'/devices/virtual/bdi/259:1'

Hardware name: HP ProLiant DL580 Gen8, BIOS P79 05/06/2015
0000000000000286 0000000002c04ad5 ffff88006f24f970 ffffffff8134caec
ffff88006f24f9c0 0000000000000000 ffff88006f24f9b0 ffffffff8108c351
0000001f0000000c ffff88105d236000 ffff88105d1031e0 ffff8800357427f8
Call Trace:
 [<ffffffff8134caec>] dump_stack+0x63/0x87
 [<ffffffff8108c351>] __warn+0xd1/0xf0
 [<ffffffff8108c3cf>] warn_slowpath_fmt+0x5f/0x80
 [<ffffffff812a0d34>] sysfs_warn_dup+0x64/0x80
 [<ffffffff812a0e1e>] sysfs_create_dir_ns+0x7e/0x90
 [<ffffffff8134faaa>] kobject_add_internal+0xaa/0x320
 [<ffffffff81358d4e>] ? vsnprintf+0x34e/0x4d0
 [<ffffffff8134ff55>] kobject_add+0x75/0xd0
 [<ffffffff816e66b2>] ? mutex_lock+0x12/0x2f
 [<ffffffff8148b0a5>] device_add+0x125/0x610
 [<ffffffff8148b788>] device_create_groups_vargs+0xd8/0x100
 [<ffffffff8148b7cc>] device_create_vargs+0x1c/0x20
 [<ffffffff811b775c>] bdi_register+0x8c/0x180
 [<ffffffff811b7877>] bdi_register_dev+0x27/0x30
 [<ffffffff813317f5>] add_disk+0x175/0x4a0

Cc: <stable@vger.kernel.org>
Reported-by: Yi Zhang <yizhan@redhat.com>
Tested-by: Yi Zhang <yizhan@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Fixed up missing 0 return in bdi_register_owner().

Signed-off-by: Jens Axboe <axboe@fb.com>
(cherrypicked from commit df08c32ce3be5be138c1dbfcba203314a3a7cd6f)
Conflicts: mm/backing-dev.c
           include/linux/backing-dev.h

The patch breaks KABI as-is because of the introduction of a new "owner"
field in struct backing_dev_info. To work around that, use the
UEK_KABI_EXTEND() macro to wrap the "owner" filed with ifdef GENKSYMS.

Signed-off-by: Ashish Samant <ashish.samant@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
block/genhd.c
include/linux/backing-dev.h
mm/backing-dev.c