亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sd.c

?? 內核是系統的心臟
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 *	sd.c Copyright (C) 1992 Drew Eckhardt 
 *	Linux scsi disk driver by
 *		Drew Eckhardt 
 *
 *	<drew@colorado.edu>
 *
 *       Modified by Eric Youngdale eric@tantalus.nrl.navy.mil to
 *       add scatter-gather, multiple outstanding request, and other
 *       enhancements.
 */

#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <asm/system.h>

#define MAJOR_NR SCSI_DISK_MAJOR
#include "../block/blk.h"
#include "scsi.h"
#include "hosts.h"
#include "sd.h"
#include "scsi_ioctl.h"
#include "constants.h"

#include <linux/genhd.h>

/*
static const char RCSid[] = "$Header:";
*/

#define MAX_RETRIES 5

/*
 *	Time out in seconds
 */

#define SD_TIMEOUT 300

struct hd_struct * sd;

int NR_SD=0;
int MAX_SD=0;
Scsi_Disk * rscsi_disks;
static int * sd_sizes;
static int * sd_blocksizes;

extern int sd_ioctl(struct inode *, struct file *, unsigned int, unsigned long);

static sd_init_onedisk(int);

static void requeue_sd_request (Scsi_Cmnd * SCpnt);

static int sd_open(struct inode * inode, struct file * filp)
{
        int target;
	target =  DEVICE_NR(MINOR(inode->i_rdev));

	if(target >= NR_SD || !rscsi_disks[target].device)
	  return -ENODEV;   /* No such device */
	
/* Make sure that only one process can do a check_change_disk at one time.
 This is also used to lock out further access when the partition table is being re-read. */

	while (rscsi_disks[target].device->busy);

	if(rscsi_disks[target].device->removable) {
	  check_disk_change(inode->i_rdev);

	  if(!rscsi_disks[target].device->access_count)
	    sd_ioctl(inode, NULL, SCSI_IOCTL_DOORLOCK, 0);
	};
	rscsi_disks[target].device->access_count++;
	return 0;
}

static void sd_release(struct inode * inode, struct file * file)
{
        int target;
	sync_dev(inode->i_rdev);

	target =  DEVICE_NR(MINOR(inode->i_rdev));

	rscsi_disks[target].device->access_count--;

	if(rscsi_disks[target].device->removable) {
	  if(!rscsi_disks[target].device->access_count)
	    sd_ioctl(inode, NULL, SCSI_IOCTL_DOORUNLOCK, 0);
	};
}

static void sd_geninit(void);

static struct file_operations sd_fops = {
	NULL,			/* lseek - default */
	block_read,		/* read - general block-dev read */
	block_write,		/* write - general block-dev write */
	NULL,			/* readdir - bad */
	NULL,			/* select */
	sd_ioctl,		/* ioctl */
	NULL,			/* mmap */
	sd_open,		/* open code */
	sd_release,		/* release */
	block_fsync		/* fsync */
};

static struct gendisk sd_gendisk = {
	MAJOR_NR,		/* Major number */
	"sd",		/* Major name */
	4,		/* Bits to shift to get real from partition */
	1 << 4,		/* Number of partitions per real */
	0,		/* maximum number of real */
	sd_geninit,	/* init function */
	NULL,		/* hd struct */
	NULL,	/* block sizes */
	0,		/* number */
	NULL,	/* internal */
	NULL		/* next */
};

static void sd_geninit (void)
{
	int i;

	for (i = 0; i < NR_SD; ++i)
		sd[i << 4].nr_sects = rscsi_disks[i].capacity;
	sd_gendisk.nr_real = NR_SD;
}

/*
	rw_intr is the interrupt routine for the device driver.  It will
	be notified on the end of a SCSI read / write, and
	will take on of several actions based on success or failure.
*/

