aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h81
1 files changed, 69 insertions, 12 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 6690e8bae7bb..09a840264d6f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -186,15 +186,19 @@ struct request {
186 }; 186 };
187 187
188 /* 188 /*
189 * two pointers are available for the IO schedulers, if they need 189 * Three pointers are available for the IO schedulers, if they need
190 * more they have to dynamically allocate it. 190 * more they have to dynamically allocate it.
191 */ 191 */
192 void *elevator_private; 192 void *elevator_private;
193 void *elevator_private2; 193 void *elevator_private2;
194 void *elevator_private3;
194 195
195 struct gendisk *rq_disk; 196 struct gendisk *rq_disk;
196 unsigned long start_time; 197 unsigned long start_time;
197 198#ifdef CONFIG_BLK_CGROUP
199 unsigned long long start_time_ns;
200 unsigned long long io_start_time_ns; /* when passed to hardware */
201#endif
198 /* Number of scatter-gather DMA addr+len pairs after 202 /* Number of scatter-gather DMA addr+len pairs after
199 * physical address coalescing is performed. 203 * physical address coalescing is performed.
200 */ 204 */
@@ -917,7 +921,12 @@ extern void blk_abort_queue(struct request_queue *);
917 */ 921 */
918extern struct request_queue *blk_init_queue_node(request_fn_proc *rfn, 922extern struct request_queue *blk_init_queue_node(request_fn_proc *rfn,
919 spinlock_t *lock, int node_id); 923 spinlock_t *lock, int node_id);
924extern struct request_queue *blk_init_allocated_queue_node(struct request_queue *,
925 request_fn_proc *,
926 spinlock_t *, int node_id);
920extern struct request_queue *blk_init_queue(request_fn_proc *, spinlock_t *); 927extern struct request_queue *blk_init_queue(request_fn_proc *, spinlock_t *);
928extern struct request_queue *blk_init_allocated_queue(struct request_queue *,
929 request_fn_proc *, spinlock_t *);
921extern void blk_cleanup_queue(struct request_queue *); 930extern void blk_cleanup_queue(struct request_queue *);
922extern void blk_queue_make_request(struct request_queue *, make_request_fn *); 931extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
923extern void blk_queue_bounce_limit(struct request_queue *, u64); 932extern void blk_queue_bounce_limit(struct request_queue *, u64);
@@ -994,20 +1003,25 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
994 return NULL; 1003 return NULL;
995 return bqt->tag_index[tag]; 1004 return bqt->tag_index[tag];
996} 1005}
997 1006enum{
998extern int blkdev_issue_flush(struct block_device *, sector_t *); 1007 BLKDEV_WAIT, /* wait for completion */
999#define DISCARD_FL_WAIT 0x01 /* wait for completion */ 1008 BLKDEV_BARRIER, /*issue request with barrier */
1000#define DISCARD_FL_BARRIER 0x02 /* issue DISCARD_BARRIER request */ 1009};
1001extern int blkdev_issue_discard(struct block_device *, sector_t sector, 1010#define BLKDEV_IFL_WAIT (1 << BLKDEV_WAIT)
1002 sector_t nr_sects, gfp_t, int flags); 1011#define BLKDEV_IFL_BARRIER (1 << BLKDEV_BARRIER)
1003 1012extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *,
1013 unsigned long);
1014extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
1015 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags);
1016extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
1017 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags);
1004static inline int sb_issue_discard(struct super_block *sb, 1018static inline int sb_issue_discard(struct super_block *sb,
1005 sector_t block, sector_t nr_blocks) 1019 sector_t block, sector_t nr_blocks)
1006{ 1020{
1007 block <<= (sb->s_blocksize_bits - 9); 1021 block <<= (sb->s_blocksize_bits - 9);
1008 nr_blocks <<= (sb->s_blocksize_bits - 9); 1022 nr_blocks <<= (sb->s_blocksize_bits - 9);
1009 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL, 1023 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL,
1010 DISCARD_FL_BARRIER); 1024 BLKDEV_IFL_WAIT | BLKDEV_IFL_BARRIER);
1011} 1025}
1012 1026
1013extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm); 1027extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);
@@ -1196,6 +1210,48 @@ static inline void put_dev_sector(Sector p)
1196struct work_struct; 1210struct work_struct;
1197int kblockd_schedule_work(struct request_queue *q, struct work_struct *work); 1211int kblockd_schedule_work(struct request_queue *q, struct work_struct *work);
1198 1212
1213#ifdef CONFIG_BLK_CGROUP
1214/*
1215 * This should not be using sched_clock(). A real patch is in progress
1216 * to fix this up, until that is in place we need to disable preemption
1217 * around sched_clock() in this function and set_io_start_time_ns().
1218 */
1219static inline void set_start_time_ns(struct request *req)
1220{
1221 preempt_disable();
1222 req->start_time_ns = sched_clock();
1223 preempt_enable();
1224}
1225
1226static inline void set_io_start_time_ns(struct request *req)
1227{
1228 preempt_disable();
1229 req->io_start_time_ns = sched_clock();
1230 preempt_enable();
1231}
1232
1233static inline uint64_t rq_start_time_ns(struct request *req)
1234{
1235 return req->start_time_ns;
1236}
1237
1238static inline uint64_t rq_io_start_time_ns(struct request *req)
1239{
1240 return req->io_start_time_ns;
1241}
1242#else
1243static inline void set_start_time_ns(struct request *req) {}
1244static inline void set_io_start_time_ns(struct request *req) {}
1245static inline uint64_t rq_start_time_ns(struct request *req)
1246{
1247 return 0;
1248}
1249static inline uint64_t rq_io_start_time_ns(struct request *req)
1250{
1251 return 0;
1252}
1253#endif
1254
1199#define MODULE_ALIAS_BLOCKDEV(major,minor) \ 1255#define MODULE_ALIAS_BLOCKDEV(major,minor) \
1200 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor)) 1256 MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
1201#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \ 1257#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
@@ -1283,10 +1339,11 @@ struct block_device_operations {
1283 int (*direct_access) (struct block_device *, sector_t, 1339 int (*direct_access) (struct block_device *, sector_t,
1284 void **, unsigned long *); 1340 void **, unsigned long *);
1285 int (*media_changed) (struct gendisk *); 1341 int (*media_changed) (struct gendisk *);
1286 unsigned long long (*set_capacity) (struct gendisk *, 1342 void (*unlock_native_capacity) (struct gendisk *);
1287 unsigned long long);
1288 int (*revalidate_disk) (struct gendisk *); 1343 int (*revalidate_disk) (struct gendisk *);
1289 int (*getgeo)(struct block_device *, struct hd_geometry *); 1344 int (*getgeo)(struct block_device *, struct hd_geometry *);
1345 /* this callback is with swap_lock and sometimes page table lock held */
1346 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
1290 struct module *owner; 1347 struct module *owner;
1291}; 1348};
1292 1349