29 Oct, 2009

1 commit


22 Sep, 2009

1 commit


02 Sep, 2009

1 commit

  • ->read_proc, ->write_proc are going away, ->proc_fops should be used instead.

    The only tricky place is IDENTIFY handling: if for some reason
    taskfile_lib_get_identify() fails, buffer _is_ changed and at least
    first byte is overwritten. Emulate old behaviour with returning
    that first byte to userspace and reporting length=1 despite overall -E.

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: David S. Miller

    Alexey Dobriyan
     

08 Aug, 2009

3 commits

  • ide-tape used to hit

    [ 58.614854] ide-tape: ht0: BUG: Two DSC requests queued!

    due to the fact that another rq was being issued while the driver was
    waiting for DSC to get set for the device executing ATAPI commands which
    set the DSC to 1 to indicate completion.

    Here's a sample output of that case:

    issue REZERO_UNIT

    [ 143.088505] ide-tape: ide_tape_issue_pc: retry #0, cmd: 0x01
    [ 143.095122] ide: Enter ide_pc_intr - interrupt handler
    [ 143.096118] ide: Packet command completed, 0 bytes transferred
    [ 143.106319] ide-tape: ide_tape_callback: cmd: 0x1, dsc: 1, err: 0
    [ 143.112601] ide-tape: idetape_postpone_request: cmd: 0x1, dsc_poll_freq: 2000

    we stall the ide-tape queue here waiting for DSC

    [ 143.119936] ide-tape: ide_tape_read_position: enter
    [ 145.119019] ide-tape: idetape_do_request: sector: 4294967295, nr_sectors: 0

    and issue the new READ_POSITION rq and hit the check.

    [ 145.126247] ide-tape: ht0: BUG: Two DSC requests queued!
    [ 145.131748] ide-tape: ide_tape_read_position: BOP - No
    [ 145.137059] ide-tape: ide_tape_read_position: EOP - No

    Also, ->postponed_rq used to point to that postponed request. To make
    things worse, in certain circumstances the rq it was pointing to got
    replaced unterneath it by swiftly reusing the same rq from the mempool
    of the block layer practically confusing stuff even more.

    However, we don't need to keep a pointer to that rq but simply wait for
    DSC to be set first before issuing the follow-up request in the drive's
    queue. In order to do that, we make idetape_do_request() first check the
    DSC and if not set, we stall the drive queue giving the other device on
    that IDE channel a chance.

    Signed-off-by: Borislav Petkov
    Signed-off-by: David S. Miller

    Borislav Petkov
     
  • Remove tape->debug_mask and use drive->debug_mask instead.

    There should be no functional change resulting from this patch.

    Signed-off-by: Borislav Petkov
    Signed-off-by: David S. Miller

    Borislav Petkov
     
  • This error only occurs when IDETAPE_DEBUG_LOG is enabled.

    Signed-off-by: Mark de Wever
    Signed-off-by: David S. Miller

    Mark de Wever
     

22 Jul, 2009

1 commit


16 Jun, 2009

2 commits

  • Unsupported requests should be never handed down to device drivers
    and the best thing we can do upon discovering such request inside
    driver's ->do_request method is to just BUG().

    Signed-off-by: Bartlomiej Zolnierkiewicz

    Bartlomiej Zolnierkiewicz
     
  • This fixes

    drivers/ide/ide-tape.c: In function `idetape_chrdev_open':
    drivers/ide/ide-tape.c:1515: error: implicit declaration of function `idetape_read_position'
    make[1]: *** [drivers/ide/ide-tape.o] Error 1

    Signed-off-by: Borislav Petkov
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Borislav Petkov
     

13 Jun, 2009