static void rw_intr (Scsi_Cmnd *SCpnt)
{
  int result = SCpnt->result;
  int this_count = SCpnt->bufflen >> 9;

#ifdef DEBUG
  printk("sd%d : rw_intr(%d, %d)\n", MINOR(SCpnt->request.dev), SCpnt->host->host_no, result);
#endif

/*
  First case : we assume that the command succeeded.  One of two things will
  happen here.  Either we will be finished, or there will be more
  sectors that we were unable to read last time.
*/

  if (!result) {

#ifdef DEBUG
    printk("sd%d : %d sectors remain.\n", MINOR(SCpnt->request.dev), SCpnt->request.nr_sectors);
    printk("use_sg is %d\n ",SCpnt->use_sg);
#endif
    if (SCpnt->use_sg) {
      struct scatterlist * sgpnt;
      int i;
      sgpnt = (struct scatterlist *) SCpnt->buffer;
      for(i=0; i<SCpnt->use_sg; i++) {
#ifdef DEBUG
	printk(":%x %x %d\n",sgpnt[i].alt_address, sgpnt[i].address, sgpnt[i].length);
#endif
	if (sgpnt[i].alt_address) {
	  if (SCpnt->request.cmd == READ)
	    memcpy(sgpnt[i].alt_address, sgpnt[i].address, sgpnt[i].length);
	  scsi_free(sgpnt[i].address, sgpnt[i].length);
	};
      };
      scsi_free(SCpnt->buffer, SCpnt->sglist_len);  /* Free list of scatter-gather pointers */
    } else {
      if (SCpnt->buffer != SCpnt->request.buffer) {
#ifdef DEBUG
	printk("nosg: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer,
		   SCpnt->bufflen);
#endif	
	  if (SCpnt->request.cmd == READ)
	    memcpy(SCpnt->request.buffer, SCpnt->buffer,
		   SCpnt->bufflen);
	  scsi_free(SCpnt->buffer, SCpnt->bufflen);
      };
    };
/*
 * 	If multiple sectors are requested in one buffer, then
 *	they will have been finished off by the first command.  If
 *	not, then we have a multi-buffer command.
 */
    if (SCpnt->request.nr_sectors > this_count)
      {
	SCpnt->request.errors = 0;
	
	if (!SCpnt->request.bh)
	  {
#ifdef DEBUG
	    printk("sd%d : handling page request, no buffer\n",
		   MINOR(SCpnt->request.dev));
#endif
/*
  The SCpnt->request.nr_sectors field is always done in 512 byte sectors,
  even if this really isn't the case.
*/
	    panic("sd.c: linked page request (%lx %x)",
		  SCpnt->request.sector, this_count);
	  }
      }
    end_scsi_request(SCpnt, 1, this_count);
    requeue_sd_request(SCpnt);
    return;
  }

/* Free up any indirection buffers we allocated for DMA purposes. */
    if (SCpnt->use_sg) {
      struct scatterlist * sgpnt;
      int i;
      sgpnt = (struct scatterlist *) SCpnt->buffer;
      for(i=0; i<SCpnt->use_sg; i++) {
#ifdef DEBUG
	printk("err: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer,
		   SCpnt->bufflen);
#endif
	if (sgpnt[i].alt_address) {
	  scsi_free(sgpnt[i].address, sgpnt[i].length);
	};
      };
      scsi_free(SCpnt->buffer, SCpnt->sglist_len);  /* Free list of scatter-gather pointers */
    } else {
#ifdef DEBUG
      printk("nosgerr: %x %x %d\n",SCpnt->request.buffer, SCpnt->buffer,
		   SCpnt->bufflen);
#endif
      if (SCpnt->buffer != SCpnt->request.buffer)
	scsi_free(SCpnt->buffer, SCpnt->bufflen);
    };

/*
	Now, if we were good little boys and girls, Santa left us a request
	sense buffer.  We can extract information from this, so we
	can choose a block to remap, etc.
*/

        if (driver_byte(result) != 0) {
	  if (sugestion(result) == SUGGEST_REMAP) {
#ifdef REMAP
/*
	Not yet implemented.  A read will fail after being remapped,
	a write will call the strategy routine again.
*/
	    if rscsi_disks[DEVICE_NR(SCpnt->request.dev)].remap
	      {
		result = 0;
	      }
	    else
	      
#endif
	    }

	  if ((SCpnt->sense_buffer[0] & 0x7f) == 0x70) {
	    if ((SCpnt->sense_buffer[2] & 0xf) == UNIT_ATTENTION) {
	      if(rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->removable) {
	      /* detected disc change.  set a bit and quietly refuse	*/
	      /* further access.					*/
	      
		rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->changed = 1;
		end_scsi_request(SCpnt, 0, this_count);
		requeue_sd_request(SCpnt);
		return;
	      }
	    }
	  }
	  

/* 	If we had an ILLEGAL REQUEST returned, then we may have
performed an unsupported command.  The only thing this should be would
be a ten byte read where only a six byte read was supportted.  Also,
on a system where READ CAPACITY failed, we mave have read past the end
of the 	disk. 
*/

	  if (SCpnt->sense_buffer[2] == ILLEGAL_REQUEST) {
	    if (rscsi_disks[DEVICE_NR(SCpnt->request.dev)].ten) {
	      rscsi_disks[DEVICE_NR(SCpnt->request.dev)].ten = 0;
	      requeue_sd_request(SCpnt);
	      result = 0;
	    } else {
	    }
	  }
	}  /* driver byte != 0 */
	if (result) {
		printk("SCSI disk error : host %d id %d lun %d return code = %x\n",
		       rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->host->host_no,
		       rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->id,
		       rscsi_disks[DEVICE_NR(SCpnt->request.dev)].device->lun, result);

		if (driver_byte(result) & DRIVER_SENSE)
			print_sense("sd", SCpnt);
		end_scsi_request(SCpnt, 0, SCpnt->request.current_nr_sectors);
		requeue_sd_request(SCpnt);
		return;
	}
}

