• Boaz Harrosh's avatar
    brd: Request from fdisk 4k alignment · c8fa3173
    Boaz Harrosh authored
    Because of the direct_access() API which returns a PFN. partitions
    better start on 4K boundary, else offset ZERO of a partition will
    not be aligned and blk_direct_access() will fail the call.
    
    By setting blk_queue_physical_block_size(PAGE_SIZE) we can communicate
    this to fdisk and friends.
    
    The call to blk_queue_physical_block_size() is harmless and will
    not affect the Kernel behavior in any way. It is only for
    communication to user-mode.
    
    before this patch running fdisk on a default size brd of 4M
    the first sector offered is 34 (BAD), but after this patch it
    will be 40, ie 8 sectors aligned. Also when entering some random
    partition sizes the next partition-start sector is offered 8 sectors
    aligned after this patch. (Please note that with fdisk the user
    can still enter bad values, only the offered default values will
    be correct)
    
    Note that with bdev-size > 4M fdisk will try to align on a 1M
    boundary (above first-sector will be 2048), in any case.
    
    CC: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: default avatarBoaz Harrosh <boaz@plexistor.com>
    Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: default avatarJens Axboe <axboe@fb.com>
    c8fa3173
brd.c 15 KB