Ignore:
Timestamp:
Apr 21, 2017, 4:28:29 AM (5 weeks ago)
Author:
brainslayer
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/linux/universal/linux-3.18/drivers/scsi/sd.c

    r29540 r31885  
    19801980#define READ_CAPACITY_RETRIES_ON_RESET  10
    19811981
     1982/*
     1983 * Ensure that we don't overflow sector_t when CONFIG_LBDAF is not set
     1984 * and the reported logical block size is bigger than 512 bytes. Note
     1985 * that last_sector is a u64 and therefore logical_to_sectors() is not
     1986 * applicable.
     1987 */
     1988static bool sd_addressable_capacity(u64 lba, unsigned int sector_size)
     1989{
     1990        u64 last_sector = (lba + 1ULL) << (ilog2(sector_size) - 9);
     1991
     1992        if (sizeof(sector_t) == 4 && last_sector > U32_MAX)
     1993                return false;
     1994
     1995        return true;
     1996}
     1997
    19821998static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
    19831999                                                unsigned char *buffer)
     
    20452061        }
    20462062
    2047         if ((sizeof(sdkp->capacity) == 4) && (lba >= 0xffffffffULL)) {
     2063        if (!sd_addressable_capacity(lba, sector_size)) {
    20482064                sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a "
    20492065                        "kernel compiled with support for large block "
     
    21312147        }
    21322148
    2133         if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) {
     2149        if (!sd_addressable_capacity(lba, sector_size)) {
    21342150                sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a "
    21352151                        "kernel compiled with support for large block "
Note: See TracChangeset for help on using the changeset viewer.