/*
	requeue_sd_request() is the request handler function for the sd driver.
	Its function in life is to take block device requests, and translate
	them to SCSI commands.
*/

static void do_sd_request (void)
{
  Scsi_Cmnd * SCpnt = NULL;
  struct request * req = NULL;
  int flag = 0;
  while (1==1){
    cli();
    if (CURRENT != NULL && CURRENT->dev == -1) {
      sti();
      return;
    };

    INIT_SCSI_REQUEST;


/* We have to be careful here.  allocate_device will get a free pointer, but
   there is no guarantee that it is queueable.  In normal usage, we want to
   call this, because other types of devices may have the host all tied up,
   and we want to make sure that we have at least one request pending for this
   type of device.   We can also come through here while servicing an
   interrupt, because of the need to start another command.  If we call
   allocate_device more than once, then the system can wedge if the command
   is not queueable.  The request_queueable function is safe because it checks
   to make sure that the host is able to take another command before it returns
   a pointer.  */

    if (flag++ == 0)
      SCpnt = allocate_device(&CURRENT,
			      rscsi_disks[DEVICE_NR(MINOR(CURRENT->dev))].device->index, 0); 
    else SCpnt = NULL;
    sti();

/* This is a performance enhancement.  We dig down into the request list and
   try and find a queueable request (i.e. device not busy, and host able to
   accept another command.  If we find one, then we queue it. This can
   make a big difference on systems with more than one disk drive.  We want
   to have the interrupts off when monkeying with the request list, because
   otherwise the kernel might try and slip in a request inbetween somewhere. */

    if (!SCpnt && NR_SD > 1){
      struct request *req1;
      req1 = NULL;
      cli();
      req = CURRENT;
      while(req){
	SCpnt = request_queueable(req,
				  rscsi_disks[DEVICE_NR(MINOR(req->dev))].device->index);
	if(SCpnt) break;
	req1 = req;
	req = req->next;
      };
      if (SCpnt && req->dev == -1) {
	if (req == CURRENT) 
	  CURRENT = CURRENT->next;
	else
	  req1->next = req->next;
      };
      sti();
    };
    
    if (!SCpnt) return; /* Could not find anything to do */
    
    wake_up(&wait_for_request);
    
    /* Queue command */
    requeue_sd_request(SCpnt);
  };  /* While */
}    

