root/include/linux/blk.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ide_end_request
  2. end_request
  3. end_request
  4. end_redirect

   1 #ifndef _BLK_H
   2 #define _BLK_H
   3 
   4 #include <linux/blkdev.h>
   5 #include <linux/locks.h>
   6 #include <linux/config.h>
   7 
   8 /*
   9  * NR_REQUEST is the number of entries in the request-queue.
  10  * NOTE that writes may use only the low 2/3 of these: reads
  11  * take precedence.
  12  */
  13 #define NR_REQUEST      64
  14 
  15 /*
  16  * This is used in the elevator algorithm.  We don't prioritise reads
  17  * over writes any more --- although reads are more time-critical than
  18  * writes, by treating them equally we increase filesystem throughput.
  19  * This turns out to give better overall performance.  -- sct
  20  */
  21 #define IN_ORDER(s1,s2) \
  22 ((s1)->rq_dev < (s2)->rq_dev || (((s1)->rq_dev == (s2)->rq_dev && \
  23 (s1)->sector < (s2)->sector)))
  24 
  25 /*
  26  * These will have to be changed to be aware of different buffer
  27  * sizes etc.. It actually needs a major cleanup.
  28  */
  29 #if defined(IDE_DRIVER) || defined(MD_DRIVER)
  30 #define SECTOR_MASK ((BLOCK_SIZE >> 9) - 1)
  31 #else
  32 #define SECTOR_MASK (blksize_size[MAJOR_NR] &&     \
  33         blksize_size[MAJOR_NR][MINOR(CURRENT->rq_dev)] ? \
  34         ((blksize_size[MAJOR_NR][MINOR(CURRENT->rq_dev)] >> 9) - 1) :  \
  35         ((BLOCK_SIZE >> 9)  -  1))
  36 #endif /* IDE_DRIVER */
  37 
  38 #define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0)
  39 
  40 #ifdef CONFIG_CDU31A
  41 extern int cdu31a_init(void);
  42 #endif CONFIG_CDU31A
  43 #ifdef CONFIG_MCD
  44 extern int mcd_init(void);
  45 #endif CONFIG_MCD
  46 #ifdef CONFIG_MCDX
  47 extern int mcdx_init(void);
  48 #endif CONFIG_MCDX
  49 #ifdef CONFIG_SBPCD
  50 extern int sbpcd_init(void);
  51 #endif CONFIG_SBPCD
  52 #ifdef CONFIG_AZTCD
  53 extern int aztcd_init(void);
  54 #endif CONFIG_AZTCD
  55 #ifdef CONFIG_CDU535
  56 extern int sony535_init(void);
  57 #endif CONFIG_CDU535
  58 #ifdef CONFIG_GSCD
  59 extern int gscd_init(void);
  60 #endif CONFIG_GSCD
  61 #ifdef CONFIG_CM206
  62 extern int cm206_init(void);
  63 #endif CONFIG_CM206
  64 #ifdef CONFIG_OPTCD
  65 extern int optcd_init(void);
  66 #endif CONFIG_OPTCD
  67 #ifdef CONFIG_SJCD
  68 extern int sjcd_init(void);
  69 #endif CONFIG_SJCD
  70 #ifdef CONFIG_CDI_INIT
  71 extern int cdi_init(void);
  72 #endif CONFIG_CDI_INIT
  73 #ifdef CONFIG_BLK_DEV_HD
  74 extern int hd_init(void);
  75 #endif
  76 #ifdef CONFIG_BLK_DEV_IDE
  77 extern int ide_init(void);
  78 #endif
  79 #ifdef CONFIG_BLK_DEV_XD
  80 extern int xd_init(void);
  81 #endif
  82 #ifdef CONFIG_BLK_DEV_LOOP
  83 extern int loop_init(void);
  84 #endif
  85 #ifdef CONFIG_BLK_DEV_MD
  86 extern int md_init(void);
  87 #endif CONFIG_BLK_DEV_MD
  88 
  89 extern void set_device_ro(kdev_t dev,int flag);
  90 void add_blkdev_randomness(int major);
  91 
  92 extern int floppy_init(void);
  93 extern void rd_load(void);
  94 extern int rd_init(void);
  95 extern int rd_doload;           /* 1 = load ramdisk, 0 = don't load */
  96 extern int rd_prompt;           /* 1 = prompt for ramdisk, 0 = don't prompt */
  97 extern int rd_image_start;      /* starting block # of image */
  98 
  99 #ifdef CONFIG_BLK_DEV_INITRD
 100 
 101 #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
 102 
 103 extern unsigned long initrd_start,initrd_end;
 104 extern int mount_initrd; /* zero if initrd should not be mounted */
 105 void initrd_init(void);
 106 
 107 #endif
 108 
 109 #define RO_IOCTLS(dev,where) \
 110   case BLKROSET: if (!suser()) return -EACCES; \
 111                  set_device_ro((dev),get_fs_long((long *) (where))); return 0; \
 112   case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
 113                    if (!__err) put_fs_long(0!=is_read_only(dev),(long *) (where)); return __err; }
 114                  
 115 #if defined(MAJOR_NR) || defined(IDE_DRIVER)
 116 
 117 /*
 118  * Add entries as needed.
 119  */
 120 
 121 #ifdef IDE_DRIVER
 122 
 123 #define DEVICE_NR(device)       (MINOR(device) >> PARTN_BITS)
 124 #define DEVICE_ON(device)       /* nothing */
 125 #define DEVICE_OFF(device)      /* nothing */
 126 
 127 #elif (MAJOR_NR == RAMDISK_MAJOR)
 128 
 129 /* ram disk */
 130 #define DEVICE_NAME "ramdisk"
 131 #define DEVICE_REQUEST rd_request
 132 #define DEVICE_NR(device) (MINOR(device))
 133 #define DEVICE_ON(device) 
 134 #define DEVICE_OFF(device)
 135 #define DEVICE_NO_RANDOM
 136 
 137 #elif (MAJOR_NR == FLOPPY_MAJOR)
 138 
 139 static void floppy_off(unsigned int nr);
 140 
 141 #define DEVICE_NAME "floppy"
 142 #define DEVICE_INTR do_floppy
 143 #define DEVICE_REQUEST do_fd_request
 144 #define DEVICE_NR(device) ( (MINOR(device) & 3) | ((MINOR(device) & 0x80 ) >> 5 ))
 145 #define DEVICE_ON(device)
 146 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
 147 
 148 #elif (MAJOR_NR == HD_MAJOR)
 149 
 150 /* harddisk: timeout is 6 seconds.. */
 151 #define DEVICE_NAME "harddisk"
 152 #define DEVICE_INTR do_hd
 153 #define DEVICE_TIMEOUT HD_TIMER
 154 #define TIMEOUT_VALUE (6*HZ)
 155 #define DEVICE_REQUEST do_hd_request
 156 #define DEVICE_NR(device) (MINOR(device)>>6)
 157 #define DEVICE_ON(device)
 158 #define DEVICE_OFF(device)
 159 
 160 #elif (MAJOR_NR == SCSI_DISK_MAJOR)
 161 
 162 #define DEVICE_NAME "scsidisk"
 163 #define DEVICE_INTR do_sd  
 164 #define TIMEOUT_VALUE (2*HZ)
 165 #define DEVICE_REQUEST do_sd_request
 166 #define DEVICE_NR(device) (MINOR(device) >> 4)
 167 #define DEVICE_ON(device)
 168 #define DEVICE_OFF(device)
 169 
 170 /* Kludge to use the same number for both char and block major numbers */
 171 #elif  (MAJOR_NR == MD_MAJOR) && defined(MD_DRIVER)
 172 
 173 #ifndef MD_PERSONALITY
 174 
 175 #define DEVICE_NAME "Multiple devices driver"
 176 #define DEVICE_REQUEST do_md_request
 177 #define DEVICE_NR(device) (MINOR(device))
 178 #define DEVICE_ON(device)
 179 #define DEVICE_OFF(device)
 180 
 181 #endif
 182 
 183 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
 184 
 185 #define DEVICE_NAME "scsitape"
 186 #define DEVICE_INTR do_st  
 187 #define DEVICE_NR(device) (MINOR(device) & 0x7f)
 188 #define DEVICE_ON(device)
 189 #define DEVICE_OFF(device)
 190 
 191 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
 192 
 193 #define DEVICE_NAME "CD-ROM"
 194 #define DEVICE_INTR do_sr
 195 #define DEVICE_REQUEST do_sr_request
 196 #define DEVICE_NR(device) (MINOR(device))
 197 #define DEVICE_ON(device)
 198 #define DEVICE_OFF(device)
 199 
 200 #elif (MAJOR_NR == XT_DISK_MAJOR)
 201 
 202 #define DEVICE_NAME "xt disk"
 203 #define DEVICE_REQUEST do_xd_request
 204 #define DEVICE_NR(device) (MINOR(device) >> 6)
 205 #define DEVICE_ON(device)
 206 #define DEVICE_OFF(device)
 207 
 208 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
 209 
 210 #define DEVICE_NAME "CDU31A"
 211 #define DEVICE_REQUEST do_cdu31a_request
 212 #define DEVICE_NR(device) (MINOR(device))
 213 #define DEVICE_ON(device)
 214 #define DEVICE_OFF(device)
 215 
 216 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
 217 
 218 #define DEVICE_NAME "Mitsumi CD-ROM"
 219 /* #define DEVICE_INTR do_mcd */
 220 #define DEVICE_REQUEST do_mcd_request
 221 #define DEVICE_NR(device) (MINOR(device))
 222 #define DEVICE_ON(device)
 223 #define DEVICE_OFF(device)
 224 
 225 #elif (MAJOR_NR == MITSUMI_X_CDROM_MAJOR)
 226 
 227 #define DEVICE_NAME "Mitsumi CD-ROM"
 228 /* #define DEVICE_INTR do_mcdx */
 229 #define DEVICE_REQUEST do_mcdx_request
 230 #define DEVICE_NR(device) (MINOR(device))
 231 #define DEVICE_ON(device)
 232 #define DEVICE_OFF(device)
 233 
 234 #elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
 235 
 236 #define DEVICE_NAME "Matsushita CD-ROM controller #1"
 237 #define DEVICE_REQUEST do_sbpcd_request
 238 #define DEVICE_NR(device) (MINOR(device))
 239 #define DEVICE_ON(device)
 240 #define DEVICE_OFF(device)
 241 
 242 #elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
 243 
 244 #define DEVICE_NAME "Matsushita CD-ROM controller #2"
 245 #define DEVICE_REQUEST do_sbpcd2_request
 246 #define DEVICE_NR(device) (MINOR(device))
 247 #define DEVICE_ON(device)
 248 #define DEVICE_OFF(device)
 249 
 250 #elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
 251 
 252 #define DEVICE_NAME "Matsushita CD-ROM controller #3"
 253 #define DEVICE_REQUEST do_sbpcd3_request
 254 #define DEVICE_NR(device) (MINOR(device))
 255 #define DEVICE_ON(device)
 256 #define DEVICE_OFF(device)
 257 
 258 #elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
 259 
 260 #define DEVICE_NAME "Matsushita CD-ROM controller #4"
 261 #define DEVICE_REQUEST do_sbpcd4_request
 262 #define DEVICE_NR(device) (MINOR(device))
 263 #define DEVICE_ON(device)
 264 #define DEVICE_OFF(device)
 265 
 266 #elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
 267 
 268 #define DEVICE_NAME "Aztech CD-ROM"
 269 #define DEVICE_REQUEST do_aztcd_request
 270 #define DEVICE_NR(device) (MINOR(device))
 271 #define DEVICE_ON(device)
 272 #define DEVICE_OFF(device)
 273 
 274 #elif (MAJOR_NR == CDU535_CDROM_MAJOR)
 275 
 276 #define DEVICE_NAME "SONY-CDU535"
 277 #define DEVICE_INTR do_cdu535
 278 #define DEVICE_REQUEST do_cdu535_request
 279 #define DEVICE_NR(device) (MINOR(device))
 280 #define DEVICE_ON(device)
 281 #define DEVICE_OFF(device)
 282 
 283 #elif (MAJOR_NR == GOLDSTAR_CDROM_MAJOR)
 284 
 285 #define DEVICE_NAME "Goldstar R420"
 286 #define DEVICE_REQUEST do_gscd_request
 287 #define DEVICE_NR(device) (MINOR(device))
 288 #define DEVICE_ON(device)
 289 #define DEVICE_OFF(device)
 290 
 291 #elif (MAJOR_NR == CM206_CDROM_MAJOR)
 292 #define DEVICE_NAME "Philips/LMS cd-rom cm206"
 293 #define DEVICE_REQUEST do_cm206_request
 294 #define DEVICE_NR(device) (MINOR(device))
 295 #define DEVICE_ON(device)
 296 #define DEVICE_OFF(device)
 297 
 298 #elif (MAJOR_NR == OPTICS_CDROM_MAJOR)
 299 
 300 #define DEVICE_NAME "DOLPHIN 8000AT CD-ROM"
 301 #define DEVICE_REQUEST do_optcd_request
 302 #define DEVICE_NR(device) (MINOR(device))
 303 #define DEVICE_ON(device)
 304 #define DEVICE_OFF(device)
 305 
 306 #elif (MAJOR_NR == SANYO_CDROM_MAJOR)
 307 
 308 #define DEVICE_NAME "Sanyo H94A CD-ROM"
 309 #define DEVICE_REQUEST do_sjcd_request
 310 #define DEVICE_NR(device) (MINOR(device))
 311 #define DEVICE_ON(device)
 312 #define DEVICE_OFF(device)
 313 
 314 #endif /* MAJOR_NR == whatever */
 315 
 316 #if ((MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER) && !defined(MD_DRIVER))
 317 
 318 #ifndef CURRENT
 319 #define CURRENT (blk_dev[MAJOR_NR].current_request)
 320 #endif
 321 
 322 #define CURRENT_DEV DEVICE_NR(CURRENT->rq_dev)
 323 
 324 #ifdef DEVICE_INTR
 325 void (*DEVICE_INTR)(void) = NULL;
 326 #endif
 327 #ifdef DEVICE_TIMEOUT
 328 
 329 #define SET_TIMER \
 330 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
 331 (timer_active |= 1<<DEVICE_TIMEOUT))
 332 
 333 #define CLEAR_TIMER \
 334 timer_active &= ~(1<<DEVICE_TIMEOUT)
 335 
 336 #define SET_INTR(x) \
 337 if ((DEVICE_INTR = (x)) != NULL) \
 338         SET_TIMER; \
 339 else \
 340         CLEAR_TIMER;
 341 
 342 #else
 343 
 344 #define SET_INTR(x) (DEVICE_INTR = (x))
 345 
 346 #endif /* DEVICE_TIMEOUT */
 347 
 348 #ifndef MD_PERSONALITY
 349 static void (DEVICE_REQUEST)(void);
 350 #endif
 351   
 352 #ifdef DEVICE_INTR
 353 #define CLEAR_INTR SET_INTR(NULL)
 354 #else
 355 #define CLEAR_INTR
 356 #endif
 357 
 358 #define INIT_REQUEST \
 359         if (!CURRENT) {\
 360                 CLEAR_INTR; \
 361                 return; \
 362         } \
 363         if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \
 364                 panic(DEVICE_NAME ": request list destroyed"); \
 365         if (CURRENT->bh) { \
 366                 if (!buffer_locked(CURRENT->bh)) \
 367                         panic(DEVICE_NAME ": block not locked"); \
 368         }
 369 
 370 #endif /* (MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER) */
 371 
 372 /* end_request() - SCSI devices have their own version */
 373 /*               - IDE drivers have their own copy too */
 374 
 375 #if ! SCSI_MAJOR(MAJOR_NR) || (defined(MD_DRIVER) && !defined(MD_PERSONALITY))
 376 
 377 #if defined(IDE_DRIVER) && !defined(_IDE_C) /* shared copy for IDE modules */
 378 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup);
 379 #else
 380 
 381 #ifdef IDE_DRIVER
 382 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup) {
     /* [previous][next][first][last][top][bottom][index][help] */
 383         struct request *req = hwgroup->rq;
 384 #elif defined(MD_DRIVER)
 385 static void end_request (int uptodate, struct request * req) {
     /* [previous][next][first][last][top][bottom][index][help] */
 386 #else
 387 static void end_request(int uptodate) {
     /* [previous][next][first][last][top][bottom][index][help] */
 388         struct request *req = CURRENT;
 389 #endif /* IDE_DRIVER */
 390         struct buffer_head * bh;
 391 
 392         req->errors = 0;
 393         if (!uptodate) {
 394                 printk("end_request: I/O error, dev %s, sector %lu\n",
 395                         kdevname(req->rq_dev), req->sector);
 396                 req->nr_sectors--;
 397                 req->nr_sectors &= ~SECTOR_MASK;
 398                 req->sector += (BLOCK_SIZE / 512);
 399                 req->sector &= ~SECTOR_MASK;            
 400         }
 401 
 402         if ((bh = req->bh) != NULL) {
 403                 req->bh = bh->b_reqnext;
 404                 bh->b_reqnext = NULL;
 405                 mark_buffer_uptodate(bh, uptodate);
 406                 unlock_buffer(bh);
 407                 if ((bh = req->bh) != NULL) {
 408                         req->current_nr_sectors = bh->b_size >> 9;
 409                         if (req->nr_sectors < req->current_nr_sectors) {
 410                                 req->nr_sectors = req->current_nr_sectors;
 411                                 printk("end_request: buffer-list destroyed\n");
 412                         }
 413                         req->buffer = bh->b_data;
 414                         return;
 415                 }
 416         }
 417 #ifndef DEVICE_NO_RANDOM
 418         add_blkdev_randomness(MAJOR(req->rq_dev));
 419 #endif
 420 #ifdef IDE_DRIVER
 421         blk_dev[MAJOR(req->rq_dev)].current_request = req->next;
 422         hwgroup->rq = NULL;
 423 #elif !defined(MD_DRIVER)
 424         DEVICE_OFF(req->rq_dev);
 425         CURRENT = req->next;
 426 #endif /* IDE_DRIVER */
 427         if (req->sem != NULL)
 428                 up(req->sem);
 429         req->rq_status = RQ_INACTIVE;
 430         wake_up(&wait_for_request);
 431 }
 432 #endif /* defined(IDE_DRIVER) && !defined(_IDE_C) */
 433 #endif /* ! SCSI_MAJOR(MAJOR_NR) */
 434 
 435 #ifdef MD_PERSONALITY
 436 extern inline void end_redirect (struct request *req)
     /* [previous][next][first][last][top][bottom][index][help] */
 437 {
 438   struct buffer_head * bh;
 439 
 440   req->errors = 0;
 441   
 442   if ((bh = req->bh) != NULL)
 443   {
 444     req->bh = bh->b_reqnext;
 445     bh->b_reqnext = NULL;
 446     
 447     if ((bh = req->bh) != NULL)
 448     {
 449       req->sector += req->current_nr_sectors;
 450       req->current_nr_sectors = bh->b_size >> 9;
 451       
 452       if (req->nr_sectors < req->current_nr_sectors)
 453       {
 454         req->nr_sectors = req->current_nr_sectors;
 455         printk("end_redirect : buffer-list destroyed\n");
 456       }
 457       
 458       req->buffer = bh->b_data;
 459       return;
 460     }
 461   }
 462 }
 463 #endif /* MD_PERSONALITY */
 464 
 465 #endif /* defined(MAJOR_NR) || defined(IDE_DRIVER) */
 466 
 467 #endif /* _BLK_H */

/* [previous][next][first][last][top][bottom][index][help] */