Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 196874
b: refs/heads/master
c: c3e33e0
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed May 21, 2010
1 parent d033e49 commit bf36a00
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 56bca01738733709bef076e2e97bbd01e5659f24
refs/heads/master: c3e33e043f5e9c583aa59d5591a614b2a8243d3a
40 changes: 16 additions & 24 deletions trunk/drivers/ide/ide-disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,32 +407,24 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
return 0;
}

static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity)
static void ide_disk_unlock_native_capacity(ide_drive_t *drive)
{
u64 set = min(capacity, drive->probed_capacity);
u16 *id = drive->id;
int lba48 = ata_id_lba48_enabled(id);

if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 ||
ata_id_hpa_enabled(id) == 0)
goto out;
return;

/*
* according to the spec the SET MAX ADDRESS command shall be
* immediately preceded by a READ NATIVE MAX ADDRESS command
*/
capacity = ide_disk_hpa_get_native_capacity(drive, lba48);
if (capacity == 0)
goto out;

set = ide_disk_hpa_set_capacity(drive, set, lba48);
if (set) {
/* needed for ->resume to disable HPA */
drive->dev_flags |= IDE_DFLAG_NOHPA;
return set;
}
out:
return drive->capacity64;
if (!ide_disk_hpa_get_native_capacity(drive, lba48))
return;

if (ide_disk_hpa_set_capacity(drive, drive->probed_capacity, lba48))
drive->dev_flags |= IDE_DFLAG_NOHPA; /* disable HPA on resume */
}

static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
Expand Down Expand Up @@ -783,13 +775,13 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
}

const struct ide_disk_ops ide_ata_disk_ops = {
.check = ide_disk_check,
.set_capacity = ide_disk_set_capacity,
.get_capacity = ide_disk_get_capacity,
.setup = ide_disk_setup,
.flush = ide_disk_flush,
.init_media = ide_disk_init_media,
.set_doorlock = ide_disk_set_doorlock,
.do_request = ide_do_rw_disk,
.ioctl = ide_disk_ioctl,
.check = ide_disk_check,
.unlock_native_capacity = ide_disk_unlock_native_capacity,
.get_capacity = ide_disk_get_capacity,
.setup = ide_disk_setup,
.flush = ide_disk_flush,
.init_media = ide_disk_init_media,
.set_doorlock = ide_disk_set_doorlock,
.do_request = ide_do_rw_disk,
.ioctl = ide_disk_ioctl,
};
11 changes: 4 additions & 7 deletions trunk/drivers/ide/ide-gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,14 @@ static int ide_gd_media_changed(struct gendisk *disk)
return ret;
}

static unsigned long long ide_gd_set_capacity(struct gendisk *disk,
unsigned long long capacity)
static void ide_gd_unlock_native_capacity(struct gendisk *disk)
{
struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
ide_drive_t *drive = idkp->drive;
const struct ide_disk_ops *disk_ops = drive->disk_ops;

if (disk_ops->set_capacity)
return disk_ops->set_capacity(drive, capacity);

return drive->capacity64;
if (disk_ops->unlock_native_capacity)
disk_ops->unlock_native_capacity(drive);
}

static int ide_gd_revalidate_disk(struct gendisk *disk)
Expand Down Expand Up @@ -329,7 +326,7 @@ static const struct block_device_operations ide_gd_ops = {
.locked_ioctl = ide_gd_ioctl,
.getgeo = ide_gd_getgeo,
.media_changed = ide_gd_media_changed,
.set_capacity = ide_gd_set_capacity,
.unlock_native_capacity = ide_gd_unlock_native_capacity,
.revalidate_disk = ide_gd_revalidate_disk
};

Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/partitions/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
"%s: p%d size %llu exceeds device capacity, ",
disk->disk_name, p, (unsigned long long) size);

if (bdops->set_capacity &&
if (bdops->unlock_native_capacity &&
(disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) {
printk(KERN_CONT "enabling native capacity\n");
bdops->set_capacity(disk, ~0ULL);
bdops->unlock_native_capacity(disk);
disk->flags |= GENHD_FL_NATIVE_CAPACITY;
/* free state and restart */
kfree(state);
Expand Down
3 changes: 1 addition & 2 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1330,8 +1330,7 @@ struct block_device_operations {
int (*direct_access) (struct block_device *, sector_t,
void **, unsigned long *);
int (*media_changed) (struct gendisk *);
unsigned long long (*set_capacity) (struct gendisk *,
unsigned long long);
void (*unlock_native_capacity) (struct gendisk *);
int (*revalidate_disk) (struct gendisk *);
int (*getgeo)(struct block_device *, struct hd_geometry *);
struct module *owner;
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/ide.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ struct ide_drive_s;
struct ide_disk_ops {
int (*check)(struct ide_drive_s *, const char *);
int (*get_capacity)(struct ide_drive_s *);
u64 (*set_capacity)(struct ide_drive_s *, u64);
void (*unlock_native_capacity)(struct ide_drive_s *);
void (*setup)(struct ide_drive_s *);
void (*flush)(struct ide_drive_s *);
int (*init_media)(struct ide_drive_s *, struct gendisk *);
Expand Down

0 comments on commit bf36a00

Please sign in to comment.