/* * NR_REQUEST is the number of entries in the request-queue. * NOTE that writes may use only the low 2/3 of these: reads * take precedence. * * 32 seems to be a reasonable number: enough to get some benefit * from the elevator-mechanism, but not so much as to lock a lot of * buffers when they are in the queue. 64 seems to be too many (easily * long pauses in reading when heavy writing/syncing is going on) */ #define NR_REQUEST 32//块请求队列中所包含的项数,写操作用这些项的底2/3项,且读操作优先处理
/* * Ok, this is an expanded form so that we can use the same * request for paging requests when that is implemented. In * paging, 'bh' is NULL, and 'waiting' is used to wait for * read/write completion. */ struct request { int dev;/* -1 if no request *///使用的设备号,当为-1时表示该项没有被使用,0无无,1块ram, 2块fd软盘,3块hd硬盘,4字符ttyx终端,5字符tty设备,6字符lp打印机设备
/* * This is used in the elevator algorithm: Note that * reads always go before writes. This is natural: reads * are much more time-critical than writes. */ #define IN_ORDER(s1,s2) \ ((s1)->cmd<(s2)->cmd ||(s1)->cmd==(s2)->cmd && \ ((s1)->dev <(s2)->dev ||((s1)->dev ==(s2)->dev && \ (s1)->sector <(s2)->sector)))//定义用于电梯算法,s1 s2 为request结构,来判断出两个请求项结构的前后排列顺序