| @@ -27,39 +27,8 @@ · 26 unmodified lines |
| 27 | 27 | #define part_to_dev(part) (&((part)->__dev)) |
| 28 | 28 | |
| 29 | 29 | extern struct device_type part_type; |
| 30 | | −extern struct kobject *block_depr; |
| 31 | 30 | extern struct class block_class; |
| 32 | 31 | |
| 33 | | −enum { |
| 34 | | −/* These three have identical behaviour; use the second one if DOS FDISK gets |
| 35 | | − confused about extended/logical partitions starting past cylinder 1023. */ |
| 36 | | − DOS_EXTENDED_PARTITION = 5, |
| 37 | | − LINUX_EXTENDED_PARTITION = 0x85, |
| 38 | | − WIN98_EXTENDED_PARTITION = 0x0f, |
| 39 | | − |
| 40 | | − SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION, |
| 41 | | − |
| 42 | | − LINUX_SWAP_PARTITION = 0x82, |
| 43 | | − LINUX_DATA_PARTITION = 0x83, |
| 44 | | − LINUX_LVM_PARTITION = 0x8e, |
| 45 | | − LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ |
| 46 | | − |
| 47 | | − SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION, |
| 48 | | − NEW_SOLARIS_X86_PARTITION = 0xbf, |
| 49 | | − |
| 50 | | − DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */ |
| 51 | | − DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */ |
| 52 | | − DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */ |
| 53 | | − EZD_PARTITION = 0x55, /* EZ-DRIVE */ |
| 54 | | − |
| 55 | | − FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */ |
| 56 | | − OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */ |
| 57 | | − NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */ |
| 58 | | − BSDI_PARTITION = 0xb7, /* BSDI Partition ID */ |
| 59 | | − MINIX_PARTITION = 0x81, /* Minix Partition ID */ |
| 60 | | − UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */ |
| 61 | | −}; |
| 62 | | − |
| 63 | 32 | #define DISK_MAX_PARTS 256 |
| 64 | 33 | #define DISK_NAME_LEN 32 |
| 65 | 34 | |
| @@ -70,26 +39,12 @@ enum { · 4 unmodified lines |
| 70 | 39 | #include <linux/fs.h> |
| 71 | 40 | #include <linux/workqueue.h> |
| 72 | 41 | |
| 73 | | −struct partition { |
| 74 | | − unsigned char boot_ind; /* 0x80 - active */ |
| 75 | | − unsigned char head; /* starting head */ |
| 76 | | − unsigned char sector; /* starting sector */ |
| 77 | | − unsigned char cyl; /* starting cylinder */ |
| 78 | | − unsigned char sys_ind; /* What partition type */ |
| 79 | | − unsigned char end_head; /* end head */ |
| 80 | | − unsigned char end_sector; /* end sector */ |
| 81 | | − unsigned char end_cyl; /* end cylinder */ |
| 82 | | − __le32 start_sect; /* starting sector counting from 0 */ |
| 83 | | − __le32 nr_sects; /* nr of sectors in partition */ |
| 84 | | −} __attribute__((packed)); |
| 85 | | − |
| 86 | 42 | struct disk_stats { |
| 87 | 43 | u64 nsecs[NR_STAT_GROUPS]; |
| 88 | 44 | unsigned long sectors[NR_STAT_GROUPS]; |
| 89 | 45 | unsigned long ios[NR_STAT_GROUPS]; |
| 90 | 46 | unsigned long merges[NR_STAT_GROUPS]; |
| 91 | 47 | unsigned long io_ticks; |
| 92 | | − unsigned long time_in_queue; |
| 93 | 48 | local_t in_flight[2]; |
| 94 | 49 | }; |
| 95 | 50 | |
| @@ -133,17 +88,64 @@ struct hd_struct { · 37 unmodified lines |
| 133 | 88 | struct rcu_work rcu_work; |
| 134 | 89 | }; |
| 135 | 90 | |
| 136 | | −#define GENHD_FL_REMOVABLE 1 |
| 137 | | −/* 2 is unused */ |
| 138 | | −#define GENHD_FL_MEDIA_CHANGE_NOTIFY 4 |
| 139 | | −#define GENHD_FL_CD 8 |
| 140 | | −#define GENHD_FL_UP 16 |
| 141 | | −#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 |
| 142 | | −#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ |
| 143 | | −#define GENHD_FL_NATIVE_CAPACITY 128 |
| 144 | | −#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256 |
| 145 | | −#define GENHD_FL_NO_PART_SCAN 512 |
| 146 | | −#define GENHD_FL_HIDDEN 1024 |
| 91 | +/** |
| 92 | + * DOC: genhd capability flags |
| 93 | + * |
| 94 | + * ``GENHD_FL_REMOVABLE`` (0x0001): indicates that the block device |
| 95 | + * gives access to removable media. |
| 96 | + * When set, the device remains present even when media is not |
| 97 | + * inserted. |
| 98 | + * Must not be set for devices which are removed entirely when the |
| 99 | + * media is removed. |
| 100 | + * |
| 101 | + * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style |
| 102 | + * device. |
| 103 | + * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl. |
| 104 | + * |
| 105 | + * ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up", |
| 106 | + * with a similar meaning to network interfaces. |
| 107 | + * |
| 108 | + * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include |
| 109 | + * partition information in ``/proc/partitions`` or in the output of |
| 110 | + * printk_all_partitions(). |
| 111 | + * Used for the null block device and some MMC devices. |
| 112 | + * |
| 113 | + * ``GENHD_FL_EXT_DEVT`` (0x0040): the driver supports extended |
| 114 | + * dynamic ``dev_t``, i.e. it wants extended device numbers |
| 115 | + * (``BLOCK_EXT_MAJOR``). |
| 116 | + * This affects the maximum number of partitions. |
| 117 | + * |
| 118 | + * ``GENHD_FL_NATIVE_CAPACITY`` (0x0080): based on information in the |
| 119 | + * partition table, the device's capacity has been extended to its |
| 120 | + * native capacity; i.e. the device has hidden capacity used by one |
| 121 | + * of the partitions (this is a flag used so that native capacity is |
| 122 | + * only ever unlocked once). |
| 123 | + * |
| 124 | + * ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is |
| 125 | + * blocked whenever a writer holds an exclusive lock. |
| 126 | + * |
| 127 | + * ``GENHD_FL_NO_PART_SCAN`` (0x0200): partition scanning is disabled. |
| 128 | + * Used for loop devices in their default settings and some MMC |
| 129 | + * devices. |
| 130 | + * |
| 131 | + * ``GENHD_FL_HIDDEN`` (0x0400): the block device is hidden; it |
| 132 | + * doesn't produce events, doesn't appear in sysfs, and doesn't have |
| 133 | + * an associated ``bdev``. |
| 134 | + * Implies ``GENHD_FL_SUPPRESS_PARTITION_INFO`` and |
| 135 | + * ``GENHD_FL_NO_PART_SCAN``. |
| 136 | + * Used for multipath devices. |
| 137 | + */ |
| 138 | +#define GENHD_FL_REMOVABLE 0x0001 |
| 139 | +/* 2 is unused (used to be GENHD_FL_DRIVERFS) */ |
| 140 | +/* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */ |
| 141 | +#define GENHD_FL_CD 0x0008 |
| 142 | +#define GENHD_FL_UP 0x0010 |
| 143 | +#define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020 |
| 144 | +#define GENHD_FL_EXT_DEVT 0x0040 |
| 145 | +#define GENHD_FL_NATIVE_CAPACITY 0x0080 |
| 146 | +#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100 |
| 147 | +#define GENHD_FL_NO_PART_SCAN 0x0200 |
| 148 | +#define GENHD_FL_HIDDEN 0x0400 |
| 147 | 149 | |
| 148 | 150 | enum { |
| 149 | 151 | DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */ |
| @@ -189,7 +191,6 @@ struct gendisk { · 39 unmodified lines |
| 189 | 191 | * disks that can't be partitioned. */ |
| 190 | 192 | |
| 191 | 193 | char disk_name[DISK_NAME_LEN]; /* name of major driver */ |
| 192 | | − char *(*devnode)(struct gendisk *gd, umode_t *mode); |
| 193 | 194 | |
| 194 | 195 | unsigned short events; /* supported events */ |
| 195 | 196 | unsigned short event_flags; /* flags related to event processing */ |
| @@ -283,144 +284,7 @@ extern void disk_part_iter_init(struct disk_part_iter *piter, · 87 unmodified lines |
| 283 | 284 | struct gendisk *disk, unsigned int flags); |
| 284 | 285 | extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter); |
| 285 | 286 | extern void disk_part_iter_exit(struct disk_part_iter *piter); |
| 286 | | − |
| 287 | | −extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, |
| 288 | | − sector_t sector); |
| 289 | | −bool disk_has_partitions(struct gendisk *disk); |
| 290 | | − |
| 291 | | −/* |
| 292 | | − * Macros to operate on percpu disk statistics: |
| 293 | | − * |
| 294 | | − * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters |
| 295 | | − * and should be called between disk_stat_lock() and |
| 296 | | − * disk_stat_unlock(). |
| 297 | | − * |
| 298 | | − * part_stat_read() can be called at any time. |
| 299 | | − * |
| 300 | | − * part_stat_{add|set_all}() and {init|free}_part_stats are for |
| 301 | | − * internal use only. |
| 302 | | − */ |
| 303 | | −#ifdef CONFIG_SMP |
| 304 | | −#define part_stat_lock() ({ rcu_read_lock(); get_cpu(); }) |
| 305 | | −#define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0) |
| 306 | | − |
| 307 | | −#define part_stat_get_cpu(part, field, cpu) \ |
| 308 | | − (per_cpu_ptr((part)->dkstats, (cpu))->field) |
| 309 | | − |
| 310 | | −#define part_stat_get(part, field) \ |
| 311 | | − part_stat_get_cpu(part, field, smp_processor_id()) |
| 312 | | − |
| 313 | | −#define part_stat_read(part, field) \ |
| 314 | | −({ \ |
| 315 | | − typeof((part)->dkstats->field) res = 0; \ |
| 316 | | − unsigned int _cpu; \ |
| 317 | | − for_each_possible_cpu(_cpu) \ |
| 318 | | − res += per_cpu_ptr((part)->dkstats, _cpu)->field; \ |
| 319 | | − res; \ |
| 320 | | −}) |
| 321 | | − |
| 322 | | −static inline void part_stat_set_all(struct hd_struct *part, int value) |
| 323 | | −{ |
| 324 | | − int i; |
| 325 | | − |
| 326 | | − for_each_possible_cpu(i) |
| 327 | | − memset(per_cpu_ptr(part->dkstats, i), value, |
| 328 | | − sizeof(struct disk_stats)); |
| 329 | | −} |
| 330 | | − |
| 331 | | −static inline int init_part_stats(struct hd_struct *part) |
| 332 | | −{ |
| 333 | | − part->dkstats = alloc_percpu(struct disk_stats); |
| 334 | | − if (!part->dkstats) |
| 335 | | − return 0; |
| 336 | | − return 1; |
| 337 | | −} |
| 338 | | − |
| 339 | | −static inline void free_part_stats(struct hd_struct *part) |
| 340 | | −{ |
| 341 | | − free_percpu(part->dkstats); |
| 342 | | −} |
| 343 | | − |
| 344 | | −#else /* !CONFIG_SMP */ |
| 345 | | −#define part_stat_lock() ({ rcu_read_lock(); 0; }) |
| 346 | | −#define part_stat_unlock() rcu_read_unlock() |
| 347 | | − |
| 348 | | −#define part_stat_get(part, field) ((part)->dkstats.field) |
| 349 | | −#define part_stat_get_cpu(part, field, cpu) part_stat_get(part, field) |
| 350 | | −#define part_stat_read(part, field) part_stat_get(part, field) |
| 351 | | − |
| 352 | | −static inline void part_stat_set_all(struct hd_struct *part, int value) |
| 353 | | −{ |
| 354 | | − memset(&part->dkstats, value, sizeof(struct disk_stats)); |
| 355 | | −} |
| 356 | | − |
| 357 | | −static inline int init_part_stats(struct hd_struct *part) |
| 358 | | −{ |
| 359 | | − return 1; |
| 360 | | −} |
| 361 | | − |
| 362 | | −static inline void free_part_stats(struct hd_struct *part) |
| 363 | | −{ |
| 364 | | −} |
| 365 | | − |
| 366 | | −#endif /* CONFIG_SMP */ |
| 367 | | − |
| 368 | | −#define part_stat_read_msecs(part, which) \ |
| 369 | | − div_u64(part_stat_read(part, nsecs[which]), NSEC_PER_MSEC) |
| 370 | | − |
| 371 | | −#define part_stat_read_accum(part, field) \ |
| 372 | | − (part_stat_read(part, field[STAT_READ]) + \ |
| 373 | | − part_stat_read(part, field[STAT_WRITE]) + \ |
| 374 | | − part_stat_read(part, field[STAT_DISCARD])) |
| 375 | | − |
| 376 | | −#define __part_stat_add(part, field, addnd) \ |
| 377 | | − (part_stat_get(part, field) += (addnd)) |
| 378 | | − |
| 379 | | −#define part_stat_add(part, field, addnd) do { \ |
| 380 | | − __part_stat_add((part), field, addnd); \ |
| 381 | | − if ((part)->partno) \ |
| 382 | | − __part_stat_add(&part_to_disk((part))->part0, \ |
| 383 | | − field, addnd); \ |
| 384 | | −} while (0) |
| 385 | | − |
| 386 | | −#define part_stat_dec(gendiskp, field) \ |
| 387 | | − part_stat_add(gendiskp, field, -1) |
| 388 | | −#define part_stat_inc(gendiskp, field) \ |
| 389 | | − part_stat_add(gendiskp, field, 1) |
| 390 | | −#define part_stat_sub(gendiskp, field, subnd) \ |
| 391 | | − part_stat_add(gendiskp, field, -subnd) |
| 392 | | − |
| 393 | | −#define part_stat_local_dec(gendiskp, field) \ |
| 394 | | − local_dec(&(part_stat_get(gendiskp, field))) |
| 395 | | −#define part_stat_local_inc(gendiskp, field) \ |
| 396 | | − local_inc(&(part_stat_get(gendiskp, field))) |
| 397 | | −#define part_stat_local_read(gendiskp, field) \ |
| 398 | | − local_read(&(part_stat_get(gendiskp, field))) |
| 399 | | −#define part_stat_local_read_cpu(gendiskp, field, cpu) \ |
| 400 | | − local_read(&(part_stat_get_cpu(gendiskp, field, cpu))) |
| 401 | | − |
| 402 | | −unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part); |
| 403 | | −void part_in_flight_rw(struct request_queue *q, struct hd_struct *part, |
| 404 | | − unsigned int inflight[2]); |
| 405 | | −void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, |
| 406 | | − int rw); |
| 407 | | −void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, |
| 408 | | − int rw); |
| 409 | | − |
| 410 | | −static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk) |
| 411 | | −{ |
| 412 | | − if (disk) |
| 413 | | − return kzalloc_node(sizeof(struct partition_meta_info), |
| 414 | | − GFP_KERNEL, disk->node_id); |
| 415 | | − return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL); |
| 416 | | −} |
| 417 | | − |
| 418 | | −static inline void free_part_info(struct hd_struct *part) |
| 419 | | −{ |
| 420 | | − kfree(part->info); |
| 421 | | −} |
| 422 | | − |
| 423 | | −void update_io_ticks(struct hd_struct *part, unsigned long now); |
| 287 | +extern bool disk_has_partitions(struct gendisk *disk); |
| 424 | 288 | |
| 425 | 289 | /* block/genhd.c */ |
| 426 | 290 | extern void device_add_disk(struct device *parent, struct gendisk *disk, |
| @@ -450,6 +314,8 @@ static inline int get_disk_ro(struct gendisk *disk) · 23 unmodified lines |
| 450 | 314 | extern void disk_block_events(struct gendisk *disk); |
| 451 | 315 | extern void disk_unblock_events(struct gendisk *disk); |
| 452 | 316 | extern void disk_flush_events(struct gendisk *disk, unsigned int mask); |
| 317 | +extern void set_capacity_revalidate_and_notify(struct gendisk *disk, |
| 318 | + sector_t size, bool revalidate); |
| 453 | 319 | extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask); |
| 454 | 320 | |
| 455 | 321 | /* drivers/char/random.c */ |
| @@ -469,170 +335,11 @@ static inline void set_capacity(struct gendisk *disk, sector_t size) · 13 unmodified lines |
| 469 | 335 | disk->part0.nr_sects = size; |
| 470 | 336 | } |
| 471 | 337 | |
| 472 | | −#ifdef CONFIG_SOLARIS_X86_PARTITION |
| 473 | | − |
| 474 | | −#define SOLARIS_X86_NUMSLICE 16 |
| 475 | | −#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) |
| 476 | | − |
| 477 | | −struct solaris_x86_slice { |
| 478 | | − __le16 s_tag; /* ID tag of partition */ |
| 479 | | − __le16 s_flag; /* permission flags */ |
| 480 | | − __le32 s_start; /* start sector no of partition */ |
| 481 | | − __le32 s_size; /* # of blocks in partition */ |
| 482 | | −}; |
| 483 | | − |
| 484 | | −struct solaris_x86_vtoc { |
| 485 | | − unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */ |
| 486 | | − __le32 v_sanity; /* to verify vtoc sanity */ |
| 487 | | − __le32 v_version; /* layout version */ |
| 488 | | − char v_volume[8]; /* volume name */ |
| 489 | | − __le16 v_sectorsz; /* sector size in bytes */ |
| 490 | | − __le16 v_nparts; /* number of partitions */ |
| 491 | | − unsigned int v_reserved[10]; /* free space */ |
| 492 | | − struct solaris_x86_slice |
| 493 | | − v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */ |
| 494 | | − unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */ |
| 495 | | − char v_asciilabel[128]; /* for compatibility */ |
| 496 | | −}; |
| 497 | | − |
| 498 | | −#endif /* CONFIG_SOLARIS_X86_PARTITION */ |
| 499 | | − |
| 500 | | −#ifdef CONFIG_BSD_DISKLABEL |
| 501 | | −/* |
| 502 | | − * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il> |
| 503 | | − * updated by Marc Espie <Marc.Espie@openbsd.org> |
| 504 | | − */ |
| 505 | | − |
| 506 | | −/* check against BSD src/sys/sys/disklabel.h for consistency */ |
| 507 | | − |
| 508 | | −#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ |
| 509 | | −#define BSD_MAXPARTITIONS 16 |
| 510 | | −#define OPENBSD_MAXPARTITIONS 16 |
| 511 | | −#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */ |
| 512 | | −struct bsd_disklabel { |
| 513 | | − __le32 d_magic; /* the magic number */ |
| 514 | | − __s16 d_type; /* drive type */ |
| 515 | | − __s16 d_subtype; /* controller/d_type specific */ |
| 516 | | − char d_typename[16]; /* type name, e.g. "eagle" */ |
| 517 | | − char d_packname[16]; /* pack identifier */ |
| 518 | | − __u32 d_secsize; /* # of bytes per sector */ |
| 519 | | − __u32 d_nsectors; /* # of data sectors per track */ |
| 520 | | − __u32 d_ntracks; /* # of tracks per cylinder */ |
| 521 | | − __u32 d_ncylinders; /* # of data cylinders per unit */ |
| 522 | | − __u32 d_secpercyl; /* # of data sectors per cylinder */ |
| 523 | | − __u32 d_secperunit; /* # of data sectors per unit */ |
| 524 | | − __u16 d_sparespertrack; /* # of spare sectors per track */ |
| 525 | | − __u16 d_sparespercyl; /* # of spare sectors per cylinder */ |
| 526 | | − __u32 d_acylinders; /* # of alt. cylinders per unit */ |
| 527 | | − __u16 d_rpm; /* rotational speed */ |
| 528 | | − __u16 d_interleave; /* hardware sector interleave */ |
| 529 | | − __u16 d_trackskew; /* sector 0 skew, per track */ |
| 530 | | − __u16 d_cylskew; /* sector 0 skew, per cylinder */ |
| 531 | | − __u32 d_headswitch; /* head switch time, usec */ |
| 532 | | − __u32 d_trkseek; /* track-to-track seek, usec */ |
| 533 | | − __u32 d_flags; /* generic flags */ |
| 534 | | −#define NDDATA 5 |
| 535 | | − __u32 d_drivedata[NDDATA]; /* drive-type specific information */ |
| 536 | | −#define NSPARE 5 |
| 537 | | − __u32 d_spare[NSPARE]; /* reserved for future use */ |
| 538 | | − __le32 d_magic2; /* the magic number (again) */ |
| 539 | | − __le16 d_checksum; /* xor of data incl. partitions */ |
| 540 | | − |
| 541 | | − /* filesystem and partition information: */ |
| 542 | | − __le16 d_npartitions; /* number of partitions in following */ |
| 543 | | − __le32 d_bbsize; /* size of boot area at sn0, bytes */ |
| 544 | | − __le32 d_sbsize; /* max size of fs superblock, bytes */ |
| 545 | | − struct bsd_partition { /* the partition table */ |
| 546 | | − __le32 p_size; /* number of sectors in partition */ |
| 547 | | − __le32 p_offset; /* starting sector */ |
| 548 | | − __le32 p_fsize; /* filesystem basic fragment size */ |
| 549 | | − __u8 p_fstype; /* filesystem type, see below */ |
| 550 | | − __u8 p_frag; /* filesystem fragments per block */ |
| 551 | | − __le16 p_cpg; /* filesystem cylinders per group */ |
| 552 | | − } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */ |
| 553 | | −}; |
| 554 | | − |
| 555 | | −#endif /* CONFIG_BSD_DISKLABEL */ |
| 556 | | − |
| 557 | | −#ifdef CONFIG_UNIXWARE_DISKLABEL |
| 558 | | −/* |
| 559 | | − * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl> |
| 560 | | − * and Krzysztof G. Baranowski <kgb@knm.org.pl> |
| 561 | | − */ |
| 562 | | − |
| 563 | | −#define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */ |
| 564 | | −#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */ |
| 565 | | −#define UNIXWARE_NUMSLICE 16 |
| 566 | | −#define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */ |
| 567 | | − |
| 568 | | −struct unixware_slice { |
| 569 | | − __le16 s_label; /* label */ |
| 570 | | − __le16 s_flags; /* permission flags */ |
| 571 | | − __le32 start_sect; /* starting sector */ |
| 572 | | − __le32 nr_sects; /* number of sectors in slice */ |
| 573 | | −}; |
| 574 | | − |
| 575 | | −struct unixware_disklabel { |
| 576 | | − __le32 d_type; /* drive type */ |
| 577 | | − __le32 d_magic; /* the magic number */ |
| 578 | | − __le32 d_version; /* version number */ |
| 579 | | − char d_serial[12]; /* serial number of the device */ |
| 580 | | − __le32 d_ncylinders; /* # of data cylinders per device */ |
| 581 | | − __le32 d_ntracks; /* # of tracks per cylinder */ |
| 582 | | − __le32 d_nsectors; /* # of data sectors per track */ |
| 583 | | − __le32 d_secsize; /* # of bytes per sector */ |
| 584 | | − __le32 d_part_start; /* # of first sector of this partition */ |
| 585 | | − __le32 d_unknown1[12]; /* ? */ |
| 586 | | − __le32 d_alt_tbl; /* byte offset of alternate table */ |
| 587 | | − __le32 d_alt_len; /* byte length of alternate table */ |
| 588 | | − __le32 d_phys_cyl; /* # of physical cylinders per device */ |
| 589 | | − __le32 d_phys_trk; /* # of physical tracks per cylinder */ |
| 590 | | − __le32 d_phys_sec; /* # of physical sectors per track */ |
| 591 | | − __le32 d_phys_bytes; /* # of physical bytes per sector */ |
| 592 | | − __le32 d_unknown2; /* ? */ |
| 593 | | − __le32 d_unknown3; /* ? */ |
| 594 | | − __le32 d_pad[8]; /* pad */ |
| 595 | | − |
| 596 | | − struct unixware_vtoc { |
| 597 | | − __le32 v_magic; /* the magic number */ |
| 598 | | − __le32 v_version; /* version number */ |
| 599 | | − char v_name[8]; /* volume name */ |
| 600 | | − __le16 v_nslices; /* # of slices */ |
| 601 | | − __le16 v_unknown1; /* ? */ |
| 602 | | − __le32 v_reserved[10]; /* reserved */ |
| 603 | | − struct unixware_slice |
| 604 | | − v_slice[UNIXWARE_NUMSLICE]; /* slice headers */ |
| 605 | | − } vtoc; |
| 606 | | − |
| 607 | | −}; /* 408 */ |
| 608 | | − |
| 609 | | −#endif /* CONFIG_UNIXWARE_DISKLABEL */ |
| 610 | | − |
| 611 | | −#ifdef CONFIG_MINIX_SUBPARTITION |
| 612 | | −# define MINIX_NR_SUBPARTITIONS 4 |
| 613 | | −#endif /* CONFIG_MINIX_SUBPARTITION */ |
| 614 | | − |
| 615 | | −#define ADDPART_FLAG_NONE 0 |
| 616 | | −#define ADDPART_FLAG_RAID 1 |
| 617 | | −#define ADDPART_FLAG_WHOLEDISK 2 |
| 618 | | − |
| 619 | | −extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt); |
| 620 | | −extern void blk_free_devt(dev_t devt); |
| 621 | | −extern void blk_invalidate_devt(dev_t devt); |
| 622 | 338 | extern dev_t blk_lookup_devt(const char *name, int partno); |
| 623 | | −extern char *disk_name (struct gendisk *hd, int partno, char *buf); |
| 624 | 339 | |
| 625 | 340 | int bdev_disk_changed(struct block_device *bdev, bool invalidate); |
| 626 | 341 | int blk_add_partitions(struct gendisk *disk, struct block_device *bdev); |
| 627 | 342 | int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev); |
| 628 | | −extern int disk_expand_part_tbl(struct gendisk *disk, int target); |
| 629 | | −extern struct hd_struct * __must_check add_partition(struct gendisk *disk, |
| 630 | | − int partno, sector_t start, |
| 631 | | − sector_t len, int flags, |
| 632 | | − struct partition_meta_info |
| 633 | | − *info); |
| 634 | | −extern void __delete_partition(struct percpu_ref *); |
| 635 | | −extern void delete_partition(struct gendisk *, int); |
| 636 | 343 | extern void printk_all_partitions(void); |
| 637 | 344 | |
| 638 | 345 | extern struct gendisk *__alloc_disk_node(int minors, int node_id); |
| @@ -646,20 +353,6 @@ extern void blk_register_region(dev_t devt, unsigned long range, · 7 unmodified lines |
| 646 | 353 | void *data); |
| 647 | 354 | extern void blk_unregister_region(dev_t devt, unsigned long range); |
| 648 | 355 | |
| 649 | | −extern ssize_t part_size_show(struct device *dev, |
| 650 | | − struct device_attribute *attr, char *buf); |
| 651 | | −extern ssize_t part_stat_show(struct device *dev, |
| 652 | | − struct device_attribute *attr, char *buf); |
| 653 | | −extern ssize_t part_inflight_show(struct device *dev, |
| 654 | | − struct device_attribute *attr, char *buf); |
| 655 | | −#ifdef CONFIG_FAIL_MAKE_REQUEST |
| 656 | | −extern ssize_t part_fail_show(struct device *dev, |
| 657 | | − struct device_attribute *attr, char *buf); |
| 658 | | −extern ssize_t part_fail_store(struct device *dev, |
| 659 | | − struct device_attribute *attr, |
| 660 | | − const char *buf, size_t count); |
| 661 | | −#endif /* CONFIG_FAIL_MAKE_REQUEST */ |
| 662 | | − |
| 663 | 356 | #define alloc_disk_node(minors, node_id) \ |
| 664 | 357 | ({ \ |
| 665 | 358 | static struct lock_class_key __key; \ |
| @@ -678,100 +371,6 @@ extern ssize_t part_fail_store(struct device *dev, · 12 unmodified lines |
| 678 | 371 | |
| 679 | 372 | #define alloc_disk(minors) alloc_disk_node(minors, NUMA_NO_NODE) |
| 680 | 373 | |
| 681 | | −static inline int hd_ref_init(struct hd_struct *part) |
| 682 | | −{ |
| 683 | | − if (percpu_ref_init(&part->ref, __delete_partition, 0, |
| 684 | | − GFP_KERNEL)) |
| 685 | | − return -ENOMEM; |
| 686 | | − return 0; |
| 687 | | −} |
| 688 | | − |
| 689 | | −static inline void hd_struct_get(struct hd_struct *part) |
| 690 | | −{ |
| 691 | | − percpu_ref_get(&part->ref); |
| 692 | | −} |
| 693 | | − |
| 694 | | −static inline int hd_struct_try_get(struct hd_struct *part) |
| 695 | | −{ |
| 696 | | − return percpu_ref_tryget_live(&part->ref); |
| 697 | | −} |
| 698 | | − |
| 699 | | −static inline void hd_struct_put(struct hd_struct *part) |
| 700 | | −{ |
| 701 | | − percpu_ref_put(&part->ref); |
| 702 | | −} |
| 703 | | − |
| 704 | | −static inline void hd_struct_kill(struct hd_struct *part) |
| 705 | | −{ |
| 706 | | − percpu_ref_kill(&part->ref); |
| 707 | | −} |
| 708 | | − |
| 709 | | −static inline void hd_free_part(struct hd_struct *part) |
| 710 | | −{ |
| 711 | | − free_part_stats(part); |
| 712 | | − free_part_info(part); |
| 713 | | − percpu_ref_exit(&part->ref); |
| 714 | | −} |
| 715 | | − |
| 716 | | −/* |
| 717 | | − * Any access of part->nr_sects which is not protected by partition |
| 718 | | − * bd_mutex or gendisk bdev bd_mutex, should be done using this |
| 719 | | − * accessor function. |
| 720 | | − * |
| 721 | | − * Code written along the lines of i_size_read() and i_size_write(). |
| 722 | | − * CONFIG_PREEMPTION case optimizes the case of UP kernel with preemption |
| 723 | | − * on. |
| 724 | | − */ |
| 725 | | −static inline sector_t part_nr_sects_read(struct hd_struct *part) |
| 726 | | −{ |
| 727 | | −#if BITS_PER_LONG==32 && defined(CONFIG_SMP) |
| 728 | | − sector_t nr_sects; |
| 729 | | − unsigned seq; |
| 730 | | − do { |
| 731 | | − seq = read_seqcount_begin(&part->nr_sects_seq); |
| 732 | | − nr_sects = part->nr_sects; |
| 733 | | − } while (read_seqcount_retry(&part->nr_sects_seq, seq)); |
| 734 | | − return nr_sects; |
| 735 | | −#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) |
| 736 | | − sector_t nr_sects; |
| 737 | | − |
| 738 | | − preempt_disable(); |
| 739 | | − nr_sects = part->nr_sects; |
| 740 | | − preempt_enable(); |
| 741 | | − return nr_sects; |
| 742 | | −#else |
| 743 | | − return part->nr_sects; |
| 744 | | −#endif |
| 745 | | −} |
| 746 | | − |
| 747 | | −/* |
| 748 | | − * Should be called with mutex lock held (typically bd_mutex) of partition |
| 749 | | − * to provide mutual exlusion among writers otherwise seqcount might be |
| 750 | | − * left in wrong state leaving the readers spinning infinitely. |
| 751 | | − */ |
| 752 | | −static inline void part_nr_sects_write(struct hd_struct *part, sector_t size) |
| 753 | | −{ |
| 754 | | −#if BITS_PER_LONG==32 && defined(CONFIG_SMP) |
| 755 | | − write_seqcount_begin(&part->nr_sects_seq); |
| 756 | | − part->nr_sects = size; |
| 757 | | − write_seqcount_end(&part->nr_sects_seq); |
| 758 | | −#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) |
| 759 | | − preempt_disable(); |
| 760 | | − part->nr_sects = size; |
| 761 | | − preempt_enable(); |
| 762 | | −#else |
| 763 | | − part->nr_sects = size; |
| 764 | | −#endif |
| 765 | | −} |
| 766 | | − |
| 767 | | −#if defined(CONFIG_BLK_DEV_INTEGRITY) |
| 768 | | −extern void blk_integrity_add(struct gendisk *); |
| 769 | | −extern void blk_integrity_del(struct gendisk *); |
| 770 | | −#else /* CONFIG_BLK_DEV_INTEGRITY */ |
| 771 | | −static inline void blk_integrity_add(struct gendisk *disk) { } |
| 772 | | −static inline void blk_integrity_del(struct gendisk *disk) { } |
| 773 | | −#endif /* CONFIG_BLK_DEV_INTEGRITY */ |
| 774 | | − |
| 775 | 374 | #else /* CONFIG_BLOCK */ |
| 776 | 375 | |
| 777 | 376 | static inline void printk_all_partitions(void) { } |