diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-10 13:52:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-10 13:52:45 -0400 |
commit | e26feff647ef34423b048b940540a0059001ddb0 (patch) | |
tree | acafe68602ee2f6f1a438c113073ffcc0040e949 /include | |
parent | d403a6484f0341bf0624d17ece46f24f741b6a92 (diff) | |
parent | b911e473d24633c19414b54b82b9ff0b1a2419d7 (diff) |
Merge branch 'for-2.6.28' of git://git.kernel.dk/linux-2.6-block
* 'for-2.6.28' of git://git.kernel.dk/linux-2.6-block: (132 commits)
doc/cdrom: Trvial documentation error, file not present
block_dev: fix kernel-doc in new functions
block: add some comments around the bio read-write flags
block: mark bio_split_pool static
block: Find bio sector offset given idx and offset
block: gendisk integrity wrapper
block: Switch blk_integrity_compare from bdev to gendisk
block: Fix double put in blk_integrity_unregister
block: Introduce integrity data ownership flag
block: revert part of d7533ad0e132f92e75c1b2eb7c26387b25a583c1
bio.h: Remove unused conditional code
block: remove end_{queued|dequeued}_request()
block: change elevator to use __blk_end_request()
gdrom: change to use __blk_end_request()
memstick: change to use __blk_end_request()
virtio_blk: change to use __blk_end_request()
blktrace: use BLKTRACE_BDEV_SIZE as the name size for setup structure
block: add lld busy state exporting interface
block: Fix blk_start_queueing() to not kick a stopped queue
include blktrace_api.h in headers_install
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/Kbuild | 1 | ||||
-rw-r--r-- | include/linux/ata.h | 6 | ||||
-rw-r--r-- | include/linux/bio.h | 108 | ||||
-rw-r--r-- | include/linux/blkdev.h | 151 | ||||
-rw-r--r-- | include/linux/blktrace_api.h | 62 | ||||
-rw-r--r-- | include/linux/device.h | 14 | ||||
-rw-r--r-- | include/linux/elevator.h | 9 | ||||
-rw-r--r-- | include/linux/fd.h | 8 | ||||
-rw-r--r-- | include/linux/fs.h | 9 | ||||
-rw-r--r-- | include/linux/genhd.h | 363 | ||||
-rw-r--r-- | include/linux/klist.h | 3 | ||||
-rw-r--r-- | include/linux/major.h | 2 | ||||
-rw-r--r-- | include/linux/mtd/blktrans.h | 2 | ||||
-rw-r--r-- | include/scsi/scsi_cmnd.h | 3 | ||||
-rw-r--r-- | include/scsi/scsi_host.h | 9 | ||||
-rw-r--r-- | include/scsi/scsi_transport.h | 3 |
16 files changed, 415 insertions, 338 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index b68ec09399be..31474e89c59a 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild | |||
@@ -180,6 +180,7 @@ unifdef-y += audit.h | |||
180 | unifdef-y += auto_fs.h | 180 | unifdef-y += auto_fs.h |
181 | unifdef-y += auxvec.h | 181 | unifdef-y += auxvec.h |
182 | unifdef-y += binfmts.h | 182 | unifdef-y += binfmts.h |
183 | unifdef-y += blktrace_api.h | ||
183 | unifdef-y += capability.h | 184 | unifdef-y += capability.h |
184 | unifdef-y += capi.h | 185 | unifdef-y += capi.h |
185 | unifdef-y += cciss_ioctl.h | 186 | unifdef-y += cciss_ioctl.h |
diff --git a/include/linux/ata.h b/include/linux/ata.h index a26ebd25bac1..be00973d1a8c 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -88,6 +88,7 @@ enum { | |||
88 | ATA_ID_DLF = 128, | 88 | ATA_ID_DLF = 128, |
89 | ATA_ID_CSFO = 129, | 89 | ATA_ID_CSFO = 129, |
90 | ATA_ID_CFA_POWER = 160, | 90 | ATA_ID_CFA_POWER = 160, |
91 | ATA_ID_ROT_SPEED = 217, | ||
91 | ATA_ID_PIO4 = (1 << 1), | 92 | ATA_ID_PIO4 = (1 << 1), |
92 | 93 | ||
93 | ATA_ID_SERNO_LEN = 20, | 94 | ATA_ID_SERNO_LEN = 20, |
@@ -700,6 +701,11 @@ static inline int ata_id_is_cfa(const u16 *id) | |||
700 | return 0; | 701 | return 0; |
701 | } | 702 | } |
702 | 703 | ||
704 | static inline int ata_id_is_ssd(const u16 *id) | ||
705 | { | ||
706 | return id[ATA_ID_ROT_SPEED] == 0x01; | ||
707 | } | ||
708 | |||
703 | static inline int ata_drive_40wire(const u16 *dev_id) | 709 | static inline int ata_drive_40wire(const u16 *dev_id) |
704 | { | 710 | { |
705 | if (ata_id_is_sata(dev_id)) | 711 | if (ata_id_is_sata(dev_id)) |
diff --git a/include/linux/bio.h b/include/linux/bio.h index 0933a14e6414..ff5b4cf9e2da 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -26,21 +26,8 @@ | |||
26 | 26 | ||
27 | #ifdef CONFIG_BLOCK | 27 | #ifdef CONFIG_BLOCK |
28 | 28 | ||
29 | /* Platforms may set this to teach the BIO layer about IOMMU hardware. */ | ||
30 | #include <asm/io.h> | 29 | #include <asm/io.h> |
31 | 30 | ||
32 | #if defined(BIO_VMERGE_MAX_SIZE) && defined(BIO_VMERGE_BOUNDARY) | ||
33 | #define BIOVEC_VIRT_START_SIZE(x) (bvec_to_phys(x) & (BIO_VMERGE_BOUNDARY - 1)) | ||
34 | #define BIOVEC_VIRT_OVERSIZE(x) ((x) > BIO_VMERGE_MAX_SIZE) | ||
35 | #else | ||
36 | #define BIOVEC_VIRT_START_SIZE(x) 0 | ||
37 | #define BIOVEC_VIRT_OVERSIZE(x) 0 | ||
38 | #endif | ||
39 | |||
40 | #ifndef BIO_VMERGE_BOUNDARY | ||
41 | #define BIO_VMERGE_BOUNDARY 0 | ||
42 | #endif | ||
43 | |||
44 | #define BIO_DEBUG | 31 | #define BIO_DEBUG |
45 | 32 | ||
46 | #ifdef BIO_DEBUG | 33 | #ifdef BIO_DEBUG |
@@ -88,25 +75,14 @@ struct bio { | |||
88 | /* Number of segments in this BIO after | 75 | /* Number of segments in this BIO after |
89 | * physical address coalescing is performed. | 76 | * physical address coalescing is performed. |
90 | */ | 77 | */ |
91 | unsigned short bi_phys_segments; | 78 | unsigned int bi_phys_segments; |
92 | |||
93 | /* Number of segments after physical and DMA remapping | ||
94 | * hardware coalescing is performed. | ||
95 | */ | ||
96 | unsigned short bi_hw_segments; | ||
97 | 79 | ||
98 | unsigned int bi_size; /* residual I/O count */ | 80 | unsigned int bi_size; /* residual I/O count */ |
99 | 81 | ||
100 | /* | ||
101 | * To keep track of the max hw size, we account for the | ||
102 | * sizes of the first and last virtually mergeable segments | ||
103 | * in this bio | ||
104 | */ | ||
105 | unsigned int bi_hw_front_size; | ||
106 | unsigned int bi_hw_back_size; | ||
107 | |||
108 | unsigned int bi_max_vecs; /* max bvl_vecs we can hold */ | 82 | unsigned int bi_max_vecs; /* max bvl_vecs we can hold */ |
109 | 83 | ||
84 | unsigned int bi_comp_cpu; /* completion CPU */ | ||
85 | |||
110 | struct bio_vec *bi_io_vec; /* the actual vec list */ | 86 | struct bio_vec *bi_io_vec; /* the actual vec list */ |
111 | 87 | ||
112 | bio_end_io_t *bi_end_io; | 88 | bio_end_io_t *bi_end_io; |
@@ -126,11 +102,14 @@ struct bio { | |||
126 | #define BIO_UPTODATE 0 /* ok after I/O completion */ | 102 | #define BIO_UPTODATE 0 /* ok after I/O completion */ |
127 | #define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ | 103 | #define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ |
128 | #define BIO_EOF 2 /* out-out-bounds error */ | 104 | #define BIO_EOF 2 /* out-out-bounds error */ |
129 | #define BIO_SEG_VALID 3 /* nr_hw_seg valid */ | 105 | #define BIO_SEG_VALID 3 /* bi_phys_segments valid */ |
130 | #define BIO_CLONED 4 /* doesn't own data */ | 106 | #define BIO_CLONED 4 /* doesn't own data */ |
131 | #define BIO_BOUNCED 5 /* bio is a bounce bio */ | 107 | #define BIO_BOUNCED 5 /* bio is a bounce bio */ |
132 | #define BIO_USER_MAPPED 6 /* contains user pages */ | 108 | #define BIO_USER_MAPPED 6 /* contains user pages */ |
133 | #define BIO_EOPNOTSUPP 7 /* not supported */ | 109 | #define BIO_EOPNOTSUPP 7 /* not supported */ |
110 | #define BIO_CPU_AFFINE 8 /* complete bio on same CPU as submitted */ | ||
111 | #define BIO_NULL_MAPPED 9 /* contains invalid user pages */ | ||
112 | #define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */ | ||
134 | #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) | 113 | #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) |
135 | 114 | ||
136 | /* | 115 | /* |
@@ -144,18 +123,31 @@ struct bio { | |||
144 | /* | 123 | /* |
145 | * bio bi_rw flags | 124 | * bio bi_rw flags |
146 | * | 125 | * |
147 | * bit 0 -- read (not set) or write (set) | 126 | * bit 0 -- data direction |
127 | * If not set, bio is a read from device. If set, it's a write to device. | ||
148 | * bit 1 -- rw-ahead when set | 128 | * bit 1 -- rw-ahead when set |
149 | * bit 2 -- barrier | 129 | * bit 2 -- barrier |
130 | * Insert a serialization point in the IO queue, forcing previously | ||
131 | * submitted IO to be completed before this oen is issued. | ||
150 | * bit 3 -- fail fast, don't want low level driver retries | 132 | * bit 3 -- fail fast, don't want low level driver retries |
151 | * bit 4 -- synchronous I/O hint: the block layer will unplug immediately | 133 | * bit 4 -- synchronous I/O hint: the block layer will unplug immediately |
134 | * Note that this does NOT indicate that the IO itself is sync, just | ||
135 | * that the block layer will not postpone issue of this IO by plugging. | ||
136 | * bit 5 -- metadata request | ||
137 | * Used for tracing to differentiate metadata and data IO. May also | ||
138 | * get some preferential treatment in the IO scheduler | ||
139 | * bit 6 -- discard sectors | ||
140 | * Informs the lower level device that this range of sectors is no longer | ||
141 | * used by the file system and may thus be freed by the device. Used | ||
142 | * for flash based storage. | ||
152 | */ | 143 | */ |
153 | #define BIO_RW 0 | 144 | #define BIO_RW 0 /* Must match RW in req flags (blkdev.h) */ |
154 | #define BIO_RW_AHEAD 1 | 145 | #define BIO_RW_AHEAD 1 /* Must match FAILFAST in req flags */ |
155 | #define BIO_RW_BARRIER 2 | 146 | #define BIO_RW_BARRIER 2 |
156 | #define BIO_RW_FAILFAST 3 | 147 | #define BIO_RW_FAILFAST 3 |
157 | #define BIO_RW_SYNC 4 | 148 | #define BIO_RW_SYNC 4 |
158 | #define BIO_RW_META 5 | 149 | #define BIO_RW_META 5 |
150 | #define BIO_RW_DISCARD 6 | ||
159 | 151 | ||
160 | /* | 152 | /* |
161 | * upper 16 bits of bi_rw define the io priority of this bio | 153 | * upper 16 bits of bi_rw define the io priority of this bio |
@@ -185,14 +177,15 @@ struct bio { | |||
185 | #define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) | 177 | #define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) |
186 | #define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) | 178 | #define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) |
187 | #define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) | 179 | #define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) |
188 | #define bio_empty_barrier(bio) (bio_barrier(bio) && !(bio)->bi_size) | 180 | #define bio_discard(bio) ((bio)->bi_rw & (1 << BIO_RW_DISCARD)) |
181 | #define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio) && !bio_discard(bio)) | ||
189 | 182 | ||
190 | static inline unsigned int bio_cur_sectors(struct bio *bio) | 183 | static inline unsigned int bio_cur_sectors(struct bio *bio) |
191 | { | 184 | { |
192 | if (bio->bi_vcnt) | 185 | if (bio->bi_vcnt) |
193 | return bio_iovec(bio)->bv_len >> 9; | 186 | return bio_iovec(bio)->bv_len >> 9; |
194 | 187 | else /* dataless requests such as discard */ | |
195 | return 0; | 188 | return bio->bi_size >> 9; |
196 | } | 189 | } |
197 | 190 | ||
198 | static inline void *bio_data(struct bio *bio) | 191 | static inline void *bio_data(struct bio *bio) |
@@ -236,8 +229,6 @@ static inline void *bio_data(struct bio *bio) | |||
236 | ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) | 229 | ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) |
237 | #endif | 230 | #endif |
238 | 231 | ||
239 | #define BIOVEC_VIRT_MERGEABLE(vec1, vec2) \ | ||
240 | ((((bvec_to_phys((vec1)) + (vec1)->bv_len) | bvec_to_phys((vec2))) & (BIO_VMERGE_BOUNDARY - 1)) == 0) | ||
241 | #define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \ | 232 | #define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \ |
242 | (((addr1) | (mask)) == (((addr2) - 1) | (mask))) | 233 | (((addr1) | (mask)) == (((addr2) - 1) | (mask))) |
243 | #define BIOVEC_SEG_BOUNDARY(q, b1, b2) \ | 234 | #define BIOVEC_SEG_BOUNDARY(q, b1, b2) \ |
@@ -319,15 +310,14 @@ struct bio_pair { | |||
319 | atomic_t cnt; | 310 | atomic_t cnt; |
320 | int error; | 311 | int error; |
321 | }; | 312 | }; |
322 | extern struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, | 313 | extern struct bio_pair *bio_split(struct bio *bi, int first_sectors); |
323 | int first_sectors); | ||
324 | extern mempool_t *bio_split_pool; | ||
325 | extern void bio_pair_release(struct bio_pair *dbio); | 314 | extern void bio_pair_release(struct bio_pair *dbio); |
326 | 315 | ||
327 | extern struct bio_set *bioset_create(int, int); | 316 | extern struct bio_set *bioset_create(int, int); |
328 | extern void bioset_free(struct bio_set *); | 317 | extern void bioset_free(struct bio_set *); |
329 | 318 | ||
330 | extern struct bio *bio_alloc(gfp_t, int); | 319 | extern struct bio *bio_alloc(gfp_t, int); |
320 | extern struct bio *bio_kmalloc(gfp_t, int); | ||
331 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); | 321 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); |
332 | extern void bio_put(struct bio *); | 322 | extern void bio_put(struct bio *); |
333 | extern void bio_free(struct bio *, struct bio_set *); | 323 | extern void bio_free(struct bio *, struct bio_set *); |
@@ -335,7 +325,6 @@ extern void bio_free(struct bio *, struct bio_set *); | |||
335 | extern void bio_endio(struct bio *, int); | 325 | extern void bio_endio(struct bio *, int); |
336 | struct request_queue; | 326 | struct request_queue; |
337 | extern int bio_phys_segments(struct request_queue *, struct bio *); | 327 | extern int bio_phys_segments(struct request_queue *, struct bio *); |
338 | extern int bio_hw_segments(struct request_queue *, struct bio *); | ||
339 | 328 | ||
340 | extern void __bio_clone(struct bio *, struct bio *); | 329 | extern void __bio_clone(struct bio *, struct bio *); |
341 | extern struct bio *bio_clone(struct bio *, gfp_t); | 330 | extern struct bio *bio_clone(struct bio *, gfp_t); |
@@ -346,12 +335,14 @@ extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); | |||
346 | extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, | 335 | extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, |
347 | unsigned int, unsigned int); | 336 | unsigned int, unsigned int); |
348 | extern int bio_get_nr_vecs(struct block_device *); | 337 | extern int bio_get_nr_vecs(struct block_device *); |
338 | extern sector_t bio_sector_offset(struct bio *, unsigned short, unsigned int); | ||
349 | extern struct bio *bio_map_user(struct request_queue *, struct block_device *, | 339 | extern struct bio *bio_map_user(struct request_queue *, struct block_device *, |
350 | unsigned long, unsigned int, int); | 340 | unsigned long, unsigned int, int, gfp_t); |
351 | struct sg_iovec; | 341 | struct sg_iovec; |
342 | struct rq_map_data; | ||
352 | extern struct bio *bio_map_user_iov(struct request_queue *, | 343 | extern struct bio *bio_map_user_iov(struct request_queue *, |
353 | struct block_device *, | 344 | struct block_device *, |
354 | struct sg_iovec *, int, int); | 345 | struct sg_iovec *, int, int, gfp_t); |
355 | extern void bio_unmap_user(struct bio *); | 346 | extern void bio_unmap_user(struct bio *); |
356 | extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, | 347 | extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, |
357 | gfp_t); | 348 | gfp_t); |
@@ -359,15 +350,25 @@ extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int, | |||
359 | gfp_t, int); | 350 | gfp_t, int); |
360 | extern void bio_set_pages_dirty(struct bio *bio); | 351 | extern void bio_set_pages_dirty(struct bio *bio); |
361 | extern void bio_check_pages_dirty(struct bio *bio); | 352 | extern void bio_check_pages_dirty(struct bio *bio); |
362 | extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int); | 353 | extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *, |
363 | extern struct bio *bio_copy_user_iov(struct request_queue *, struct sg_iovec *, | 354 | unsigned long, unsigned int, int, gfp_t); |
364 | int, int); | 355 | extern struct bio *bio_copy_user_iov(struct request_queue *, |
356 | struct rq_map_data *, struct sg_iovec *, | ||
357 | int, int, gfp_t); | ||
365 | extern int bio_uncopy_user(struct bio *); | 358 | extern int bio_uncopy_user(struct bio *); |
366 | void zero_fill_bio(struct bio *bio); | 359 | void zero_fill_bio(struct bio *bio); |
367 | extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); | 360 | extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); |
368 | extern unsigned int bvec_nr_vecs(unsigned short idx); | 361 | extern unsigned int bvec_nr_vecs(unsigned short idx); |
369 | 362 | ||
370 | /* | 363 | /* |
364 | * Allow queuer to specify a completion CPU for this bio | ||
365 | */ | ||
366 | static inline void bio_set_completion_cpu(struct bio *bio, unsigned int cpu) | ||
367 | { | ||
368 | bio->bi_comp_cpu = cpu; | ||
369 | } | ||
370 | |||
371 | /* | ||
371 | * bio_set is used to allow other portions of the IO system to | 372 | * bio_set is used to allow other portions of the IO system to |
372 | * allocate their own private memory pools for bio and iovec structures. | 373 | * allocate their own private memory pools for bio and iovec structures. |
373 | * These memory pools in turn all allocate from the bio_slab | 374 | * These memory pools in turn all allocate from the bio_slab |
@@ -445,6 +446,14 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, | |||
445 | __bio_kmap_irq((bio), (bio)->bi_idx, (flags)) | 446 | __bio_kmap_irq((bio), (bio)->bi_idx, (flags)) |
446 | #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) | 447 | #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) |
447 | 448 | ||
449 | /* | ||
450 | * Check whether this bio carries any data or not. A NULL bio is allowed. | ||
451 | */ | ||
452 | static inline int bio_has_data(struct bio *bio) | ||
453 | { | ||
454 | return bio && bio->bi_io_vec != NULL; | ||
455 | } | ||
456 | |||
448 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | 457 | #if defined(CONFIG_BLK_DEV_INTEGRITY) |
449 | 458 | ||
450 | #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) | 459 | #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) |
@@ -458,14 +467,7 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, | |||
458 | #define bip_for_each_vec(bvl, bip, i) \ | 467 | #define bip_for_each_vec(bvl, bip, i) \ |
459 | __bip_for_each_vec(bvl, bip, i, (bip)->bip_idx) | 468 | __bip_for_each_vec(bvl, bip, i, (bip)->bip_idx) |
460 | 469 | ||
461 | static inline int bio_integrity(struct bio *bio) | 470 | #define bio_integrity(bio) (bio->bi_integrity != NULL) |
462 | { | ||
463 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
464 | return bio->bi_integrity != NULL; | ||
465 | #else | ||
466 | return 0; | ||
467 | #endif | ||
468 | } | ||
469 | 471 | ||
470 | extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *); | 472 | extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *); |
471 | extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); | 473 | extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 53ea933cf60b..a92d9e4ea96e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -16,7 +16,9 @@ | |||
16 | #include <linux/bio.h> | 16 | #include <linux/bio.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/stringify.h> | 18 | #include <linux/stringify.h> |
19 | #include <linux/gfp.h> | ||
19 | #include <linux/bsg.h> | 20 | #include <linux/bsg.h> |
21 | #include <linux/smp.h> | ||
20 | 22 | ||
21 | #include <asm/scatterlist.h> | 23 | #include <asm/scatterlist.h> |
22 | 24 | ||
@@ -54,7 +56,6 @@ enum rq_cmd_type_bits { | |||
54 | REQ_TYPE_PM_SUSPEND, /* suspend request */ | 56 | REQ_TYPE_PM_SUSPEND, /* suspend request */ |
55 | REQ_TYPE_PM_RESUME, /* resume request */ | 57 | REQ_TYPE_PM_RESUME, /* resume request */ |
56 | REQ_TYPE_PM_SHUTDOWN, /* shutdown request */ | 58 | REQ_TYPE_PM_SHUTDOWN, /* shutdown request */ |
57 | REQ_TYPE_FLUSH, /* flush request */ | ||
58 | REQ_TYPE_SPECIAL, /* driver defined type */ | 59 | REQ_TYPE_SPECIAL, /* driver defined type */ |
59 | REQ_TYPE_LINUX_BLOCK, /* generic block layer message */ | 60 | REQ_TYPE_LINUX_BLOCK, /* generic block layer message */ |
60 | /* | 61 | /* |
@@ -76,19 +77,18 @@ enum rq_cmd_type_bits { | |||
76 | * | 77 | * |
77 | */ | 78 | */ |
78 | enum { | 79 | enum { |
79 | /* | ||
80 | * just examples for now | ||
81 | */ | ||
82 | REQ_LB_OP_EJECT = 0x40, /* eject request */ | 80 | REQ_LB_OP_EJECT = 0x40, /* eject request */ |
83 | REQ_LB_OP_FLUSH = 0x41, /* flush device */ | 81 | REQ_LB_OP_FLUSH = 0x41, /* flush request */ |
82 | REQ_LB_OP_DISCARD = 0x42, /* discard sectors */ | ||
84 | }; | 83 | }; |
85 | 84 | ||
86 | /* | 85 | /* |
87 | * request type modified bits. first three bits match BIO_RW* bits, important | 86 | * request type modified bits. first two bits match BIO_RW* bits, important |
88 | */ | 87 | */ |
89 | enum rq_flag_bits { | 88 | enum rq_flag_bits { |
90 | __REQ_RW, /* not set, read. set, write */ | 89 | __REQ_RW, /* not set, read. set, write */ |
91 | __REQ_FAILFAST, /* no low level driver retries */ | 90 | __REQ_FAILFAST, /* no low level driver retries */ |
91 | __REQ_DISCARD, /* request to discard sectors */ | ||
92 | __REQ_SORTED, /* elevator knows about this request */ | 92 | __REQ_SORTED, /* elevator knows about this request */ |
93 | __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ | 93 | __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ |
94 | __REQ_HARDBARRIER, /* may not be passed by drive either */ | 94 | __REQ_HARDBARRIER, /* may not be passed by drive either */ |
@@ -111,6 +111,7 @@ enum rq_flag_bits { | |||
111 | }; | 111 | }; |
112 | 112 | ||
113 | #define REQ_RW (1 << __REQ_RW) | 113 | #define REQ_RW (1 << __REQ_RW) |
114 | #define REQ_DISCARD (1 << __REQ_DISCARD) | ||
114 | #define REQ_FAILFAST (1 << __REQ_FAILFAST) | 115 | #define REQ_FAILFAST (1 << __REQ_FAILFAST) |
115 | #define REQ_SORTED (1 << __REQ_SORTED) | 116 | #define REQ_SORTED (1 << __REQ_SORTED) |
116 | #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) | 117 | #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) |
@@ -140,12 +141,14 @@ enum rq_flag_bits { | |||
140 | */ | 141 | */ |
141 | struct request { | 142 | struct request { |
142 | struct list_head queuelist; | 143 | struct list_head queuelist; |
143 | struct list_head donelist; | 144 | struct call_single_data csd; |
145 | int cpu; | ||
144 | 146 | ||
145 | struct request_queue *q; | 147 | struct request_queue *q; |
146 | 148 | ||
147 | unsigned int cmd_flags; | 149 | unsigned int cmd_flags; |
148 | enum rq_cmd_type_bits cmd_type; | 150 | enum rq_cmd_type_bits cmd_type; |
151 | unsigned long atomic_flags; | ||
149 | 152 | ||
150 | /* Maintain bio traversal state for part by part I/O submission. | 153 | /* Maintain bio traversal state for part by part I/O submission. |
151 | * hard_* are block layer internals, no driver should touch them! | 154 | * hard_* are block layer internals, no driver should touch them! |
@@ -190,13 +193,6 @@ struct request { | |||
190 | */ | 193 | */ |
191 | unsigned short nr_phys_segments; | 194 | unsigned short nr_phys_segments; |
192 | 195 | ||
193 | /* Number of scatter-gather addr+len pairs after | ||
194 | * physical and DMA remapping hardware coalescing is performed. | ||
195 | * This is the number of scatter-gather entries the driver | ||
196 | * will actually have to deal with after DMA mapping is done. | ||
197 | */ | ||
198 | unsigned short nr_hw_segments; | ||
199 | |||
200 | unsigned short ioprio; | 196 | unsigned short ioprio; |
201 | 197 | ||
202 | void *special; | 198 | void *special; |
@@ -220,6 +216,8 @@ struct request { | |||
220 | void *data; | 216 | void *data; |
221 | void *sense; | 217 | void *sense; |
222 | 218 | ||
219 | unsigned long deadline; | ||
220 | struct list_head timeout_list; | ||
223 | unsigned int timeout; | 221 | unsigned int timeout; |
224 | int retries; | 222 | int retries; |
225 | 223 | ||
@@ -233,6 +231,11 @@ struct request { | |||
233 | struct request *next_rq; | 231 | struct request *next_rq; |
234 | }; | 232 | }; |
235 | 233 | ||
234 | static inline unsigned short req_get_ioprio(struct request *req) | ||
235 | { | ||
236 | return req->ioprio; | ||
237 | } | ||
238 | |||
236 | /* | 239 | /* |
237 | * State information carried for REQ_TYPE_PM_SUSPEND and REQ_TYPE_PM_RESUME | 240 | * State information carried for REQ_TYPE_PM_SUSPEND and REQ_TYPE_PM_RESUME |
238 | * requests. Some step values could eventually be made generic. | 241 | * requests. Some step values could eventually be made generic. |
@@ -252,6 +255,7 @@ typedef void (request_fn_proc) (struct request_queue *q); | |||
252 | typedef int (make_request_fn) (struct request_queue *q, struct bio *bio); | 255 | typedef int (make_request_fn) (struct request_queue *q, struct bio *bio); |
253 | typedef int (prep_rq_fn) (struct request_queue *, struct request *); | 256 | typedef int (prep_rq_fn) (struct request_queue *, struct request *); |
254 | typedef void (unplug_fn) (struct request_queue *); | 257 | typedef void (unplug_fn) (struct request_queue *); |
258 | typedef int (prepare_discard_fn) (struct request_queue *, struct request *); | ||
255 | 259 | ||
256 | struct bio_vec; | 260 | struct bio_vec; |
257 | struct bvec_merge_data { | 261 | struct bvec_merge_data { |
@@ -265,6 +269,15 @@ typedef int (merge_bvec_fn) (struct request_queue *, struct bvec_merge_data *, | |||
265 | typedef void (prepare_flush_fn) (struct request_queue *, struct request *); | 269 | typedef void (prepare_flush_fn) (struct request_queue *, struct request *); |
266 | typedef void (softirq_done_fn)(struct request *); | 270 | typedef void (softirq_done_fn)(struct request *); |
267 | typedef int (dma_drain_needed_fn)(struct request *); | 271 | typedef int (dma_drain_needed_fn)(struct request *); |
272 | typedef int (lld_busy_fn) (struct request_queue *q); | ||
273 | |||
274 | enum blk_eh_timer_return { | ||
275 | BLK_EH_NOT_HANDLED, | ||
276 | BLK_EH_HANDLED, | ||
277 | BLK_EH_RESET_TIMER, | ||
278 | }; | ||
279 | |||
280 | typedef enum blk_eh_timer_return (rq_timed_out_fn)(struct request *); | ||
268 | 281 | ||
269 | enum blk_queue_state { | 282 | enum blk_queue_state { |
270 | Queue_down, | 283 | Queue_down, |
@@ -307,10 +320,13 @@ struct request_queue | |||
307 | make_request_fn *make_request_fn; | 320 | make_request_fn *make_request_fn; |
308 | prep_rq_fn *prep_rq_fn; | 321 | prep_rq_fn *prep_rq_fn; |
309 | unplug_fn *unplug_fn; | 322 | unplug_fn *unplug_fn; |
323 | prepare_discard_fn *prepare_discard_fn; | ||
310 | merge_bvec_fn *merge_bvec_fn; | 324 | merge_bvec_fn *merge_bvec_fn; |
311 | prepare_flush_fn *prepare_flush_fn; | 325 | prepare_flush_fn *prepare_flush_fn; |
312 | softirq_done_fn *softirq_done_fn; | 326 | softirq_done_fn *softirq_done_fn; |
327 | rq_timed_out_fn *rq_timed_out_fn; | ||
313 | dma_drain_needed_fn *dma_drain_needed; | 328 | dma_drain_needed_fn *dma_drain_needed; |
329 | lld_busy_fn *lld_busy_fn; | ||
314 | 330 | ||
315 | /* | 331 | /* |
316 | * Dispatch queue sorting | 332 | * Dispatch queue sorting |
@@ -385,6 +401,10 @@ struct request_queue | |||
385 | unsigned int nr_sorted; | 401 | unsigned int nr_sorted; |
386 | unsigned int in_flight; | 402 | unsigned int in_flight; |
387 | 403 | ||
404 | unsigned int rq_timeout; | ||
405 | struct timer_list timeout; | ||
406 | struct list_head timeout_list; | ||
407 | |||
388 | /* | 408 | /* |
389 | * sg stuff | 409 | * sg stuff |
390 | */ | 410 | */ |
@@ -421,6 +441,10 @@ struct request_queue | |||
421 | #define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ | 441 | #define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ |
422 | #define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ | 442 | #define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ |
423 | #define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */ | 443 | #define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */ |
444 | #define QUEUE_FLAG_SAME_COMP 11 /* force complete on same CPU */ | ||
445 | #define QUEUE_FLAG_FAIL_IO 12 /* fake timeout */ | ||
446 | #define QUEUE_FLAG_STACKABLE 13 /* supports request stacking */ | ||
447 | #define QUEUE_FLAG_NONROT 14 /* non-rotational device (SSD) */ | ||
424 | 448 | ||
425 | static inline int queue_is_locked(struct request_queue *q) | 449 | static inline int queue_is_locked(struct request_queue *q) |
426 | { | 450 | { |
@@ -526,7 +550,10 @@ enum { | |||
526 | #define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) | 550 | #define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) |
527 | #define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) | 551 | #define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) |
528 | #define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags) | 552 | #define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags) |
553 | #define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags) | ||
529 | #define blk_queue_flushing(q) ((q)->ordseq) | 554 | #define blk_queue_flushing(q) ((q)->ordseq) |
555 | #define blk_queue_stackable(q) \ | ||
556 | test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags) | ||
530 | 557 | ||
531 | #define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) | 558 | #define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) |
532 | #define blk_pc_request(rq) ((rq)->cmd_type == REQ_TYPE_BLOCK_PC) | 559 | #define blk_pc_request(rq) ((rq)->cmd_type == REQ_TYPE_BLOCK_PC) |
@@ -536,16 +563,18 @@ enum { | |||
536 | #define blk_noretry_request(rq) ((rq)->cmd_flags & REQ_FAILFAST) | 563 | #define blk_noretry_request(rq) ((rq)->cmd_flags & REQ_FAILFAST) |
537 | #define blk_rq_started(rq) ((rq)->cmd_flags & REQ_STARTED) | 564 | #define blk_rq_started(rq) ((rq)->cmd_flags & REQ_STARTED) |
538 | 565 | ||
539 | #define blk_account_rq(rq) (blk_rq_started(rq) && blk_fs_request(rq)) | 566 | #define blk_account_rq(rq) (blk_rq_started(rq) && (blk_fs_request(rq) || blk_discard_rq(rq))) |
540 | 567 | ||
541 | #define blk_pm_suspend_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND) | 568 | #define blk_pm_suspend_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND) |
542 | #define blk_pm_resume_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_RESUME) | 569 | #define blk_pm_resume_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_RESUME) |
543 | #define blk_pm_request(rq) \ | 570 | #define blk_pm_request(rq) \ |
544 | (blk_pm_suspend_request(rq) || blk_pm_resume_request(rq)) | 571 | (blk_pm_suspend_request(rq) || blk_pm_resume_request(rq)) |
545 | 572 | ||
573 | #define blk_rq_cpu_valid(rq) ((rq)->cpu != -1) | ||
546 | #define blk_sorted_rq(rq) ((rq)->cmd_flags & REQ_SORTED) | 574 | #define blk_sorted_rq(rq) ((rq)->cmd_flags & REQ_SORTED) |
547 | #define blk_barrier_rq(rq) ((rq)->cmd_flags & REQ_HARDBARRIER) | 575 | #define blk_barrier_rq(rq) ((rq)->cmd_flags & REQ_HARDBARRIER) |
548 | #define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA) | 576 | #define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA) |
577 | #define blk_discard_rq(rq) ((rq)->cmd_flags & REQ_DISCARD) | ||
549 | #define blk_bidi_rq(rq) ((rq)->next_rq != NULL) | 578 | #define blk_bidi_rq(rq) ((rq)->next_rq != NULL) |
550 | #define blk_empty_barrier(rq) (blk_barrier_rq(rq) && blk_fs_request(rq) && !(rq)->hard_nr_sectors) | 579 | #define blk_empty_barrier(rq) (blk_barrier_rq(rq) && blk_fs_request(rq) && !(rq)->hard_nr_sectors) |
551 | /* rq->queuelist of dequeued request must be list_empty() */ | 580 | /* rq->queuelist of dequeued request must be list_empty() */ |
@@ -592,7 +621,8 @@ static inline void blk_clear_queue_full(struct request_queue *q, int rw) | |||
592 | #define RQ_NOMERGE_FLAGS \ | 621 | #define RQ_NOMERGE_FLAGS \ |
593 | (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER) | 622 | (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER) |
594 | #define rq_mergeable(rq) \ | 623 | #define rq_mergeable(rq) \ |
595 | (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && blk_fs_request((rq))) | 624 | (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && \ |
625 | (blk_discard_rq(rq) || blk_fs_request((rq)))) | ||
596 | 626 | ||
597 | /* | 627 | /* |
598 | * q->prep_rq_fn return values | 628 | * q->prep_rq_fn return values |
@@ -637,6 +667,12 @@ static inline void blk_queue_bounce(struct request_queue *q, struct bio **bio) | |||
637 | } | 667 | } |
638 | #endif /* CONFIG_MMU */ | 668 | #endif /* CONFIG_MMU */ |
639 | 669 | ||
670 | struct rq_map_data { | ||
671 | struct page **pages; | ||
672 | int page_order; | ||
673 | int nr_entries; | ||
674 | }; | ||
675 | |||
640 | struct req_iterator { | 676 | struct req_iterator { |
641 | int i; | 677 | int i; |
642 | struct bio *bio; | 678 | struct bio *bio; |
@@ -664,6 +700,10 @@ extern void __blk_put_request(struct request_queue *, struct request *); | |||
664 | extern struct request *blk_get_request(struct request_queue *, int, gfp_t); | 700 | extern struct request *blk_get_request(struct request_queue *, int, gfp_t); |
665 | extern void blk_insert_request(struct request_queue *, struct request *, int, void *); | 701 | extern void blk_insert_request(struct request_queue *, struct request *, int, void *); |
666 | extern void blk_requeue_request(struct request_queue *, struct request *); | 702 | extern void blk_requeue_request(struct request_queue *, struct request *); |
703 | extern int blk_rq_check_limits(struct request_queue *q, struct request *rq); | ||
704 | extern int blk_lld_busy(struct request_queue *q); | ||
705 | extern int blk_insert_cloned_request(struct request_queue *q, | ||
706 | struct request *rq); | ||
667 | extern void blk_plug_device(struct request_queue *); | 707 | extern void blk_plug_device(struct request_queue *); |
668 | extern void blk_plug_device_unlocked(struct request_queue *); | 708 | extern void blk_plug_device_unlocked(struct request_queue *); |
669 | extern int blk_remove_plug(struct request_queue *); | 709 | extern int blk_remove_plug(struct request_queue *); |
@@ -705,11 +745,14 @@ extern void __blk_stop_queue(struct request_queue *q); | |||
705 | extern void __blk_run_queue(struct request_queue *); | 745 | extern void __blk_run_queue(struct request_queue *); |
706 | extern void blk_run_queue(struct request_queue *); | 746 | extern void blk_run_queue(struct request_queue *); |
707 | extern void blk_start_queueing(struct request_queue *); | 747 | extern void blk_start_queueing(struct request_queue *); |
708 | extern int blk_rq_map_user(struct request_queue *, struct request *, void __user *, unsigned long); | 748 | extern int blk_rq_map_user(struct request_queue *, struct request *, |
749 | struct rq_map_data *, void __user *, unsigned long, | ||
750 | gfp_t); | ||
709 | extern int blk_rq_unmap_user(struct bio *); | 751 | extern int blk_rq_unmap_user(struct bio *); |
710 | extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t); | 752 | extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t); |
711 | extern int blk_rq_map_user_iov(struct request_queue *, struct request *, | 753 | extern int blk_rq_map_user_iov(struct request_queue *, struct request *, |
712 | struct sg_iovec *, int, unsigned int); | 754 | struct rq_map_data *, struct sg_iovec *, int, |
755 | unsigned int, gfp_t); | ||
713 | extern int blk_execute_rq(struct request_queue *, struct gendisk *, | 756 | extern int blk_execute_rq(struct request_queue *, struct gendisk *, |
714 | struct request *, int); | 757 | struct request *, int); |
715 | extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, | 758 | extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, |
@@ -750,12 +793,15 @@ extern int __blk_end_request(struct request *rq, int error, | |||
750 | extern int blk_end_bidi_request(struct request *rq, int error, | 793 | extern int blk_end_bidi_request(struct request *rq, int error, |
751 | unsigned int nr_bytes, unsigned int bidi_bytes); | 794 | unsigned int nr_bytes, unsigned int bidi_bytes); |
752 | extern void end_request(struct request *, int); | 795 | extern void end_request(struct request *, int); |
753 | extern void end_queued_request(struct request *, int); | ||
754 | extern void end_dequeued_request(struct request *, int); | ||
755 | extern int blk_end_request_callback(struct request *rq, int error, | 796 | extern int blk_end_request_callback(struct request *rq, int error, |
756 | unsigned int nr_bytes, | 797 | unsigned int nr_bytes, |
757 | int (drv_callback)(struct request *)); | 798 | int (drv_callback)(struct request *)); |
758 | extern void blk_complete_request(struct request *); | 799 | extern void blk_complete_request(struct request *); |
800 | extern void __blk_complete_request(struct request *); | ||
801 | extern void blk_abort_request(struct request *); | ||
802 | extern void blk_abort_queue(struct request_queue *); | ||
803 | extern void blk_update_request(struct request *rq, int error, | ||
804 | unsigned int nr_bytes); | ||
759 | 805 | ||
760 | /* | 806 | /* |
761 | * blk_end_request() takes bytes instead of sectors as a complete size. | 807 | * blk_end_request() takes bytes instead of sectors as a complete size. |
@@ -790,12 +836,16 @@ extern void blk_queue_update_dma_pad(struct request_queue *, unsigned int); | |||
790 | extern int blk_queue_dma_drain(struct request_queue *q, | 836 | extern int blk_queue_dma_drain(struct request_queue *q, |
791 | dma_drain_needed_fn *dma_drain_needed, | 837 | dma_drain_needed_fn *dma_drain_needed, |
792 | void *buf, unsigned int size); | 838 | void *buf, unsigned int size); |
839 | extern void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn); | ||
793 | extern void blk_queue_segment_boundary(struct request_queue *, unsigned long); | 840 | extern void blk_queue_segment_boundary(struct request_queue *, unsigned long); |
794 | extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn); | 841 | extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn); |
795 | extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *); | 842 | extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *); |
796 | extern void blk_queue_dma_alignment(struct request_queue *, int); | 843 | extern void blk_queue_dma_alignment(struct request_queue *, int); |
797 | extern void blk_queue_update_dma_alignment(struct request_queue *, int); | 844 | extern void blk_queue_update_dma_alignment(struct request_queue *, int); |
798 | extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *); | 845 | extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *); |
846 | extern void blk_queue_set_discard(struct request_queue *, prepare_discard_fn *); | ||
847 | extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *); | ||
848 | extern void blk_queue_rq_timeout(struct request_queue *, unsigned int); | ||
799 | extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); | 849 | extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); |
800 | extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *); | 850 | extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *); |
801 | extern int blk_do_ordered(struct request_queue *, struct request **); | 851 | extern int blk_do_ordered(struct request_queue *, struct request **); |
@@ -837,6 +887,16 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, | |||
837 | } | 887 | } |
838 | 888 | ||
839 | extern int blkdev_issue_flush(struct block_device *, sector_t *); | 889 | extern int blkdev_issue_flush(struct block_device *, sector_t *); |
890 | extern int blkdev_issue_discard(struct block_device *, | ||
891 | sector_t sector, sector_t nr_sects, gfp_t); | ||
892 | |||
893 | static inline int sb_issue_discard(struct super_block *sb, | ||
894 | sector_t block, sector_t nr_blocks) | ||
895 | { | ||
896 | block <<= (sb->s_blocksize_bits - 9); | ||
897 | nr_blocks <<= (sb->s_blocksize_bits - 9); | ||
898 | return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL); | ||
899 | } | ||
840 | 900 | ||
841 | /* | 901 | /* |
842 | * command filter functions | 902 | * command filter functions |
@@ -874,6 +934,13 @@ static inline int queue_dma_alignment(struct request_queue *q) | |||
874 | return q ? q->dma_alignment : 511; | 934 | return q ? q->dma_alignment : 511; |
875 | } | 935 | } |
876 | 936 | ||
937 | static inline int blk_rq_aligned(struct request_queue *q, void *addr, | ||
938 | unsigned int len) | ||
939 | { | ||
940 | unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask; | ||
941 | return !((unsigned long)addr & alignment) && !(len & alignment); | ||
942 | } | ||
943 | |||
877 | /* assumes size > 256 */ | 944 | /* assumes size > 256 */ |
878 | static inline unsigned int blksize_bits(unsigned int size) | 945 | static inline unsigned int blksize_bits(unsigned int size) |
879 | { | 946 | { |
@@ -900,7 +967,7 @@ static inline void put_dev_sector(Sector p) | |||
900 | } | 967 | } |
901 | 968 | ||
902 | struct work_struct; | 969 | struct work_struct; |
903 | int kblockd_schedule_work(struct work_struct *work); | 970 | int kblockd_schedule_work(struct request_queue *q, struct work_struct *work); |
904 | void kblockd_flush_work(struct work_struct *work); | 971 | void kblockd_flush_work(struct work_struct *work); |
905 | 972 | ||
906 | #define MODULE_ALIAS_BLOCKDEV(major,minor) \ | 973 | #define MODULE_ALIAS_BLOCKDEV(major,minor) \ |
@@ -945,49 +1012,19 @@ struct blk_integrity { | |||
945 | 1012 | ||
946 | extern int blk_integrity_register(struct gendisk *, struct blk_integrity *); | 1013 | extern int blk_integrity_register(struct gendisk *, struct blk_integrity *); |
947 | extern void blk_integrity_unregister(struct gendisk *); | 1014 | extern void blk_integrity_unregister(struct gendisk *); |
948 | extern int blk_integrity_compare(struct block_device *, struct block_device *); | 1015 | extern int blk_integrity_compare(struct gendisk *, struct gendisk *); |
949 | extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); | 1016 | extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); |
950 | extern int blk_rq_count_integrity_sg(struct request *); | 1017 | extern int blk_rq_count_integrity_sg(struct request *); |
951 | 1018 | ||
952 | static inline unsigned short blk_integrity_tuple_size(struct blk_integrity *bi) | 1019 | static inline |
953 | { | 1020 | struct blk_integrity *bdev_get_integrity(struct block_device *bdev) |
954 | if (bi) | ||
955 | return bi->tuple_size; | ||
956 | |||
957 | return 0; | ||
958 | } | ||
959 | |||
960 | static inline struct blk_integrity *bdev_get_integrity(struct block_device *bdev) | ||
961 | { | 1021 | { |
962 | return bdev->bd_disk->integrity; | 1022 | return bdev->bd_disk->integrity; |
963 | } | 1023 | } |
964 | 1024 | ||
965 | static inline unsigned int bdev_get_tag_size(struct block_device *bdev) | 1025 | static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk) |
966 | { | 1026 | { |
967 | struct blk_integrity *bi = bdev_get_integrity(bdev); | 1027 | return disk->integrity; |
968 | |||
969 | if (bi) | ||
970 | return bi->tag_size; | ||
971 | |||
972 | return 0; | ||
973 | } | ||
974 | |||
975 | static inline int bdev_integrity_enabled(struct block_device *bdev, int rw) | ||
976 | { | ||
977 | struct blk_integrity *bi = bdev_get_integrity(bdev); | ||
978 | |||
979 | if (bi == NULL) | ||
980 | return 0; | ||
981 | |||
982 | if (rw == READ && bi->verify_fn != NULL && | ||
983 | (bi->flags & INTEGRITY_FLAG_READ)) | ||
984 | return 1; | ||
985 | |||
986 | if (rw == WRITE && bi->generate_fn != NULL && | ||
987 | (bi->flags & INTEGRITY_FLAG_WRITE)) | ||
988 | return 1; | ||
989 | |||
990 | return 0; | ||
991 | } | 1028 | } |
992 | 1029 | ||
993 | static inline int blk_integrity_rq(struct request *rq) | 1030 | static inline int blk_integrity_rq(struct request *rq) |
@@ -1004,7 +1041,7 @@ static inline int blk_integrity_rq(struct request *rq) | |||
1004 | #define blk_rq_count_integrity_sg(a) (0) | 1041 | #define blk_rq_count_integrity_sg(a) (0) |
1005 | #define blk_rq_map_integrity_sg(a, b) (0) | 1042 | #define blk_rq_map_integrity_sg(a, b) (0) |
1006 | #define bdev_get_integrity(a) (0) | 1043 | #define bdev_get_integrity(a) (0) |
1007 | #define bdev_get_tag_size(a) (0) | 1044 | #define blk_get_integrity(a) (0) |
1008 | #define blk_integrity_compare(a, b) (0) | 1045 | #define blk_integrity_compare(a, b) (0) |
1009 | #define blk_integrity_register(a, b) (0) | 1046 | #define blk_integrity_register(a, b) (0) |
1010 | #define blk_integrity_unregister(a) do { } while (0); | 1047 | #define blk_integrity_unregister(a) do { } while (0); |
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index d084b8d227a5..3a31eb506164 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h | |||
@@ -1,8 +1,10 @@ | |||
1 | #ifndef BLKTRACE_H | 1 | #ifndef BLKTRACE_H |
2 | #define BLKTRACE_H | 2 | #define BLKTRACE_H |
3 | 3 | ||
4 | #ifdef __KERNEL__ | ||
4 | #include <linux/blkdev.h> | 5 | #include <linux/blkdev.h> |
5 | #include <linux/relay.h> | 6 | #include <linux/relay.h> |
7 | #endif | ||
6 | 8 | ||
7 | /* | 9 | /* |
8 | * Trace categories | 10 | * Trace categories |
@@ -21,6 +23,7 @@ enum blktrace_cat { | |||
21 | BLK_TC_NOTIFY = 1 << 10, /* special message */ | 23 | BLK_TC_NOTIFY = 1 << 10, /* special message */ |
22 | BLK_TC_AHEAD = 1 << 11, /* readahead */ | 24 | BLK_TC_AHEAD = 1 << 11, /* readahead */ |
23 | BLK_TC_META = 1 << 12, /* metadata */ | 25 | BLK_TC_META = 1 << 12, /* metadata */ |
26 | BLK_TC_DISCARD = 1 << 13, /* discard requests */ | ||
24 | 27 | ||
25 | BLK_TC_END = 1 << 15, /* only 16-bits, reminder */ | 28 | BLK_TC_END = 1 << 15, /* only 16-bits, reminder */ |
26 | }; | 29 | }; |
@@ -47,6 +50,7 @@ enum blktrace_act { | |||
47 | __BLK_TA_SPLIT, /* bio was split */ | 50 | __BLK_TA_SPLIT, /* bio was split */ |
48 | __BLK_TA_BOUNCE, /* bio was bounced */ | 51 | __BLK_TA_BOUNCE, /* bio was bounced */ |
49 | __BLK_TA_REMAP, /* bio was remapped */ | 52 | __BLK_TA_REMAP, /* bio was remapped */ |
53 | __BLK_TA_ABORT, /* request aborted */ | ||
50 | }; | 54 | }; |
51 | 55 | ||
52 | /* | 56 | /* |
@@ -77,6 +81,7 @@ enum blktrace_notify { | |||
77 | #define BLK_TA_SPLIT (__BLK_TA_SPLIT) | 81 | #define BLK_TA_SPLIT (__BLK_TA_SPLIT) |
78 | #define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) | 82 | #define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) |
79 | #define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) | 83 | #define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) |
84 | #define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE)) | ||
80 | 85 | ||
81 | #define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY)) | 86 | #define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY)) |
82 | #define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY)) | 87 | #define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY)) |
@@ -89,17 +94,17 @@ enum blktrace_notify { | |||
89 | * The trace itself | 94 | * The trace itself |
90 | */ | 95 | */ |
91 | struct blk_io_trace { | 96 | struct blk_io_trace { |
92 | u32 magic; /* MAGIC << 8 | version */ | 97 | __u32 magic; /* MAGIC << 8 | version */ |
93 | u32 sequence; /* event number */ | 98 | __u32 sequence; /* event number */ |
94 | u64 time; /* in microseconds */ | 99 | __u64 time; /* in microseconds */ |
95 | u64 sector; /* disk offset */ | 100 | __u64 sector; /* disk offset */ |
96 | u32 bytes; /* transfer length */ | 101 | __u32 bytes; /* transfer length */ |
97 | u32 action; /* what happened */ | 102 | __u32 action; /* what happened */ |
98 | u32 pid; /* who did it */ | 103 | __u32 pid; /* who did it */ |
99 | u32 device; /* device number */ | 104 | __u32 device; /* device number */ |
100 | u32 cpu; /* on what cpu did it happen */ | 105 | __u32 cpu; /* on what cpu did it happen */ |
101 | u16 error; /* completion error */ | 106 | __u16 error; /* completion error */ |
102 | u16 pdu_len; /* length of data after this trace */ | 107 | __u16 pdu_len; /* length of data after this trace */ |
103 | }; | 108 | }; |
104 | 109 | ||
105 | /* | 110 | /* |
@@ -117,6 +122,23 @@ enum { | |||
117 | Blktrace_stopped, | 122 | Blktrace_stopped, |
118 | }; | 123 | }; |
119 | 124 | ||
125 | #define BLKTRACE_BDEV_SIZE 32 | ||
126 | |||
127 | /* | ||
128 | * User setup structure passed with BLKTRACESTART | ||
129 | */ | ||
130 | struct blk_user_trace_setup { | ||
131 | char name[BLKTRACE_BDEV_SIZE]; /* output */ | ||
132 | __u16 act_mask; /* input */ | ||
133 | __u32 buf_size; /* input */ | ||
134 | __u32 buf_nr; /* input */ | ||
135 | __u64 start_lba; | ||
136 | __u64 end_lba; | ||
137 | __u32 pid; | ||
138 | }; | ||
139 | |||
140 | #ifdef __KERNEL__ | ||
141 | #if defined(CONFIG_BLK_DEV_IO_TRACE) | ||
120 | struct blk_trace { | 142 | struct blk_trace { |
121 | int trace_state; | 143 | int trace_state; |
122 | struct rchan *rchan; | 144 | struct rchan *rchan; |
@@ -133,21 +155,6 @@ struct blk_trace { | |||
133 | atomic_t dropped; | 155 | atomic_t dropped; |
134 | }; | 156 | }; |
135 | 157 | ||
136 | /* | ||
137 | * User setup structure passed with BLKTRACESTART | ||
138 | */ | ||
139 | struct blk_user_trace_setup { | ||
140 | char name[BDEVNAME_SIZE]; /* output */ | ||
141 | u16 act_mask; /* input */ | ||
142 | u32 buf_size; /* input */ | ||
143 | u32 buf_nr; /* input */ | ||
144 | u64 start_lba; | ||
145 | u64 end_lba; | ||
146 | u32 pid; | ||
147 | }; | ||
148 | |||
149 | #ifdef __KERNEL__ | ||
150 | #if defined(CONFIG_BLK_DEV_IO_TRACE) | ||
151 | extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *); | 158 | extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *); |
152 | extern void blk_trace_shutdown(struct request_queue *); | 159 | extern void blk_trace_shutdown(struct request_queue *); |
153 | extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *); | 160 | extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *); |
@@ -195,6 +202,9 @@ static inline void blk_add_trace_rq(struct request_queue *q, struct request *rq, | |||
195 | if (likely(!bt)) | 202 | if (likely(!bt)) |
196 | return; | 203 | return; |
197 | 204 | ||
205 | if (blk_discard_rq(rq)) | ||
206 | rw |= (1 << BIO_RW_DISCARD); | ||
207 | |||
198 | if (blk_pc_request(rq)) { | 208 | if (blk_pc_request(rq)) { |
199 | what |= BLK_TC_ACT(BLK_TC_PC); | 209 | what |= BLK_TC_ACT(BLK_TC_PC); |
200 | __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, sizeof(rq->cmd), rq->cmd); | 210 | __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, sizeof(rq->cmd), rq->cmd); |
diff --git a/include/linux/device.h b/include/linux/device.h index 4d8372d135df..246937c9cbc7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -199,6 +199,11 @@ struct class { | |||
199 | struct class_private *p; | 199 | struct class_private *p; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | struct class_dev_iter { | ||
203 | struct klist_iter ki; | ||
204 | const struct device_type *type; | ||
205 | }; | ||
206 | |||
202 | extern struct kobject *sysfs_dev_block_kobj; | 207 | extern struct kobject *sysfs_dev_block_kobj; |
203 | extern struct kobject *sysfs_dev_char_kobj; | 208 | extern struct kobject *sysfs_dev_char_kobj; |
204 | extern int __must_check __class_register(struct class *class, | 209 | extern int __must_check __class_register(struct class *class, |
@@ -213,6 +218,13 @@ extern void class_unregister(struct class *class); | |||
213 | __class_register(class, &__key); \ | 218 | __class_register(class, &__key); \ |
214 | }) | 219 | }) |
215 | 220 | ||
221 | extern void class_dev_iter_init(struct class_dev_iter *iter, | ||
222 | struct class *class, | ||
223 | struct device *start, | ||
224 | const struct device_type *type); | ||
225 | extern struct device *class_dev_iter_next(struct class_dev_iter *iter); | ||
226 | extern void class_dev_iter_exit(struct class_dev_iter *iter); | ||
227 | |||
216 | extern int class_for_each_device(struct class *class, struct device *start, | 228 | extern int class_for_each_device(struct class *class, struct device *start, |
217 | void *data, | 229 | void *data, |
218 | int (*fn)(struct device *dev, void *data)); | 230 | int (*fn)(struct device *dev, void *data)); |
@@ -396,7 +408,7 @@ struct device { | |||
396 | spinlock_t devres_lock; | 408 | spinlock_t devres_lock; |
397 | struct list_head devres_head; | 409 | struct list_head devres_head; |
398 | 410 | ||
399 | struct list_head node; | 411 | struct klist_node knode_class; |
400 | struct class *class; | 412 | struct class *class; |
401 | dev_t devt; /* dev_t, creates the sysfs "dev" */ | 413 | dev_t devt; /* dev_t, creates the sysfs "dev" */ |
402 | struct attribute_group **groups; /* optional groups */ | 414 | struct attribute_group **groups; /* optional groups */ |
diff --git a/include/linux/elevator.h b/include/linux/elevator.h index 639624b55fbe..92f6f634e3e6 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h | |||
@@ -112,6 +112,7 @@ extern struct request *elv_latter_request(struct request_queue *, struct request | |||
112 | extern int elv_register_queue(struct request_queue *q); | 112 | extern int elv_register_queue(struct request_queue *q); |
113 | extern void elv_unregister_queue(struct request_queue *q); | 113 | extern void elv_unregister_queue(struct request_queue *q); |
114 | extern int elv_may_queue(struct request_queue *, int); | 114 | extern int elv_may_queue(struct request_queue *, int); |
115 | extern void elv_abort_queue(struct request_queue *); | ||
115 | extern void elv_completed_request(struct request_queue *, struct request *); | 116 | extern void elv_completed_request(struct request_queue *, struct request *); |
116 | extern int elv_set_request(struct request_queue *, struct request *, gfp_t); | 117 | extern int elv_set_request(struct request_queue *, struct request *, gfp_t); |
117 | extern void elv_put_request(struct request_queue *, struct request *); | 118 | extern void elv_put_request(struct request_queue *, struct request *); |
@@ -173,15 +174,15 @@ enum { | |||
173 | #define rb_entry_rq(node) rb_entry((node), struct request, rb_node) | 174 | #define rb_entry_rq(node) rb_entry((node), struct request, rb_node) |
174 | 175 | ||
175 | /* | 176 | /* |
176 | * Hack to reuse the donelist list_head as the fifo time holder while | 177 | * Hack to reuse the csd.list list_head as the fifo time holder while |
177 | * the request is in the io scheduler. Saves an unsigned long in rq. | 178 | * the request is in the io scheduler. Saves an unsigned long in rq. |
178 | */ | 179 | */ |
179 | #define rq_fifo_time(rq) ((unsigned long) (rq)->donelist.next) | 180 | #define rq_fifo_time(rq) ((unsigned long) (rq)->csd.list.next) |
180 | #define rq_set_fifo_time(rq,exp) ((rq)->donelist.next = (void *) (exp)) | 181 | #define rq_set_fifo_time(rq,exp) ((rq)->csd.list.next = (void *) (exp)) |
181 | #define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist) | 182 | #define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist) |
182 | #define rq_fifo_clear(rq) do { \ | 183 | #define rq_fifo_clear(rq) do { \ |
183 | list_del_init(&(rq)->queuelist); \ | 184 | list_del_init(&(rq)->queuelist); \ |
184 | INIT_LIST_HEAD(&(rq)->donelist); \ | 185 | INIT_LIST_HEAD(&(rq)->csd.list); \ |
185 | } while (0) | 186 | } while (0) |
186 | 187 | ||
187 | /* | 188 | /* |
diff --git a/include/linux/fd.h b/include/linux/fd.h index b6bd41d2b460..f5d194af07a8 100644 --- a/include/linux/fd.h +++ b/include/linux/fd.h | |||
@@ -15,10 +15,16 @@ struct floppy_struct { | |||
15 | sect, /* sectors per track */ | 15 | sect, /* sectors per track */ |
16 | head, /* nr of heads */ | 16 | head, /* nr of heads */ |
17 | track, /* nr of tracks */ | 17 | track, /* nr of tracks */ |
18 | stretch; /* !=0 means double track steps */ | 18 | stretch; /* bit 0 !=0 means double track steps */ |
19 | /* bit 1 != 0 means swap sides */ | ||
20 | /* bits 2..9 give the first sector */ | ||
21 | /* number (the LSB is flipped) */ | ||
19 | #define FD_STRETCH 1 | 22 | #define FD_STRETCH 1 |
20 | #define FD_SWAPSIDES 2 | 23 | #define FD_SWAPSIDES 2 |
21 | #define FD_ZEROBASED 4 | 24 | #define FD_ZEROBASED 4 |
25 | #define FD_SECTBASEMASK 0x3FC | ||
26 | #define FD_MKSECTBASE(s) (((s) ^ 1) << 2) | ||
27 | #define FD_SECTBASE(floppy) ((((floppy)->stretch & FD_SECTBASEMASK) >> 2) ^ 1) | ||
22 | 28 | ||
23 | unsigned char gap, /* gap1 size */ | 29 | unsigned char gap, /* gap1 size */ |
24 | 30 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 580b513668fe..32477e8872d5 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -86,7 +86,9 @@ extern int dir_notify_enable; | |||
86 | #define READ_META (READ | (1 << BIO_RW_META)) | 86 | #define READ_META (READ | (1 << BIO_RW_META)) |
87 | #define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) | 87 | #define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) |
88 | #define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) | 88 | #define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) |
89 | #define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER)) | 89 | #define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER)) |
90 | #define DISCARD_NOBARRIER (1 << BIO_RW_DISCARD) | ||
91 | #define DISCARD_BARRIER ((1 << BIO_RW_DISCARD) | (1 << BIO_RW_BARRIER)) | ||
90 | 92 | ||
91 | #define SEL_IN 1 | 93 | #define SEL_IN 1 |
92 | #define SEL_OUT 2 | 94 | #define SEL_OUT 2 |
@@ -222,6 +224,7 @@ extern int dir_notify_enable; | |||
222 | #define BLKTRACESTART _IO(0x12,116) | 224 | #define BLKTRACESTART _IO(0x12,116) |
223 | #define BLKTRACESTOP _IO(0x12,117) | 225 | #define BLKTRACESTOP _IO(0x12,117) |
224 | #define BLKTRACETEARDOWN _IO(0x12,118) | 226 | #define BLKTRACETEARDOWN _IO(0x12,118) |
227 | #define BLKDISCARD _IO(0x12,119) | ||
225 | 228 | ||
226 | #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ | 229 | #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ |
227 | #define FIBMAP _IO(0x00,1) /* bmap access */ | 230 | #define FIBMAP _IO(0x00,1) /* bmap access */ |
@@ -1682,6 +1685,7 @@ extern void chrdev_show(struct seq_file *,off_t); | |||
1682 | 1685 | ||
1683 | /* fs/block_dev.c */ | 1686 | /* fs/block_dev.c */ |
1684 | #define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ | 1687 | #define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ |
1688 | #define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */ | ||
1685 | 1689 | ||
1686 | #ifdef CONFIG_BLOCK | 1690 | #ifdef CONFIG_BLOCK |
1687 | #define BLKDEV_MAJOR_HASH_SIZE 255 | 1691 | #define BLKDEV_MAJOR_HASH_SIZE 255 |
@@ -1718,6 +1722,9 @@ extern int fs_may_remount_ro(struct super_block *); | |||
1718 | */ | 1722 | */ |
1719 | #define bio_data_dir(bio) ((bio)->bi_rw & 1) | 1723 | #define bio_data_dir(bio) ((bio)->bi_rw & 1) |
1720 | 1724 | ||
1725 | extern void check_disk_size_change(struct gendisk *disk, | ||
1726 | struct block_device *bdev); | ||
1727 | extern int revalidate_disk(struct gendisk *); | ||
1721 | extern int check_disk_change(struct block_device *); | 1728 | extern int check_disk_change(struct block_device *); |
1722 | extern int __invalidate_device(struct block_device *); | 1729 | extern int __invalidate_device(struct block_device *); |
1723 | extern int invalidate_partition(struct gendisk *, int); | 1730 | extern int invalidate_partition(struct gendisk *, int); |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index be4f5e5bfe06..206cdf96c3a7 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -11,12 +11,15 @@ | |||
11 | 11 | ||
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | #include <linux/kdev_t.h> | 13 | #include <linux/kdev_t.h> |
14 | #include <linux/rcupdate.h> | ||
14 | 15 | ||
15 | #ifdef CONFIG_BLOCK | 16 | #ifdef CONFIG_BLOCK |
16 | 17 | ||
17 | #define kobj_to_dev(k) container_of(k, struct device, kobj) | 18 | #define kobj_to_dev(k) container_of((k), struct device, kobj) |
18 | #define dev_to_disk(device) container_of(device, struct gendisk, dev) | 19 | #define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev) |
19 | #define dev_to_part(device) container_of(device, struct hd_struct, dev) | 20 | #define dev_to_part(device) container_of((device), struct hd_struct, __dev) |
21 | #define disk_to_dev(disk) (&(disk)->part0.__dev) | ||
22 | #define part_to_dev(part) (&((part)->__dev)) | ||
20 | 23 | ||
21 | extern struct device_type part_type; | 24 | extern struct device_type part_type; |
22 | extern struct kobject *block_depr; | 25 | extern struct kobject *block_depr; |
@@ -55,6 +58,9 @@ enum { | |||
55 | UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */ | 58 | UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */ |
56 | }; | 59 | }; |
57 | 60 | ||
61 | #define DISK_MAX_PARTS 256 | ||
62 | #define DISK_NAME_LEN 32 | ||
63 | |||
58 | #include <linux/major.h> | 64 | #include <linux/major.h> |
59 | #include <linux/device.h> | 65 | #include <linux/device.h> |
60 | #include <linux/smp.h> | 66 | #include <linux/smp.h> |
@@ -87,7 +93,7 @@ struct disk_stats { | |||
87 | struct hd_struct { | 93 | struct hd_struct { |
88 | sector_t start_sect; | 94 | sector_t start_sect; |
89 | sector_t nr_sects; | 95 | sector_t nr_sects; |
90 | struct device dev; | 96 | struct device __dev; |
91 | struct kobject *holder_dir; | 97 | struct kobject *holder_dir; |
92 | int policy, partno; | 98 | int policy, partno; |
93 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 99 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
@@ -100,6 +106,7 @@ struct hd_struct { | |||
100 | #else | 106 | #else |
101 | struct disk_stats dkstats; | 107 | struct disk_stats dkstats; |
102 | #endif | 108 | #endif |
109 | struct rcu_head rcu_head; | ||
103 | }; | 110 | }; |
104 | 111 | ||
105 | #define GENHD_FL_REMOVABLE 1 | 112 | #define GENHD_FL_REMOVABLE 1 |
@@ -108,100 +115,148 @@ struct hd_struct { | |||
108 | #define GENHD_FL_CD 8 | 115 | #define GENHD_FL_CD 8 |
109 | #define GENHD_FL_UP 16 | 116 | #define GENHD_FL_UP 16 |
110 | #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 | 117 | #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 |
111 | #define GENHD_FL_FAIL 64 | 118 | #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ |
119 | |||
120 | #define BLK_SCSI_MAX_CMDS (256) | ||
121 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) | ||
122 | |||
123 | struct blk_scsi_cmd_filter { | ||
124 | unsigned long read_ok[BLK_SCSI_CMD_PER_LONG]; | ||
125 | unsigned long write_ok[BLK_SCSI_CMD_PER_LONG]; | ||
126 | struct kobject kobj; | ||
127 | }; | ||
128 | |||
129 | struct disk_part_tbl { | ||
130 | struct rcu_head rcu_head; | ||
131 | int len; | ||
132 | struct hd_struct *part[]; | ||
133 | }; | ||
112 | 134 | ||
113 | struct gendisk { | 135 | struct gendisk { |
136 | /* major, first_minor and minors are input parameters only, | ||
137 | * don't use directly. Use disk_devt() and disk_max_parts(). | ||
138 | */ | ||
114 | int major; /* major number of driver */ | 139 | int major; /* major number of driver */ |
115 | int first_minor; | 140 | int first_minor; |
116 | int minors; /* maximum number of minors, =1 for | 141 | int minors; /* maximum number of minors, =1 for |
117 | * disks that can't be partitioned. */ | 142 | * disks that can't be partitioned. */ |
118 | char disk_name[32]; /* name of major driver */ | 143 | |
119 | struct hd_struct **part; /* [indexed by minor] */ | 144 | char disk_name[DISK_NAME_LEN]; /* name of major driver */ |
145 | |||
146 | /* Array of pointers to partitions indexed by partno. | ||
147 | * Protected with matching bdev lock but stat and other | ||
148 | * non-critical accesses use RCU. Always access through | ||
149 | * helpers. | ||
150 | */ | ||
151 | struct disk_part_tbl *part_tbl; | ||
152 | struct hd_struct part0; | ||
153 | |||
120 | struct block_device_operations *fops; | 154 | struct block_device_operations *fops; |
121 | struct request_queue *queue; | 155 | struct request_queue *queue; |
122 | void *private_data; | 156 | void *private_data; |
123 | sector_t capacity; | ||
124 | 157 | ||
125 | int flags; | 158 | int flags; |
126 | struct device *driverfs_dev; // FIXME: remove | 159 | struct device *driverfs_dev; // FIXME: remove |
127 | struct device dev; | ||
128 | struct kobject *holder_dir; | ||
129 | struct kobject *slave_dir; | 160 | struct kobject *slave_dir; |
130 | 161 | ||
131 | struct timer_rand_state *random; | 162 | struct timer_rand_state *random; |
132 | int policy; | ||
133 | 163 | ||
134 | atomic_t sync_io; /* RAID */ | 164 | atomic_t sync_io; /* RAID */ |
135 | unsigned long stamp; | ||
136 | int in_flight; | ||
137 | #ifdef CONFIG_SMP | ||
138 | struct disk_stats *dkstats; | ||
139 | #else | ||
140 | struct disk_stats dkstats; | ||
141 | #endif | ||
142 | struct work_struct async_notify; | 165 | struct work_struct async_notify; |
143 | #ifdef CONFIG_BLK_DEV_INTEGRITY | 166 | #ifdef CONFIG_BLK_DEV_INTEGRITY |
144 | struct blk_integrity *integrity; | 167 | struct blk_integrity *integrity; |
145 | #endif | 168 | #endif |
169 | int node_id; | ||
146 | }; | 170 | }; |
147 | 171 | ||
148 | /* | 172 | static inline struct gendisk *part_to_disk(struct hd_struct *part) |
149 | * Macros to operate on percpu disk statistics: | ||
150 | * | ||
151 | * The __ variants should only be called in critical sections. The full | ||
152 | * variants disable/enable preemption. | ||
153 | */ | ||
154 | static inline struct hd_struct *get_part(struct gendisk *gendiskp, | ||
155 | sector_t sector) | ||
156 | { | 173 | { |
157 | struct hd_struct *part; | 174 | if (likely(part)) { |
158 | int i; | 175 | if (part->partno) |
159 | for (i = 0; i < gendiskp->minors - 1; i++) { | 176 | return dev_to_disk(part_to_dev(part)->parent); |
160 | part = gendiskp->part[i]; | 177 | else |
161 | if (part && part->start_sect <= sector | 178 | return dev_to_disk(part_to_dev(part)); |
162 | && sector < part->start_sect + part->nr_sects) | ||
163 | return part; | ||
164 | } | 179 | } |
165 | return NULL; | 180 | return NULL; |
166 | } | 181 | } |
167 | 182 | ||
168 | #ifdef CONFIG_SMP | 183 | static inline int disk_max_parts(struct gendisk *disk) |
169 | #define __disk_stat_add(gendiskp, field, addnd) \ | 184 | { |
170 | (per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd) | 185 | if (disk->flags & GENHD_FL_EXT_DEVT) |
186 | return DISK_MAX_PARTS; | ||
187 | return disk->minors; | ||
188 | } | ||
171 | 189 | ||
172 | #define disk_stat_read(gendiskp, field) \ | 190 | static inline bool disk_partitionable(struct gendisk *disk) |
173 | ({ \ | 191 | { |
174 | typeof(gendiskp->dkstats->field) res = 0; \ | 192 | return disk_max_parts(disk) > 1; |
175 | int i; \ | 193 | } |
176 | for_each_possible_cpu(i) \ | ||
177 | res += per_cpu_ptr(gendiskp->dkstats, i)->field; \ | ||
178 | res; \ | ||
179 | }) | ||
180 | 194 | ||
181 | static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { | 195 | static inline dev_t disk_devt(struct gendisk *disk) |
182 | int i; | 196 | { |
197 | return disk_to_dev(disk)->devt; | ||
198 | } | ||
183 | 199 | ||
184 | for_each_possible_cpu(i) | 200 | static inline dev_t part_devt(struct hd_struct *part) |
185 | memset(per_cpu_ptr(gendiskp->dkstats, i), value, | 201 | { |
186 | sizeof(struct disk_stats)); | 202 | return part_to_dev(part)->devt; |
187 | } | 203 | } |
188 | 204 | ||
189 | #define __part_stat_add(part, field, addnd) \ | 205 | extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno); |
190 | (per_cpu_ptr(part->dkstats, smp_processor_id())->field += addnd) | ||
191 | 206 | ||
192 | #define __all_stat_add(gendiskp, part, field, addnd, sector) \ | 207 | static inline void disk_put_part(struct hd_struct *part) |
193 | ({ \ | 208 | { |
194 | if (part) \ | 209 | if (likely(part)) |
195 | __part_stat_add(part, field, addnd); \ | 210 | put_device(part_to_dev(part)); |
196 | __disk_stat_add(gendiskp, field, addnd); \ | 211 | } |
197 | }) | 212 | |
213 | /* | ||
214 | * Smarter partition iterator without context limits. | ||
215 | */ | ||
216 | #define DISK_PITER_REVERSE (1 << 0) /* iterate in the reverse direction */ | ||
217 | #define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */ | ||
218 | #define DISK_PITER_INCL_PART0 (1 << 2) /* include partition 0 */ | ||
219 | |||
220 | struct disk_part_iter { | ||
221 | struct gendisk *disk; | ||
222 | struct hd_struct *part; | ||
223 | int idx; | ||
224 | unsigned int flags; | ||
225 | }; | ||
226 | |||
227 | extern void disk_part_iter_init(struct disk_part_iter *piter, | ||
228 | struct gendisk *disk, unsigned int flags); | ||
229 | extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter); | ||
230 | extern void disk_part_iter_exit(struct disk_part_iter *piter); | ||
231 | |||
232 | extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, | ||
233 | sector_t sector); | ||
234 | |||
235 | /* | ||
236 | * Macros to operate on percpu disk statistics: | ||
237 | * | ||
238 | * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters | ||
239 | * and should be called between disk_stat_lock() and | ||
240 | * disk_stat_unlock(). | ||
241 | * | ||
242 | * part_stat_read() can be called at any time. | ||
243 | * | ||
244 | * part_stat_{add|set_all}() and {init|free}_part_stats are for | ||
245 | * internal use only. | ||
246 | */ | ||
247 | #ifdef CONFIG_SMP | ||
248 | #define part_stat_lock() ({ rcu_read_lock(); get_cpu(); }) | ||
249 | #define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0) | ||
250 | |||
251 | #define __part_stat_add(cpu, part, field, addnd) \ | ||
252 | (per_cpu_ptr((part)->dkstats, (cpu))->field += (addnd)) | ||
198 | 253 | ||
199 | #define part_stat_read(part, field) \ | 254 | #define part_stat_read(part, field) \ |
200 | ({ \ | 255 | ({ \ |
201 | typeof(part->dkstats->field) res = 0; \ | 256 | typeof((part)->dkstats->field) res = 0; \ |
202 | int i; \ | 257 | int i; \ |
203 | for_each_possible_cpu(i) \ | 258 | for_each_possible_cpu(i) \ |
204 | res += per_cpu_ptr(part->dkstats, i)->field; \ | 259 | res += per_cpu_ptr((part)->dkstats, i)->field; \ |
205 | res; \ | 260 | res; \ |
206 | }) | 261 | }) |
207 | 262 | ||
@@ -213,171 +268,107 @@ static inline void part_stat_set_all(struct hd_struct *part, int value) | |||
213 | memset(per_cpu_ptr(part->dkstats, i), value, | 268 | memset(per_cpu_ptr(part->dkstats, i), value, |
214 | sizeof(struct disk_stats)); | 269 | sizeof(struct disk_stats)); |
215 | } | 270 | } |
216 | |||
217 | #else /* !CONFIG_SMP */ | ||
218 | #define __disk_stat_add(gendiskp, field, addnd) \ | ||
219 | (gendiskp->dkstats.field += addnd) | ||
220 | #define disk_stat_read(gendiskp, field) (gendiskp->dkstats.field) | ||
221 | 271 | ||
222 | static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) | 272 | static inline int init_part_stats(struct hd_struct *part) |
223 | { | 273 | { |
224 | memset(&gendiskp->dkstats, value, sizeof (struct disk_stats)); | 274 | part->dkstats = alloc_percpu(struct disk_stats); |
275 | if (!part->dkstats) | ||
276 | return 0; | ||
277 | return 1; | ||
225 | } | 278 | } |
226 | 279 | ||
227 | #define __part_stat_add(part, field, addnd) \ | 280 | static inline void free_part_stats(struct hd_struct *part) |
228 | (part->dkstats.field += addnd) | ||
229 | |||
230 | #define __all_stat_add(gendiskp, part, field, addnd, sector) \ | ||
231 | ({ \ | ||
232 | if (part) \ | ||
233 | part->dkstats.field += addnd; \ | ||
234 | __disk_stat_add(gendiskp, field, addnd); \ | ||
235 | }) | ||
236 | |||
237 | #define part_stat_read(part, field) (part->dkstats.field) | ||
238 | |||
239 | static inline void part_stat_set_all(struct hd_struct *part, int value) | ||
240 | { | 281 | { |
241 | memset(&part->dkstats, value, sizeof(struct disk_stats)); | 282 | free_percpu(part->dkstats); |
242 | } | 283 | } |
243 | 284 | ||
244 | #endif /* CONFIG_SMP */ | 285 | #else /* !CONFIG_SMP */ |
286 | #define part_stat_lock() ({ rcu_read_lock(); 0; }) | ||
287 | #define part_stat_unlock() rcu_read_unlock() | ||
245 | 288 | ||
246 | #define disk_stat_add(gendiskp, field, addnd) \ | 289 | #define __part_stat_add(cpu, part, field, addnd) \ |
247 | do { \ | 290 | ((part)->dkstats.field += addnd) |
248 | preempt_disable(); \ | 291 | |
249 | __disk_stat_add(gendiskp, field, addnd); \ | 292 | #define part_stat_read(part, field) ((part)->dkstats.field) |
250 | preempt_enable(); \ | ||
251 | } while (0) | ||
252 | |||
253 | #define __disk_stat_dec(gendiskp, field) __disk_stat_add(gendiskp, field, -1) | ||
254 | #define disk_stat_dec(gendiskp, field) disk_stat_add(gendiskp, field, -1) | ||
255 | |||
256 | #define __disk_stat_inc(gendiskp, field) __disk_stat_add(gendiskp, field, 1) | ||
257 | #define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1) | ||
258 | |||
259 | #define __disk_stat_sub(gendiskp, field, subnd) \ | ||
260 | __disk_stat_add(gendiskp, field, -subnd) | ||
261 | #define disk_stat_sub(gendiskp, field, subnd) \ | ||
262 | disk_stat_add(gendiskp, field, -subnd) | ||
263 | |||
264 | #define part_stat_add(gendiskp, field, addnd) \ | ||
265 | do { \ | ||
266 | preempt_disable(); \ | ||
267 | __part_stat_add(gendiskp, field, addnd);\ | ||
268 | preempt_enable(); \ | ||
269 | } while (0) | ||
270 | |||
271 | #define __part_stat_dec(gendiskp, field) __part_stat_add(gendiskp, field, -1) | ||
272 | #define part_stat_dec(gendiskp, field) part_stat_add(gendiskp, field, -1) | ||
273 | |||
274 | #define __part_stat_inc(gendiskp, field) __part_stat_add(gendiskp, field, 1) | ||
275 | #define part_stat_inc(gendiskp, field) part_stat_add(gendiskp, field, 1) | ||
276 | |||
277 | #define __part_stat_sub(gendiskp, field, subnd) \ | ||
278 | __part_stat_add(gendiskp, field, -subnd) | ||
279 | #define part_stat_sub(gendiskp, field, subnd) \ | ||
280 | part_stat_add(gendiskp, field, -subnd) | ||
281 | |||
282 | #define all_stat_add(gendiskp, part, field, addnd, sector) \ | ||
283 | do { \ | ||
284 | preempt_disable(); \ | ||
285 | __all_stat_add(gendiskp, part, field, addnd, sector); \ | ||
286 | preempt_enable(); \ | ||
287 | } while (0) | ||
288 | |||
289 | #define __all_stat_dec(gendiskp, field, sector) \ | ||
290 | __all_stat_add(gendiskp, field, -1, sector) | ||
291 | #define all_stat_dec(gendiskp, field, sector) \ | ||
292 | all_stat_add(gendiskp, field, -1, sector) | ||
293 | |||
294 | #define __all_stat_inc(gendiskp, part, field, sector) \ | ||
295 | __all_stat_add(gendiskp, part, field, 1, sector) | ||
296 | #define all_stat_inc(gendiskp, part, field, sector) \ | ||
297 | all_stat_add(gendiskp, part, field, 1, sector) | ||
298 | |||
299 | #define __all_stat_sub(gendiskp, part, field, subnd, sector) \ | ||
300 | __all_stat_add(gendiskp, part, field, -subnd, sector) | ||
301 | #define all_stat_sub(gendiskp, part, field, subnd, sector) \ | ||
302 | all_stat_add(gendiskp, part, field, -subnd, sector) | ||
303 | |||
304 | /* Inlines to alloc and free disk stats in struct gendisk */ | ||
305 | #ifdef CONFIG_SMP | ||
306 | static inline int init_disk_stats(struct gendisk *disk) | ||
307 | { | ||
308 | disk->dkstats = alloc_percpu(struct disk_stats); | ||
309 | if (!disk->dkstats) | ||
310 | return 0; | ||
311 | return 1; | ||
312 | } | ||
313 | 293 | ||
314 | static inline void free_disk_stats(struct gendisk *disk) | 294 | static inline void part_stat_set_all(struct hd_struct *part, int value) |
315 | { | 295 | { |
316 | free_percpu(disk->dkstats); | 296 | memset(&part->dkstats, value, sizeof(struct disk_stats)); |
317 | } | 297 | } |
318 | 298 | ||
319 | static inline int init_part_stats(struct hd_struct *part) | 299 | static inline int init_part_stats(struct hd_struct *part) |
320 | { | 300 | { |
321 | part->dkstats = alloc_percpu(struct disk_stats); | ||
322 | if (!part->dkstats) | ||
323 | return 0; | ||
324 | return 1; | 301 | return 1; |
325 | } | 302 | } |
326 | 303 | ||
327 | static inline void free_part_stats(struct hd_struct *part) | 304 | static inline void free_part_stats(struct hd_struct *part) |
328 | { | 305 | { |
329 | free_percpu(part->dkstats); | ||
330 | } | ||
331 | |||
332 | #else /* CONFIG_SMP */ | ||
333 | static inline int init_disk_stats(struct gendisk *disk) | ||
334 | { | ||
335 | return 1; | ||
336 | } | 306 | } |
337 | 307 | ||
338 | static inline void free_disk_stats(struct gendisk *disk) | 308 | #endif /* CONFIG_SMP */ |
339 | { | ||
340 | } | ||
341 | 309 | ||
342 | static inline int init_part_stats(struct hd_struct *part) | 310 | #define part_stat_add(cpu, part, field, addnd) do { \ |
311 | __part_stat_add((cpu), (part), field, addnd); \ | ||
312 | if ((part)->partno) \ | ||
313 | __part_stat_add((cpu), &part_to_disk((part))->part0, \ | ||
314 | field, addnd); \ | ||
315 | } while (0) | ||
316 | |||
317 | #define part_stat_dec(cpu, gendiskp, field) \ | ||
318 | part_stat_add(cpu, gendiskp, field, -1) | ||
319 | #define part_stat_inc(cpu, gendiskp, field) \ | ||
320 | part_stat_add(cpu, gendiskp, field, 1) | ||
321 | #define part_stat_sub(cpu, gendiskp, field, subnd) \ | ||
322 | part_stat_add(cpu, gendiskp, field, -subnd) | ||
323 | |||
324 | static inline void part_inc_in_flight(struct hd_struct *part) | ||
343 | { | 325 | { |
344 | return 1; | 326 | part->in_flight++; |
327 | if (part->partno) | ||
328 | part_to_disk(part)->part0.in_flight++; | ||
345 | } | 329 | } |
346 | 330 | ||
347 | static inline void free_part_stats(struct hd_struct *part) | 331 | static inline void part_dec_in_flight(struct hd_struct *part) |
348 | { | 332 | { |
333 | part->in_flight--; | ||
334 | if (part->partno) | ||
335 | part_to_disk(part)->part0.in_flight--; | ||
349 | } | 336 | } |
350 | #endif /* CONFIG_SMP */ | ||
351 | 337 | ||
352 | /* drivers/block/ll_rw_blk.c */ | 338 | /* drivers/block/ll_rw_blk.c */ |
353 | extern void disk_round_stats(struct gendisk *disk); | 339 | extern void part_round_stats(int cpu, struct hd_struct *part); |
354 | extern void part_round_stats(struct hd_struct *part); | ||
355 | 340 | ||
356 | /* drivers/block/genhd.c */ | 341 | /* drivers/block/genhd.c */ |
357 | extern int get_blkdev_list(char *, int); | 342 | extern int get_blkdev_list(char *, int); |
358 | extern void add_disk(struct gendisk *disk); | 343 | extern void add_disk(struct gendisk *disk); |
359 | extern void del_gendisk(struct gendisk *gp); | 344 | extern void del_gendisk(struct gendisk *gp); |
360 | extern void unlink_gendisk(struct gendisk *gp); | 345 | extern void unlink_gendisk(struct gendisk *gp); |
361 | extern struct gendisk *get_gendisk(dev_t dev, int *part); | 346 | extern struct gendisk *get_gendisk(dev_t dev, int *partno); |
347 | extern struct block_device *bdget_disk(struct gendisk *disk, int partno); | ||
362 | 348 | ||
363 | extern void set_device_ro(struct block_device *bdev, int flag); | 349 | extern void set_device_ro(struct block_device *bdev, int flag); |
364 | extern void set_disk_ro(struct gendisk *disk, int flag); | 350 | extern void set_disk_ro(struct gendisk *disk, int flag); |
365 | 351 | ||
352 | static inline int get_disk_ro(struct gendisk *disk) | ||
353 | { | ||
354 | return disk->part0.policy; | ||
355 | } | ||
356 | |||
366 | /* drivers/char/random.c */ | 357 | /* drivers/char/random.c */ |
367 | extern void add_disk_randomness(struct gendisk *disk); | 358 | extern void add_disk_randomness(struct gendisk *disk); |
368 | extern void rand_initialize_disk(struct gendisk *disk); | 359 | extern void rand_initialize_disk(struct gendisk *disk); |
369 | 360 | ||
370 | static inline sector_t get_start_sect(struct block_device *bdev) | 361 | static inline sector_t get_start_sect(struct block_device *bdev) |
371 | { | 362 | { |
372 | return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect; | 363 | return bdev->bd_part->start_sect; |
373 | } | 364 | } |
374 | static inline sector_t get_capacity(struct gendisk *disk) | 365 | static inline sector_t get_capacity(struct gendisk *disk) |
375 | { | 366 | { |
376 | return disk->capacity; | 367 | return disk->part0.nr_sects; |
377 | } | 368 | } |
378 | static inline void set_capacity(struct gendisk *disk, sector_t size) | 369 | static inline void set_capacity(struct gendisk *disk, sector_t size) |
379 | { | 370 | { |
380 | disk->capacity = size; | 371 | disk->part0.nr_sects = size; |
381 | } | 372 | } |
382 | 373 | ||
383 | #ifdef CONFIG_SOLARIS_X86_PARTITION | 374 | #ifdef CONFIG_SOLARIS_X86_PARTITION |
@@ -527,9 +518,12 @@ struct unixware_disklabel { | |||
527 | #define ADDPART_FLAG_RAID 1 | 518 | #define ADDPART_FLAG_RAID 1 |
528 | #define ADDPART_FLAG_WHOLEDISK 2 | 519 | #define ADDPART_FLAG_WHOLEDISK 2 |
529 | 520 | ||
530 | extern dev_t blk_lookup_devt(const char *name, int part); | 521 | extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt); |
531 | extern char *disk_name (struct gendisk *hd, int part, char *buf); | 522 | extern void blk_free_devt(dev_t devt); |
523 | extern dev_t blk_lookup_devt(const char *name, int partno); | ||
524 | extern char *disk_name (struct gendisk *hd, int partno, char *buf); | ||
532 | 525 | ||
526 | extern int disk_expand_part_tbl(struct gendisk *disk, int target); | ||
533 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); | 527 | extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); |
534 | extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int); | 528 | extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int); |
535 | extern void delete_partition(struct gendisk *, int); | 529 | extern void delete_partition(struct gendisk *, int); |
@@ -546,16 +540,23 @@ extern void blk_register_region(dev_t devt, unsigned long range, | |||
546 | void *data); | 540 | void *data); |
547 | extern void blk_unregister_region(dev_t devt, unsigned long range); | 541 | extern void blk_unregister_region(dev_t devt, unsigned long range); |
548 | 542 | ||
549 | static inline struct block_device *bdget_disk(struct gendisk *disk, int index) | 543 | extern ssize_t part_size_show(struct device *dev, |
550 | { | 544 | struct device_attribute *attr, char *buf); |
551 | return bdget(MKDEV(disk->major, disk->first_minor) + index); | 545 | extern ssize_t part_stat_show(struct device *dev, |
552 | } | 546 | struct device_attribute *attr, char *buf); |
547 | #ifdef CONFIG_FAIL_MAKE_REQUEST | ||
548 | extern ssize_t part_fail_show(struct device *dev, | ||
549 | struct device_attribute *attr, char *buf); | ||
550 | extern ssize_t part_fail_store(struct device *dev, | ||
551 | struct device_attribute *attr, | ||
552 | const char *buf, size_t count); | ||
553 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ | ||
553 | 554 | ||
554 | #else /* CONFIG_BLOCK */ | 555 | #else /* CONFIG_BLOCK */ |
555 | 556 | ||
556 | static inline void printk_all_partitions(void) { } | 557 | static inline void printk_all_partitions(void) { } |
557 | 558 | ||
558 | static inline dev_t blk_lookup_devt(const char *name, int part) | 559 | static inline dev_t blk_lookup_devt(const char *name, int partno) |
559 | { | 560 | { |
560 | dev_t devt = MKDEV(0, 0); | 561 | dev_t devt = MKDEV(0, 0); |
561 | return devt; | 562 | return devt; |
diff --git a/include/linux/klist.h b/include/linux/klist.h index 06c338ef7f1b..8ea98db223e5 100644 --- a/include/linux/klist.h +++ b/include/linux/klist.h | |||
@@ -38,7 +38,7 @@ extern void klist_init(struct klist *k, void (*get)(struct klist_node *), | |||
38 | void (*put)(struct klist_node *)); | 38 | void (*put)(struct klist_node *)); |
39 | 39 | ||
40 | struct klist_node { | 40 | struct klist_node { |
41 | struct klist *n_klist; | 41 | void *n_klist; /* never access directly */ |
42 | struct list_head n_node; | 42 | struct list_head n_node; |
43 | struct kref n_ref; | 43 | struct kref n_ref; |
44 | struct completion n_removed; | 44 | struct completion n_removed; |
@@ -57,7 +57,6 @@ extern int klist_node_attached(struct klist_node *n); | |||
57 | 57 | ||
58 | struct klist_iter { | 58 | struct klist_iter { |
59 | struct klist *i_klist; | 59 | struct klist *i_klist; |
60 | struct list_head *i_head; | ||
61 | struct klist_node *i_cur; | 60 | struct klist_node *i_cur; |
62 | }; | 61 | }; |
63 | 62 | ||
diff --git a/include/linux/major.h b/include/linux/major.h index 53d5fafd85c3..88249452b935 100644 --- a/include/linux/major.h +++ b/include/linux/major.h | |||
@@ -170,4 +170,6 @@ | |||
170 | 170 | ||
171 | #define VIOTAPE_MAJOR 230 | 171 | #define VIOTAPE_MAJOR 230 |
172 | 172 | ||
173 | #define BLOCK_EXT_MAJOR 259 | ||
174 | |||
173 | #endif | 175 | #endif |
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h index 310e61606415..8b4aa0523db7 100644 --- a/include/linux/mtd/blktrans.h +++ b/include/linux/mtd/blktrans.h | |||
@@ -41,6 +41,8 @@ struct mtd_blktrans_ops { | |||
41 | unsigned long block, char *buffer); | 41 | unsigned long block, char *buffer); |
42 | int (*writesect)(struct mtd_blktrans_dev *dev, | 42 | int (*writesect)(struct mtd_blktrans_dev *dev, |
43 | unsigned long block, char *buffer); | 43 | unsigned long block, char *buffer); |
44 | int (*discard)(struct mtd_blktrans_dev *dev, | ||
45 | unsigned long block, unsigned nr_blocks); | ||
44 | 46 | ||
45 | /* Block layer ioctls */ | 47 | /* Block layer ioctls */ |
46 | int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); | 48 | int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); |
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index f9f6e793575c..855bf95963e7 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h | |||
@@ -75,7 +75,6 @@ struct scsi_cmnd { | |||
75 | 75 | ||
76 | int retries; | 76 | int retries; |
77 | int allowed; | 77 | int allowed; |
78 | int timeout_per_command; | ||
79 | 78 | ||
80 | unsigned char prot_op; | 79 | unsigned char prot_op; |
81 | unsigned char prot_type; | 80 | unsigned char prot_type; |
@@ -86,7 +85,6 @@ struct scsi_cmnd { | |||
86 | /* These elements define the operation we are about to perform */ | 85 | /* These elements define the operation we are about to perform */ |
87 | unsigned char *cmnd; | 86 | unsigned char *cmnd; |
88 | 87 | ||
89 | struct timer_list eh_timeout; /* Used to time out the command. */ | ||
90 | 88 | ||
91 | /* These elements define the operation we ultimately want to perform */ | 89 | /* These elements define the operation we ultimately want to perform */ |
92 | struct scsi_data_buffer sdb; | 90 | struct scsi_data_buffer sdb; |
@@ -139,7 +137,6 @@ extern void scsi_put_command(struct scsi_cmnd *); | |||
139 | extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *, | 137 | extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *, |
140 | struct device *); | 138 | struct device *); |
141 | extern void scsi_finish_command(struct scsi_cmnd *cmd); | 139 | extern void scsi_finish_command(struct scsi_cmnd *cmd); |
142 | extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd); | ||
143 | 140 | ||
144 | extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, | 141 | extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, |
145 | size_t *offset, size_t *len); | 142 | size_t *offset, size_t *len); |
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 44a55d1bf530..d123ca84e732 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h | |||
@@ -43,13 +43,6 @@ struct blk_queue_tags; | |||
43 | #define DISABLE_CLUSTERING 0 | 43 | #define DISABLE_CLUSTERING 0 |
44 | #define ENABLE_CLUSTERING 1 | 44 | #define ENABLE_CLUSTERING 1 |
45 | 45 | ||
46 | enum scsi_eh_timer_return { | ||
47 | EH_NOT_HANDLED, | ||
48 | EH_HANDLED, | ||
49 | EH_RESET_TIMER, | ||
50 | }; | ||
51 | |||
52 | |||
53 | struct scsi_host_template { | 46 | struct scsi_host_template { |
54 | struct module *module; | 47 | struct module *module; |
55 | const char *name; | 48 | const char *name; |
@@ -347,7 +340,7 @@ struct scsi_host_template { | |||
347 | * | 340 | * |
348 | * Status: OPTIONAL | 341 | * Status: OPTIONAL |
349 | */ | 342 | */ |
350 | enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); | 343 | enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); |
351 | 344 | ||
352 | /* | 345 | /* |
353 | * Name of proc directory | 346 | * Name of proc directory |
diff --git a/include/scsi/scsi_transport.h b/include/scsi/scsi_transport.h index 490bd13a634c..0de32cd4e8a7 100644 --- a/include/scsi/scsi_transport.h +++ b/include/scsi/scsi_transport.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define SCSI_TRANSPORT_H | 21 | #define SCSI_TRANSPORT_H |
22 | 22 | ||
23 | #include <linux/transport_class.h> | 23 | #include <linux/transport_class.h> |
24 | #include <linux/blkdev.h> | ||
24 | #include <scsi/scsi_host.h> | 25 | #include <scsi/scsi_host.h> |
25 | #include <scsi/scsi_device.h> | 26 | #include <scsi/scsi_device.h> |
26 | 27 | ||
@@ -64,7 +65,7 @@ struct scsi_transport_template { | |||
64 | * begin counting again | 65 | * begin counting again |
65 | * EH_NOT_HANDLED Begin normal error recovery | 66 | * EH_NOT_HANDLED Begin normal error recovery |
66 | */ | 67 | */ |
67 | enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); | 68 | enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); |
68 | 69 | ||
69 | /* | 70 | /* |
70 | * Used as callback for the completion of i_t_nexus request | 71 | * Used as callback for the completion of i_t_nexus request |