2 commits

  • Conflicts:
    drivers/ide/ide-tape.c

    Bartlomiej Zolnierkiewicz
     
  • * 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (29 commits)
    ide: re-implement ide_pci_init_one() on top of ide_pci_init_two()
    ide: unexport ide_find_dma_mode()
    ide: fix PowerMac bootup oops
    ide: skip probe if there are no devices on the port (v2)
    sl82c105: add printk() logging facility
    ide-tape: fix proc warning
    ide: add IDE_DFLAG_NIEN_QUIRK device flag
    ide: respect quirk_drives[] list on all controllers
    hpt366: enable all quirks for devices on quirk_drives[] list
    hpt366: sync quirk_drives[] list with pdc202xx_{new,old}.c
    ide: remove superfluous SELECT_MASK() call from do_rw_taskfile()
    ide: remove superfluous SELECT_MASK() call from ide_driveid_update()
    icside: remove superfluous ->maskproc method
    ide-tape: fix IDE_AFLAG_* atomic accesses
    ide-tape: change IDE_AFLAG_IGNORE_DSC non-atomically
    pdc202xx_old: kill resetproc() method
    pdc202xx_old: don't call pdc202xx_reset() on IRQ timeout
    pdc202xx_old: use ide_dma_test_irq()
    ide: preserve Host Protected Area by default (v2)
    ide-gd: implement block device ->set_capacity method (v2)
    ...

    Linus Torvalds
     

12 Jun, 2009

1 commit

  • * 'for-2.6.31' of git://git.kernel.dk/linux-2.6-block: (153 commits)
    block: add request clone interface (v2)
    floppy: fix hibernation
    ramdisk: remove long-deprecated "ramdisk=" boot-time parameter
    fs/bio.c: add missing __user annotation
    block: prevent possible io_context->refcount overflow
    Add serial number support for virtio_blk, V4a
    block: Add missing bounce_pfn stacking and fix comments
    Revert "block: Fix bounce limit setting in DM"
    cciss: decode unit attention in SCSI error handling code
    cciss: Remove no longer needed sendcmd reject processing code
    cciss: change SCSI error handling routines to work with interrupts enabled.
    cciss: separate error processing and command retrying code in sendcmd_withirq_core()
    cciss: factor out fix target status processing code from sendcmd functions
    cciss: simplify interface of sendcmd() and sendcmd_withirq()
    cciss: factor out core of sendcmd_withirq() for use by SCSI error handling code
    cciss: Use schedule_timeout_uninterruptible in SCSI error handling code
    block: needs to set the residual length of a bidi request
    Revert "block: implement blkdev_readpages"
    block: Fix bounce limit setting in DM
    Removed reference to non-existing file Documentation/PCI/PCI-DMA-mapping.txt
    ...

    Manually fix conflicts with tracing updates in:
    block/blk-sysfs.c
    drivers/ide/ide-atapi.c
    drivers/ide/ide-cd.c
    drivers/ide/ide-floppy.c
    drivers/ide/ide-tape.c
    include/trace/events/block.h
    kernel/trace/blktrace.c

    Linus Torvalds
     

09 Jun, 2009

