1. 11 5月, 2009 3 次提交
    • T
      block: add rq->resid_len · c3a4d78c
      Tejun Heo 提交于
      rq->data_len served two purposes - the length of data buffer on issue
      and the residual count on completion.  This duality creates some
      headaches.
      
      First of all, block layer and low level drivers can't really determine
      what rq->data_len contains while a request is executing.  It could be
      the total request length or it coulde be anything else one of the
      lower layers is using to keep track of residual count.  This
      complicates things because blk_rq_bytes() and thus
      [__]blk_end_request_all() relies on rq->data_len for PC commands.
      Drivers which want to report residual count should first cache the
      total request length, update rq->data_len and then complete the
      request with the cached data length.
      
      Secondly, it makes requests default to reporting full residual count,
      ie. reporting that no data transfer occurred.  The residual count is
      an exception not the norm; however, the driver should clear
      rq->data_len to zero to signify the normal cases while leaving it
      alone means no data transfer occurred at all.  This reverse default
      behavior complicates code unnecessarily and renders block PC on some
      drivers (ide-tape/floppy) unuseable.
      
      This patch adds rq->resid_len which is used only for residual count.
      
      While at it, remove now unnecessasry blk_rq_bytes() caching in
      ide_pc_intr() as rq->data_len is not changed anymore.
      
      Boaz	: spotted missing conversion in osd
      Sergei	: spotted too early conversion to blk_rq_bytes() in ide-tape
      
      [ Impact: cleanup residual count handling, report 0 resid by default ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      Cc: Borislav Petkov <petkovbb@googlemail.com>
      Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
      Cc: Mike Miller <mike.miller@hp.com>
      Cc: Eric Moore <Eric.Moore@lsi.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Cc: Doug Gilbert <dgilbert@interlog.com>
      Cc: Mike Miller <mike.miller@hp.com>
      Cc: Eric Moore <Eric.Moore@lsi.com>
      Cc: Darrick J. Wong <djwong@us.ibm.com>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Cc: Boaz Harrosh <bharrosh@panasas.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      c3a4d78c
    • T
      ide-tape: don't initialize rq->sector for rw requests · 9720aef2
      Tejun Heo 提交于
      rq->sector is set to the tape->first_frame but it's never actually
      used and not even in the correct unit (512 byte sectors).  Don't set
      it.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Acked-by: NBorislav Petkov <petkovbb@gmail.com>
      Acked-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      9720aef2
    • T
      nbd: don't clear rq->sector and nr_sectors unnecessarily · 53d6979a
      Tejun Heo 提交于
      There's no reason to clear rq->sector and nr_sectors after calling
      blk_rq_init().  They're guaranteed to be clear.  Drop unnecessary
      clearing.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Paul Clements <paul.clements@steeleye.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      53d6979a
  2. 28 4月, 2009 37 次提交
    • B
      mg_disk: use defines from <linux/ata.h> · f68adec3
      Bartlomiej Zolnierkiewicz 提交于
      While at it:
      - remove MG_REG_HEAD_MUST_BE_ON define
      - remove MG_REG_CTRL_INTR_ENABLE define
      - remove MG_REG_HEAD_LBA_MODE define
      - remove unused defines
      
      Cc: unsik Kim <donari75@gmail.com>
      Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      f68adec3
    • B
      mg_disk: fix dependency on libata · 8a11a789
      Bartlomiej Zolnierkiewicz 提交于
      Add local copies of ata_id_string() and ata_id_c_string() to mg_disk
      so there is no need for the driver to depend on ATA and SCSI.
      
      [ Impact: break dependency on libata by copying ata id string functions ]
      
      Cc: unsik Kim <donari75@gmail.com>
      Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      8a11a789
    • T
      mg_disk: clean up request completion paths · a03bb5a3
      Tejun Heo 提交于
      mg_disk implements its own partial completion.  Convert to standard
      block layer partial completion.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: unsik Kim <donari75@gmail.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      a03bb5a3
    • T
      mg_disk: fold mg_disk.h into mg_disk.c · eec94620
      Tejun Heo 提交于
      include/linux/mg_disk.h is used only by drivers/block/mg_disk.c.  No
      reason to put it in a separate header.  Fold it into mg_disk.c.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: unsik Kim <donari75@gmail.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      eec94620
    • T
      swim: clean up request completion paths · e138b4e0
      Tejun Heo 提交于
      swim curiously tries to update request parameters before calling
      __blk_end_request() when __blk_end_request() will do it anyway and
      unnecessarily checks whether current_nr_sectors is zero right after
      fetching.
      
      Drop unnecessary stuff and use standard block layer mechanisms.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Laurent Vivier <Laurent@lvivier.info>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      e138b4e0
    • T
      swim3: clean up request completion paths · 467ca759
      Tejun Heo 提交于
      swim3 curiously tries to update request parameters before calling
      __blk_end_request() when __blk_end_request() will do it anyway, and it
      updates request for partial completion manually instead of using
      blk_update_request().  Also, it does some spurious checks on rq such
      as testing whether rq->sector is negative or current_nr_sectors is
      zero right after fetching.
      
      Drop unnecessary stuff and use standard block layer mechanisms.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      467ca759
    • T
      hd: clean up request completion paths · e091eb67
      Tejun Heo 提交于
      hd read/write_intr() functions manually manipulate request to
      incrementally complete it, which block layer already supports.  Simply
      use block layer completion routines instead of manual partial
      completion.
      
      While at it, clear unnecessary elv_next_request() check at the tail of
      read_intr().  This also makes read and write_intr() more consistent.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      e091eb67
    • T
      sunvdc: kill vdc_end_request() · 04420850
      Tejun Heo 提交于
      vdc_end_request() is a thin silly wrapper on top of
      __blk_end_request().  Kill it.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      04420850
    • T
      ps3disk: simplify request completion · cd4c34eb
      Tejun Heo 提交于
      ps3disk_interrupt() always completes requests fully but it uses
      rq->hard_cur_sectors for FLUSH requests for some reason.  Drop them
      and simply use __blk_end_request_all().
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      cd4c34eb
    • T
      amiflop,ataflop,xd,mg_disk: clean up unnecessary stuff from block drivers · 5b5c5d12
      Tejun Heo 提交于
      rq_data_dir() can only be READ or WRITE and rq->sector and nr_sectors
      are always automatically updated after partial request completion.
      Don't worry about rq_data_dir() not being either READ or WRITE or
      manually update sector and nr_sectors.
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jörg Dorchain <joerg@dorchain.net>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: unsik Kim <donari75@gmail.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      5b5c5d12
    • T
      block: kill rq->data · 731ec497
      Tejun Heo 提交于
      Now that all block request data transfer is done via bio, rq->data
      isn't used.  Kill it.
      
      While at it, make the roles of rq->special and buffer clear.
      
      [ Impact: drop now unncessary field from struct request ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Boaz Harrosh <bharrosh@panasas.com>
      731ec497
    • T
      block: replace end_request() with [__]blk_end_request_cur() · f06d9a2b
      Tejun Heo 提交于
      end_request() has been kept around for backward compatibility;
      however, it's about time for it to go away.
      
      * There aren't too many users left.
      
      * Its use of @updtodate is pretty confusing.
      
      * In some cases, newer code ends up using mixture of end_request() and
        [__]blk_end_request[_all](), which is way too confusing.
      
      So, add [__]blk_end_request_cur() and replace end_request() with it.
      Most conversions are straightforward.  Noteworthy ones are...
      
      * paride/pcd: next_request() updated to take 0/-errno instead of 1/0.
      
      * paride/pf: pf_end_request() and next_request() updated to take
        0/-errno instead of 1/0.
      
      * xd: xd_readwrite() updated to return 0/-errno instead of 1/0.
      
      * mtd/mtd_blkdevs: blktrans_discard_request() updated to return
        0/-errno instead of 1/0.  Unnecessary local variable res
        initialization removed from mtd_blktrans_thread().
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Acked-by: NJoerg Dorchain <joerg@dorchain.net>
      Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: NGrant Likely <grant.likely@secretlab.ca>
      Acked-by: NLaurent Vivier <Laurent@lvivier.info>
      Cc: Tim Waugh <tim@cyberelk.net>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
      Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Cc: unsik Kim <donari75@gmail.com>
      f06d9a2b
    • T
      block: implement and use [__]blk_end_request_all() · 40cbbb78
      Tejun Heo 提交于
      There are many [__]blk_end_request() call sites which call it with
      full request length and expect full completion.  Many of them ensure
      that the request actually completes by doing BUG_ON() the return
      value, which is awkward and error-prone.
      
      This patch adds [__]blk_end_request_all() which takes @rq and @error
      and fully completes the request.  BUG_ON() is added to to ensure that
      this actually happens.
      
      Most conversions are simple but there are a few noteworthy ones.
      
      * cdrom/viocd: viocd_end_request() replaced with direct calls to
        __blk_end_request_all().
      
      * s390/block/dasd: dasd_end_request() replaced with direct calls to
        __blk_end_request_all().
      
      * s390/char/tape_block: tapeblock_end_request() replaced with direct
        calls to blk_end_request_all().
      
      [ Impact: cleanup ]
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Mike Miller <mike.miller@hp.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Jeff Garzik <jgarzik@pobox.com>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
      Cc: Alex Dubov <oakad@yahoo.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      40cbbb78
    • T
      ide-dma: don't reset request fields on dma_timeout_retry() · 586cf268
      Tejun Heo 提交于
      Impact: drop unnecessary code
      
      Now that everything uses bio and block operations, there is no need to
      reset request fields manually when retrying a request.  Every field is
      guaranteed to be always valid.  Drop unnecessary request field
      resetting from ide_dma_timeout_retry().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      586cf268
    • T
      ide: drop rq->data handling from ide_map_sg() · 5ad960fe
      Tejun Heo 提交于
      Impact: remove code path which is no longer necessary
      
      All IDE data transfers now use rq->bio.  Simplify ide_map_sg()
      accordingly.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      5ad960fe
    • T
      ide-atapi: kill unused fields and callbacks · 29d1a437
      Tejun Heo 提交于
      Impact: remove fields and code paths which are no longer necessary
      
      Now that ide-tape uses standard mechanisms to transfer data, special
      case handling for bh handling can be dropped from ide-atapi.  Drop the
      followings.
      
      * pc->cur_pos, b_count, bh and b_data
      * drive->pc_update_buffers() and pc_io_buffers().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      29d1a437
    • T
      ide-tape: simplify read/write functions · 4344d07f
      Tejun Heo 提交于
      Impact: cleanup
      
      idetape_chrdev_read/write() functions are unnecessarily complex when
      everything can be handled in a single loop.  Collapse
      idetape_add_chrdev_read/write_request() into the rw functions and
      simplify the implementation.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      4344d07f
    • T
      ide-tape: use byte size instead of sectors on rw issue functions · 71294cf9
      Tejun Heo 提交于
      Impact: cleanup
      
      Byte size is what most issue functions deal with, make
      idetape_queue_rw_tail() and its wrappers take byte size instead of
      sector counts.  idetape_chrdev_read() and write() functions are
      converted to use tape->buffer_size instead of ctl from tape->cap.
      
      This cleans up code a little bit and will ease the next r/w
      reimplementation.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      71294cf9
    • T
      ide-tape: unify r/w init paths · 3596b664
      Tejun Heo 提交于
      Impact: cleanup
      
      Read and write init paths are almost identical.  Unify them into
      idetape_init_rw().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      3596b664
    • T
      ide-tape: kill idetape_bh · 6cf3d545
      Tejun Heo 提交于
      Impact: kill now unnecessary idetape_bh
      
      With everything using standard mechanisms, there is no need for
      idetape_bh anymore.  Kill it and use tape->buf, cur and valid to
      describe data buffer instead.
      
      Changes worth mentioning are...
      
      * idetape_queue_rq_tail() now always queue tape->buf and and adjusts
        buffer state properly before completion.
      
      * idetape_pad_zeros() clears the buffer only once.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      6cf3d545
    • T
      ide-tape: use standard data transfer mechanism · e998f30b
      Tejun Heo 提交于
      Impact: use standard way to transfer data
      
      ide-tape uses rq in an interesting way.  For r/w requests, rq->special
      is used to carry a private buffer management structure idetape_bh and
      rq->nr_sectors and current_nr_sectors are initialized to the number of
      idetape blocks which isn't necessary 512 bytes.  Also,
      rq->current_nr_sectors is used to report back the residual count in
      units of idetape blocks.
      
      This peculiarity taxes both block layer and ide.  ide-atapi has
      different paths and hooks to accomodate it and what a rq means becomes
      quite confusing and making changes at the block layer becomes quite
      difficult and error-prone.
      
      This patch makes ide-tape use bio instead.  With the previous patch,
      ide-tape currently is using single contiguos buffer so replacing it
      isn't difficult.  Data buffer is mapped into bio using
      blk_rq_map_kern() in idetape_queue_rw_tail().  idetape_io_buffers()
      and idetape_update_buffers() are dropped and pc->bh is set to null to
      tell ide-atapi to use standard data transfer mechanism and idetape_bh
      byte counts are updated by the issuer on completion using the residual
      count.
      
      This change also nicely removes the FIXME in ide_pc_intr() where
      ide-tape rqs need to be completed using ide_rq_bytes() instead of
      blk_rq_bytes() (although this didn't really matter as the request
      didn't have bio).
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      e998f30b
    • T
      ide-tape: use single continuous buffer · 7b13354e
      Tejun Heo 提交于
      Impact: simpler buffer allocation and handling, kills OOM, fix DMA transfers
      
      ide-tape has its own multiple buffer mechanism using struct
      idetape_bh.  It allocates buffer with decreasing order-of-two
      allocations so that it results in minimum number of segments.
      However, the implementation is quite complex and works in a way that
      no other block or ide driver works necessitating a lot of special case
      handling.
      
      The benefit this complex allocation scheme brings is questionable as
      PIO or DMA the number of segments (16 maximum) doesn't make any
      noticeable difference and it also doesn't negate the need for multiple
      order allocation which can fail under memory pressure or high
      fragmentation although it does lower the highest order necessary by
      one when the buffer size isn't power of two.
      
      As the first step to remove the custom buffer management, this patch
      makes ide-tape allocate single continous buffer.  The maximum order is
      four.  I doubt the change would cause any trouble but if it ever
      matters, it should be converted to regular sg mechanism like everyone
      else and even in that case dropping custom buffer handling and moving
      to standard mechanism first make sense as an intermediate step.
      
      This patch makes the first bh to contain the whole buffer and drops
      multi bh handling code.  Following patches will make further changes.
      
      This patch has the side effect of killing OOM triggered by allocation
      path and fixing DMA transfers.  Previously, bug in alloc path
      triggered OOM on command issue and commands were passed to DMA engine
      without DMA-mapping all the segments.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      7b13354e
    • T
      ide-atapi,tape,floppy: allow ->pc_callback() to change rq->data_len · eb6a61bb
      Tejun Heo 提交于
      Impact: allow residual count implementation in ->pc_callback()
      
      rq->data_len has two duties - carrying the number of input bytes on
      issue and carrying residual count back to the issuer on completion.
      ide-atapi completion callback ->pc_callback() is the right place to do
      this but currently ide-atapi depends on rq->data_len carrying the
      original request size after calling ->pc_callback() to complete the pc
      request.
      
      This patch makes ide_pc_intr(), ide_tape_issue_pc() and
      ide_floppy_issue_pc() cache length to complete before calling
      ->pc_callback() so that it can modify rq->data_len as necessary.
      
      Note: As using rq->data_len for two purposes can make cases like this
            incorrect in subtle ways, future changes will introduce separate
            field for residual count.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      eb6a61bb
    • T
      ide-tape,floppy: fix failed command completion after request sense · 08f370f0
      Tejun Heo 提交于
      Impact: fix infinite retry loop
      
      After a command failed, ide-tape and floppy inserts REQUEST_SENSE in
      front of the failed command and according to the result, sets
      pc->retries, flags and errors.  After REQUEST_SENSE is complete, the
      failed command is again at the front of the queue and if the verdict
      was to terminate the request, the issue functions tries to complete it
      directly by calling drive->pc_callback() and returning ide_stopped.
      
      However, drive->pc_callback() doesn't complete a request.  It only
      prepares for completion of the request.  As a result, this creates an
      infinite loop where the failed request is retried perpetually.
      
      Fix it by actually ending the request by calling ide_complete_rq().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      08f370f0
    • T
      ide-pm: don't abuse rq->data · 765139ef
      Tejun Heo 提交于
      Impact: cleanup rq->data usage
      
      ide-pm uses rq->data to carry pointer to struct request_pm_state
      through request queue and rq->special is used to carray pointer to
      local struct ide_cmd, which isn't necessary.  Use rq->special for
      request_pm_state instead and use local ide_cmd in
      ide_start_power_step().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      765139ef
    • T
      ide-cd,atapi: use bio for internal commands · 02e7cf8f
      Tejun Heo 提交于
      Impact: unify request data buffer handling
      
      rq->data is used mostly to pass kernel buffer through request queue
      without using bio.  There are only a couple of places which still do
      this in kernel and converting to bio isn't difficult.
      
      This patch converts ide-cd and atapi to use bio instead of rq->data
      for request sense and internal pc commands.  With previous change to
      unify sense request handling, this is relatively easily achieved by
      adding blk_rq_map_kern() during sense_rq prep and PC issue.
      
      If blk_rq_map_kern() fails for sense, the error is deferred till sense
      issue and aborts the failed command which triggered the sense.  Note
      that this is a slim possibility as sense prep is done on each command
      issue, so for the above condition to actually trigger, all preps since
      the last sense issue till the issue of the request which would require
      a sense should fail.
      
      * do_request functions might sleep now.  This should be okay as ide
        request_fn - do_ide_request() - is invoked only from make_request
        and plug work.  Make sure this is the case by adding might_sleep()
        to do_ide_request().
      
      * Functions which access the read sense data before the sense request
        is complete now should access bio_data(sense_rq->bio) as the sense
        buffer might have been copied during blk_rq_map_kern().
      
      * ide-tape updated to map sg.
      
      * cdrom_do_block_pc() now doesn't have to deal with REQ_TYPE_ATA_PC
        special case.  Simplified.
      
      * tp_ops->output/input_data path dropped from ide_pc_intr().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      02e7cf8f
    • B
      ide-atapi: convert ide-{floppy,tape} to using preallocated sense buffer · 06875320
      Borislav Petkov 提交于
      Since we're issuing REQ_TYPE_SENSE now we need to allow those types of
      rqs in the ->do_request callbacks. As a future improvement, sense_len
      assignment might be unified across all ATAPI devices. Borislav to
      check with specs and test.
      
      As a result, get rid of ide_queue_pc_head() and
      drive->request_sense_rq.
      
      tj: * Init request sense ide_atapi_pc from sense request.  In the
            longer timer, it would probably better to fold
            ide_create_request_sense_cmd() into its only current user -
            ide_floppy_get_format_progress().
      
          * ide_retry_pc() no longer takes @disk.
      
      CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: NBorislav Petkov <petkovbb@gmail.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      06875320
    • B
      ide-cd: convert to using generic sense request · c457ce87
      Borislav Petkov 提交于
      Preallocate a sense request in the ->do_request method and reinitialize
      it only on demand, in case it's been consumed in the IRQ handler path.
      The reason for this is that we don't want to be mapping rq to bio in
      the IRQ path and introduce all kinds of unnecessary hacks to the block
      layer.
      
      tj: * Both user and kernel PC requests expect sense data to be stored
            in separate storage other than drive->sense_data.  Copy sense
            data to rq->sense on completion if rq->sense is not NULL.  This
            fixes bogus sense data on PC requests.
      
      As a result, remove cdrom_queue_request_sense.
      
      CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: NBorislav Petkov <petkovbb@gmail.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      c457ce87
    • B
      ide: add helpers for preparing sense requests · e69d800f
      Borislav Petkov 提交于
      This is in preparation of removing the queueing of a sense request out
      of the IRQ handler path.
      
      Use struct request_sense as a general sense buffer for all ATAPI
      devices ide-{floppy,tape,cd}.
      
      tj: * blk_get_request(__GFP_WAIT) can't be called from do_request() as
            it can cause deadlock.  Converted to use inline struct request
            and blk_rq_init().
      
          * Added xfer / cdb len selection depending on device type.
      
          * All sense prep logics folded into ide_prep_sense() which never
            fails.
      
          * hwif->rq clearing and sense_rq used handling moved into
            ide_queue_sense_rq().
      
          * blk_rq_map_kern() conversion is moved to later patch.
      
      CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
      CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: NBorislav Petkov <petkovbb@gmail.com>
      Signed-off-by: NTejun Heo <tj@kernel.org>
      e69d800f
    • T
      ide-cd: don't abuse rq->buffer · 1f181d2b
      Tejun Heo 提交于
      Impact: rq->buffer usage cleanup
      
      ide-cd uses rq->buffer to carry pointer to the original request when
      issuing REQUEST_SENSE.  Use rq->special instead.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      1f181d2b
    • T
      ide-atapi: don't abuse rq->buffer · ac0b0113
      Tejun Heo 提交于
      Impact: rq->buffer usage cleanup
      
      ide-atapi uses rq->buffer as private opaque value for internal special
      requests.  rq->special isn't used for these cases (the only case where
      rq->special is used is for ide-tape rw requests).  Use rq->special
      instead.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      ac0b0113
    • T
      ide-taskfile: don't abuse rq->buffer · d868ca24
      Tejun Heo 提交于
      Impact: rq->buffer usage cleanup
      
      ide_raw_taskfile() directly uses rq->buffer to carry pointer to the
      data buffer.  This complicates both block interface and ide backend
      request handling.  Use blk_rq_map_kern() instead and drop special
      handling for REQ_TYPE_ATA_TASKFILE from ide_map_sg().
      
      Note that REQ_RW setting is moved upwards as blk_rq_map_kern() uses it
      to initialize bio rw flag.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      d868ca24
    • T
      ide-floppy: block pc always uses bio · 8968932e
      Tejun Heo 提交于
      Impact: remove unnecessary code path
      
      Block pc requests always use bio and rq->data is always NULL.  No need
      to worry about !rq->bio cases in idefloppy_block_pc_cmd().  Note that
      ide-atapi uses ide_pio_bytes() for bio PIO transfer which handle sg
      fine.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      8968932e
    • T
      ide-cd: clear sense buffer before issuing request sense · 59a4f6f3
      Tejun Heo 提交于
      Impact: code simplification
      
      ide_cd_request_sense_fixup() clears the tail of the sense buffer if
      the device didn't completely fill it.  This patch makes
      cdrom_queue_request_sense() clear the sense buffer before issuing the
      command instead of clearing it afterwards.  This simplifies code and
      eases future changes.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      59a4f6f3
    • T
      ide: don't set REQ_SOFTBARRIER · b2963ac1
      Tejun Heo 提交于
      ide doesn't have to worry about REQ_SOFTBARRIER.  Don't set it.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      b2963ac1
    • T
      ide: use blk_run_queue() instead of blk_start_queueing() · 220d06b5
      Tejun Heo 提交于
      blk_start_queueing() is being phased out in favor of
      [__]blk_run_queue().  Switch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      220d06b5
    • T
      ide-tape: remove back-to-back REQUEST_SENSE detection · 0de57fb9
      Tejun Heo 提交于
      Impact: fix an oops which always triggers
      
      ide_tape_issue_pc() assumed drive->pc isn't NULL on invocation when
      checking for back-to-back request sense issues but drive->pc can be
      NULL and even when it's not NULL, it's not safe to dereference it once
      the previous command is complete because pc could have been freed or
      was on stack.  Kill back-to-back REQUEST_SENSE detection.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      0de57fb9