static void requeue_sd_request (Scsi_Cmnd * SCpnt)
{
	int dev, block, this_count;
	unsigned char cmd[10];
	char * buff;

repeat:

	if(SCpnt->request.dev <= 0) {
	  do_sd_request();
	  return;
	}

	dev =  MINOR(SCpnt->request.dev);
	block = SCpnt->request.sector;
	this_count = 0;

#ifdef DEBUG
	printk("Doing sd request, dev = %d, block = %d\n", dev, block);
#endif

	if (dev >= (NR_SD << 4) || block + SCpnt->request.nr_sectors > sd[dev].nr_sects)
		{
		end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
		goto repeat;
		}

	block += sd[dev].start_sect;
	dev = DEVICE_NR(dev);

	if (rscsi_disks[dev].device->changed)
	        {
/*
 * quietly refuse to do anything to a changed disc until the changed bit has been reset
 */
		/* printk("SCSI disk has been changed.  Prohibiting further I/O.\n");	*/
		end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
		goto repeat;
		}

#ifdef DEBUG
	printk("sd%d : real dev = /dev/sd%d, block = %d\n", MINOR(SCpnt->request.dev), dev, block);
#endif

	switch (SCpnt->request.cmd)
		{
		case WRITE :
			if (!rscsi_disks[dev].device->writeable)
				{
				end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
				goto repeat;
				}
			cmd[0] = WRITE_6;
			break;
		case READ :
			cmd[0] = READ_6;
			break;
		default :
			panic ("Unknown sd command %d\n", SCpnt->request.cmd);
		      }

	SCpnt->this_count = 0;

	if (!SCpnt->request.bh || 
	    (SCpnt->request.nr_sectors == SCpnt->request.current_nr_sectors)) {

	  /* case of page request (i.e. raw device), or unlinked buffer */
	  this_count = SCpnt->request.nr_sectors;
	  buff = SCpnt->request.buffer;
	  SCpnt->use_sg = 0;

	} else if (SCpnt->host->sg_tablesize == 0 ||
		   (need_isa_buffer && 
		    dma_free_sectors < 10)) {

	  /* Case of host adapter that cannot scatter-gather.  We also
	   come here if we are running low on DMA buffer memory.  We set
	   a threshold higher than that we would need for this request so
	   we leave room for other requests.  Even though we would not need
	   it all, we need to be conservative, because if we run low enough
	   we have no choice but to panic. */

	  if (SCpnt->host->sg_tablesize != 0 &&
	      need_isa_buffer && 
	      dma_free_sectors < 10)
	    printk("Warning: SCSI DMA buffer space running low.  Using non scatter-gather I/O.\n");

	  this_count = SCpnt->request.current_nr_sectors;
	  buff = SCpnt->request.buffer;
	  SCpnt->use_sg = 0;

	} else {

	  /* Scatter-gather capable host adapter */
	  struct buffer_head * bh;
	  struct scatterlist * sgpnt;
	  int count, this_count_max;
	  bh = SCpnt->request.bh;
	  this_count = 0;
	  this_count_max = (rscsi_disks[dev].ten ? 0xffff : 0xff);
	  count = 0;
	  while(bh && count < SCpnt->host->sg_tablesize) {
	    if ((this_count + (bh->b_size >> 9)) > this_count_max) break;
	    this_count += (bh->b_size >> 9);
	    count++;
	    bh = bh->b_reqnext;
	  };

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99vv1com这只有精品| 亚洲人精品午夜| 视频一区二区三区在线| 色综合久久中文综合久久牛| 自拍偷拍亚洲欧美日韩| va亚洲va日韩不卡在线观看| 国产农村妇女毛片精品久久麻豆| 精品一区二区免费在线观看| 欧美成人a∨高清免费观看| 一区二区三区久久| 色综合激情久久| 亚洲色图一区二区三区| 国产91精品一区二区麻豆亚洲| 91精品啪在线观看国产60岁| 日韩高清不卡一区二区| 日韩一区二区在线免费观看| 日韩成人dvd| 欧美电视剧在线观看完整版| 久久精品99久久久| 精品国产伦一区二区三区免费| 久久99精品国产.久久久久久| 欧美va亚洲va香蕉在线| 国产一区二区电影| 中文字幕人成不卡一区| 91原创在线视频| 亚洲香蕉伊在人在线观| 在线播放国产精品二区一二区四区| 亚洲国产精品综合小说图片区| 欧美一级片在线看| 国内成人精品2018免费看| 欧美成人性福生活免费看| 免费一级欧美片在线观看| 久久精品无码一区二区三区| 99视频精品全部免费在线| 亚洲一区二区三区在线看| 欧美一区二区三区公司| 不卡视频一二三| 五月激情综合婷婷| 久久久91精品国产一区二区三区| 91同城在线观看| 五月婷婷色综合| 久久人人超碰精品| 欧洲av在线精品| 激情综合色丁香一区二区| 国产精品美女久久久久久| 欧美三级乱人伦电影| 国产乱国产乱300精品| 一区av在线播放| 久久青草欧美一区二区三区| 欧美中文字幕一二三区视频| 午夜精品福利一区二区三区蜜桃| 欧美精品v日韩精品v韩国精品v| 日韩国产一区二| 一区二区中文字幕在线| 欧美电视剧免费全集观看| 色94色欧美sute亚洲13| 国产麻豆精品95视频| 亚洲一区二区三区自拍| 中文天堂在线一区| 日韩精品一区二区三区在线| 色综合天天综合网国产成人综合天 | 美女在线一区二区| 亚洲乱码一区二区三区在线观看| 精品国产亚洲在线| 一本到高清视频免费精品| 五月综合激情网| 中文字幕一区av| 制服.丝袜.亚洲.中文.综合| 9色porny自拍视频一区二区| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲一卡二卡三卡四卡| 国产精品国产三级国产| 26uuu成人网一区二区三区| 欧美伊人精品成人久久综合97| 国产激情偷乱视频一区二区三区| 男女性色大片免费观看一区二区| 亚洲伦在线观看| 亚洲精品一线二线三线| 粉嫩aⅴ一区二区三区四区 | 日一区二区三区| 一区二区三区在线观看网站| 亚洲欧洲精品一区二区三区| 欧美精品在线视频| 在线一区二区三区做爰视频网站| 播五月开心婷婷综合| 国产麻豆精品95视频| 极品销魂美女一区二区三区| 男女视频一区二区| 男人的天堂久久精品| 奇米综合一区二区三区精品视频 | 成人av中文字幕| 国产高清在线观看免费不卡| 黑人精品欧美一区二区蜜桃| 免费观看一级特黄欧美大片| 曰韩精品一区二区| 中文字幕在线播放不卡一区| 日韩视频一区二区在线观看| 日韩美一区二区三区| 日韩精品一区二区三区视频在线观看 | 色综合天天综合在线视频| 91女神在线视频| 色婷婷国产精品| 日本韩国欧美三级| 99免费精品在线| 精品亚洲国内自在自线福利| 九九久久精品视频| 国产精品亚洲第一| av一本久道久久综合久久鬼色| 99国产精品久久久久久久久久| 日本韩国一区二区三区| 欧美老人xxxx18| 欧美亚洲高清一区| 欧美日韩中文一区| 91丨porny丨最新| 欧美日韩国产高清一区二区三区 | 国产精品色一区二区三区| 亚洲欧洲国产日韩| 一区二区三区高清| 免费成人小视频| 免费成人av在线播放| 国产精品1024| 色婷婷综合激情| 日韩欧美不卡在线观看视频| 国产日韩高清在线| 一区二区三区电影在线播| 免费精品99久久国产综合精品| 国产一区二区中文字幕| 99久久婷婷国产综合精品| 欧美视频在线播放| 久久久久久免费毛片精品| 亚洲婷婷综合久久一本伊一区| 午夜亚洲国产au精品一区二区| 激情久久五月天| 国产成人在线观看免费网站| 91黄视频在线观看| 欧美电视剧免费观看| 国产精品热久久久久夜色精品三区| 亚洲激情自拍偷拍| 国产一区二区三区视频在线播放| 色噜噜狠狠色综合中国| 日韩欧美国产系列| 亚洲欧美日韩中文播放 | 欧美精品一二三四| 国产精品网站在线观看| 青青草视频一区| 99v久久综合狠狠综合久久| 正在播放一区二区| 《视频一区视频二区| 日本强好片久久久久久aaa| hitomi一区二区三区精品| 不卡的看片网站| 精品久久五月天| 亚洲愉拍自拍另类高清精品| 免费欧美日韩国产三级电影| 麻豆精品视频在线观看| 色综合久久99| 久久久国产精品不卡| 日本女人一区二区三区| 国产99一区视频免费| 欧美精品一区二区三区高清aⅴ| 亚洲另类色综合网站| 成人免费看的视频| 欧美一区二区三区白人 | 久久久午夜电影| 美国十次了思思久久精品导航| 在线视频综合导航| 自拍偷拍亚洲激情| 成人一级片网址| 精品欧美久久久| 美女高潮久久久| 91精品国产色综合久久久蜜香臀| 欧美日韩1区2区| 亚洲欧洲成人精品av97| 国产麻豆日韩欧美久久| 日韩午夜精品电影| 日本最新不卡在线| 欧美日韩卡一卡二| 亚洲高清免费一级二级三级| 91国模大尺度私拍在线视频| 亚洲蜜臀av乱码久久精品| 91看片淫黄大片一级| 国产精品成人网| 99r国产精品| 国产欧美一区二区三区沐欲| 国产高清精品久久久久| 国产精品久久久久一区 | 精品国产乱码久久久久久图片| 国产一区在线观看视频| 2021中文字幕一区亚洲| 久久久www成人免费无遮挡大片| 亚洲精品免费视频| 欧美欧美欧美欧美| 国产麻豆成人精品| 1024精品合集| 91精品91久久久中77777| 喷水一区二区三区| 91精品国产色综合久久不卡蜜臀| 欧美国产亚洲另类动漫| 亚洲制服丝袜av| 欧美性受xxxx|