1 commit

  • ide_tape_chrdev_get() was missing an ide_device_get() refcount increment
    which lead to the following warning:

    [ 278.147906] ------------[ cut here ]------------
    [ 278.152685] WARNING: at fs/proc/generic.c:847 remove_proc_entry+0x199/0x1b8()
    [ 278.160070] Hardware name: P4I45PE 1.00
    [ 278.160076] remove_proc_entry: removing non-empty directory 'ide0/hdb', leaking at least 'name'
    [ 278.160080] Modules linked in: rtc intel_agp pcspkr thermal processor thermal_sys parport_pc parport agpgart button
    [ 278.160100] Pid: 2312, comm: mt Not tainted 2.6.30-rc2 #3
    [ 278.160105] Call Trace:
    [ 278.160117] [] warn_slowpath+0x71/0xa0
    [ 278.160126] [] ? _spin_unlock_irqrestore+0x29/0x2c
    [ 278.160132] [] ? try_to_wake_up+0x1b6/0x1c0
    [ 278.160141] [] ? default_wake_function+0xb/0xd
    [ 278.160149] [] ? pollwake+0x4a/0x55
    [ 278.160156] [] ? _spin_unlock+0x24/0x26
    [ 278.160163] [] ? add_partial+0x44/0x49
    [ 278.160169] [] ? __slab_free+0xba/0x29c
    [ 278.160177] [] ? sysfs_delete_inode+0x0/0x3c
    [ 278.160184] [] remove_proc_entry+0x199/0x1b8
    [ 278.160191] [] ? remove_dir+0x27/0x2e
    [ 278.160199] [] ide_proc_unregister_device+0x40/0x4c
    [ 278.160207] [] drive_release_dev+0x14/0x47
    [ 278.160214] [] device_release+0x35/0x5a
    [ 278.160221] [] kobject_release+0x40/0x50
    [ 278.160226] [] ? kobject_release+0x0/0x50
    [ 278.160232] [] kref_put+0x3c/0x4a
    [ 278.160238] [] kobject_put+0x37/0x3c
    [ 278.160243] [] put_device+0xf/0x11
    [ 278.160249] [] ide_device_put+0x2d/0x30
    [ 278.160255] [] ide_tape_put+0x24/0x32
    [ 278.160261] [] idetape_chrdev_release+0x17f/0x18e
    [ 278.160269] [] __fput+0xca/0x175
    [ 278.160275] [] fput+0x19/0x1b
    [ 278.160280] [] filp_close+0x51/0x5b
    [ 278.160286] [] sys_close+0x73/0xad
    [ 278.160293] [] syscall_call+0x7/0xb
    [ 278.160298] ---[ end trace f16d907ea1f89336 ]---

    Instead of trivially fixing it by adding the missing call,
    ide_tape_chrdev_get() and ide_tape_get() were merged into one function
    since both were almost identical. The only difference was that
    ide_tape_chrdev_get() was accessing the ide-tape reference through the
    idetape_devs[] array of minors instead of through the gendisk.

    Accomodate that by adding two additional parameters to ide_tape_get() to
    annotate the call site and invoke the proper behavior.

    As a result, remove ide_tape_chrdev_get().

    Signed-off-by: Borislav Petkov
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Borislav Petkov
     

07 Jun, 2009

2 commits


19 May, 2009

1 commit

  • In commit c3a4d78c580de4edc9ef0f7c59812fb02ceb037f, while introducing
    rq->resid_len, the default value of residue count was changed from
    full count to zero. The conversion was done under the assumption that
    when a request fails residue count wasn't defined. However, Boaz and
    James pointed out that this wasn't true and the residue count should
    be preserved for failed requests too.

    This patchset restores the original behavior by setting rq->resid_len
    to blk_rq_bytes(rq) on request start and restoring explicit clearing
    in affected drivers. While at it, take advantage of the fact that
    rq->resid_len is set to full count where applicable.

    * ide-cd: rq->resid_len cleared on pc success

    * mptsas: req->resid_len cleared on success

    * sas_expander: rsp/req->resid_len cleared on success

    * mpt2sas_transport: req->resid_len cleared on success

    * ide-cd, ide-tape, mptsas, sas_host_smp, mpt2sas_transport, ub: take
    advantage of initial full count to simplify code

    Boaz Harrosh spotted bug in resid_len initialization. Fixed as
    suggested.

    Signed-off-by: Tejun Heo
    Acked-by: Borislav Petkov
    Cc: Boaz Harrosh
    Cc: James Bottomley
    Cc: Pete Zaitcev
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Sergei Shtylyov
    Cc: Eric Moore
    Cc: Darrick J. Wong
    Signed-off-by: Jens Axboe

    Tejun Heo
     

17 May, 2009

1 commit


15 May, 2009

