[lkml]   [2010]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[002/289] block: Fix race during disk initialization
    2.6.36-stable review patch.  If anyone has any objections, please let us know.


    From: Jan Kara <>

    commit 01ea50638bc04ca5259f5711fcdedefcdde1cf43 upstream.

    When a new disk is being discovered, add_disk() first ties the bdev to gendisk
    (via register_disk()->blkdev_get()) and only after that calls
    bdi_register_bdev(). Because register_disk() also creates disk's kobject, it
    can happen that userspace manages to open and modify the device's data (or
    inode) before its BDI is properly initialized leading to a warning in

    Fix the problem by registering BDI early enough.

    This patch addresses

    Reported-by: Larry Finger <>
    Signed-off-by: Jan Kara <>
    Signed-off-by: Jens Axboe <>
    Signed-off-by: Greg Kroah-Hartman <>

    block/genhd.c | 6 ++++--
    1 file changed, 4 insertions(+), 2 deletions(-)

    --- a/block/genhd.c
    +++ b/block/genhd.c
    @@ -541,13 +541,15 @@ void add_disk(struct gendisk *disk)
    disk->major = MAJOR(devt);
    disk->first_minor = MINOR(devt);

    + /* Register BDI before referencing it from bdev */
    + bdi = &disk->queue->backing_dev_info;
    + bdi_register_dev(bdi, disk_devt(disk));
    blk_register_region(disk_devt(disk), disk->minors, NULL,
    exact_match, exact_lock, disk);

    - bdi = &disk->queue->backing_dev_info;
    - bdi_register_dev(bdi, disk_devt(disk));
    retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj,

     \ /
      Last update: 2010-12-08 03:07    [W:0.029 / U:4.584 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site