aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-09-03 03:06:42 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:07 -0400
commitb5d0b9df0ba5d9a044f3a21e7544f53d90bd1465 (patch)
treed3347c1cfc59cf5d38c2c9adc2423f9d9b4cf818 /include/linux/genhd.h
parented9e1982347b36573cd622ee5f4e2a7ccd79b3fd (diff)
block: introduce partition 0
genhd and partition code handled disk and partitions separately. All information about the whole disk was in struct genhd and partitions in struct hd_struct. However, the whole disk (part0) and other partitions have a lot in common and the data structures end up having good number of common fields and thus separate code paths doing the same thing. Also, the partition array was indexed by partno - 1 which gets pretty confusing at times. This patch introduces partition 0 and makes the partition array indexed by partno. Following patches will unify the handling of disk and parts piece-by-piece. This patch also implements disk_partitionable() which tests whether a disk is partitionable. With coming dynamic partition array change, the most common usage of disk_max_parts() will be testing whether a disk is partitionable and the number of max partitions will become much less important. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r--include/linux/genhd.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e4e18c509ac5..9e866a2aee50 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -127,12 +127,13 @@ struct gendisk {
127 127
128 char disk_name[32]; /* name of major driver */ 128 char disk_name[32]; /* name of major driver */
129 129
130 /* Array of pointers to partitions indexed by partno - 1. 130 /* Array of pointers to partitions indexed by partno.
131 * Protected with matching bdev lock but stat and other 131 * Protected with matching bdev lock but stat and other
132 * non-critical accesses use RCU. Always access through 132 * non-critical accesses use RCU. Always access through
133 * helpers. 133 * helpers.
134 */ 134 */
135 struct hd_struct **__part; 135 struct hd_struct **__part;
136 struct hd_struct part0;
136 137
137 struct block_device_operations *fops; 138 struct block_device_operations *fops;
138 struct request_queue *queue; 139 struct request_queue *queue;
@@ -171,7 +172,12 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part)
171 172
172static inline int disk_max_parts(struct gendisk *disk) 173static inline int disk_max_parts(struct gendisk *disk)
173{ 174{
174 return disk->minors + disk->ext_minors - 1; 175 return disk->minors + disk->ext_minors;
176}
177
178static inline bool disk_partitionable(struct gendisk *disk)
179{
180 return disk_max_parts(disk) > 1;
175} 181}
176 182
177static inline dev_t disk_devt(struct gendisk *disk) 183static inline dev_t disk_devt(struct gendisk *disk)
@@ -197,6 +203,7 @@ static inline void disk_put_part(struct hd_struct *part)
197 */ 203 */
198#define DISK_PITER_REVERSE (1 << 0) /* iterate in the reverse direction */ 204#define DISK_PITER_REVERSE (1 << 0) /* iterate in the reverse direction */
199#define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */ 205#define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */
206#define DISK_PITER_INCL_PART0 (1 << 2) /* include partition 0 */
200 207
201struct disk_part_iter { 208struct disk_part_iter {
202 struct gendisk *disk; 209 struct gendisk *disk;