9 commits

  • Now after all users of pc->buf have been converted, remove the 64B buffer
    embedded in each packet command.

    There should be no functional change resulting from this patch.

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • ide-tape used to issue READ POSITION in several places and the
    evaluation of the returned READ POSITION data was done in the
    ->pc_callback. Convert it to use local buffer and move that
    evaluation chunk in the idetape_read_position(). Additionally, fold
    idetape_create_read_position_cmd() into it, too, thus concentrating READ
    POSITION handling in one method only and making all places call that.

    Finally, mv {idetape,ide_tape}_read_position.

    There should be no functional change resulting from this patch.

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • There should be no functional change resulting from this patch.

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • Access the sense buffer through the bio in ->pc_callback method thus
    alleviating the need for the pc->buf pointer.

    There should be no functional change resulting from this patch.

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • This is in preparation of removing ide_atapi_pc. Expose the buffer as an
    argument to ide_queue_pc_tail with later replacing it with local buffer
    or even kmalloc'ed one if needed due to stack usage constraints.

    Also, add the possibility of passing a NULL-ptr buffer for cmds which
    don't transfer data besides the cdb. While at it, switch to local buffer
    in idetape_get_mode_sense_results().

    There should be no functional change resulting from this patch.

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • This is in preparation for removing ide_atapi_pc.

    There should be no functional change resulting from this patch.

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • Now that we have rq->resid_len, use it to account partial completion
    amount during the lifetime of an rq, decrementing it on each successful
    transfer. As a result, get rid of now unused pc->xferred.

    While at it, remove noisy debug call in ide_prep_sense.

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • After the recent struct request cleanups, blk_rq_bytes() is guaranteed
    to be valid and is the current total length of the rq's bio. Use that
    instead of pc->req_xfer in the do_request() path after the command has
    been queued

    The remaining usage of pc->req_xfer now is only until we map the rq to a
    bio.

    While at it:

    - remove local caching of rq completion length in ide_tape_issue_pc()

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     
  • ide-tape had a potential bug for fs requests when preparing the command
    packet: it was writing the transfer length as a number of fixed blocks.
    However, the block layer implies 512 byte blocks and ide-tape can have
    other block sizes so account for that too.

    ide-floppy does this calculation properly with the block size factor
    (floppy->bs_factor).

    Signed-off-by: Borislav Petkov

    Borislav Petkov
     

11 May, 2009

4 commits

  • With recent unification of fields, it's now guaranteed that
    rq->data_len always equals blk_rq_bytes(). Convert all direct users
    to accessors.

    [ Impact: convert direct rq->data_len usages to blk_rq_bytes() ]

    Signed-off-by: Tejun Heo
    Acked-by: Bartlomiej Zolnierkiewicz
    Cc: Borislav Petkov
    Cc: Sergei Shtylyov
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • ide doesn't manipulate request fields anymore and thus all hard and
    their soft equivalents are always equal. Convert all references to
    accessors.

    [ Impact: use pos and nr_sectors accessors ]

    Signed-off-by: Tejun Heo
    Acked-by: Bartlomiej Zolnierkiewicz
    Cc: Borislav Petkov
    Cc: Sergei Shtylyov
    Signed-off-by: Jens Axboe

    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: Tejun Heo
    Cc: James Bottomley
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Borislav Petkov
    Cc: Sergei Shtylyov
    Cc: Mike Miller
    Cc: Eric Moore
    Cc: Alan Stern
    Cc: FUJITA Tomonori
    Cc: Doug Gilbert
    Cc: Mike Miller
    Cc: Eric Moore
    Cc: Darrick J. Wong
    Cc: Pete Zaitcev
    Cc: Boaz Harrosh
    Signed-off-by: Jens Axboe

    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: Tejun Heo
    Acked-by: Borislav Petkov
    Acked-by: Bartlomiej Zolnierkiewicz
    Signed-off-by: Jens Axboe

    Tejun Heo
     

28 Apr, 2009

10 commits

  • 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: Tejun Heo

    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: Tejun Heo

    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: Tejun Heo

    Tejun Heo
     
  • Impact: cleanup

    Read and write init paths are almost identical. Unify them into
    idetape_init_rw().

    Signed-off-by: Tejun Heo

    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: Tejun Heo

    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: Tejun Heo
    Cc: Jens Axboe

    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: Tejun Heo

    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: Tejun Heo
    Cc: Jens Axboe

    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: Tejun Heo

    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: Tejun Heo

    Tejun Heo