28 Jan, 2015

1 commit

  • commit 046ba64285a4389ae5e9a7dfa253c6bff3d7c341 upstream.

    This patch drops the arbitrary maximum I/O size limit in sbc_parse_cdb(),
    which currently for fabric_max_sectors is hardcoded to 8192 (4 MB for 512
    byte sector devices), and for hw_max_sectors is a backend driver dependent
    value.

    This limit is problematic because Linux initiators have only recently
    started to honor block limits MAXIMUM TRANSFER LENGTH, and other non-Linux
    based initiators (eg: MSFT Fibre Channel) can also generate I/Os larger
    than 4 MB in size.

    Currently when this happens, the following message will appear on the
    target resulting in I/Os being returned with non recoverable status:

    SCSI OP 28h with too big sectors 16384 exceeds fabric_max_sectors: 8192

    Instead, drop both [fabric,hw]_max_sector checks in sbc_parse_cdb(),
    and convert the existing hw_max_sectors into a purely informational
    attribute used to represent the granuality that backend driver and/or
    subsystem code is splitting I/Os upon.

    Also, update FILEIO with an explicit FD_MAX_BYTES check in fd_execute_rw()
    to deal with the one special iovec limitiation case.

    v2 changes:
    - Drop hw_max_sectors check in sbc_parse_cdb()

    Reported-by: Lance Gropper
    Reported-by: Stefan Priebe
    Cc: Christoph Hellwig
    Cc: Martin K. Petersen
    Cc: Roland Dreier
    Signed-off-by: Nicholas Bellinger
    Signed-off-by: Greg Kroah-Hartman

    Nicholas Bellinger
     

08 Oct, 2014

1 commit

  • Both of the file target's calls to vfs_fsync_range() got the end offset
    off by one. The range is inclusive, not exclusive. It would sync a bit
    more data than was required.

    The sync path already tested the length of the range and fell back to
    LLONG_MAX so I copied that pattern in the rw path.

    This is untested. I found the errors by inspection while following other
    code.

    Signed-off-by: Zach Brown
    Signed-off-by: Nicholas Bellinger

    Zach Brown
     

18 Sep, 2014

1 commit


07 Apr, 2014

1 commit


01 Feb, 2014

1 commit

  • Pull SCSI target updates from Nicholas Bellinger:
    "The highlights this round include:

    - add support for SCSI Referrals (Hannes)
    - add support for T10 DIF into target core (nab + mkp)
    - add support for T10 DIF emulation in FILEIO + RAMDISK backends (Sagi + nab)
    - add support for T10 DIF -> bio_integrity passthrough in IBLOCK backend (nab)
    - prep changes to iser-target for >= v3.15 T10 DIF support (Sagi)
    - add support for qla2xxx N_Port ID Virtualization - NPIV (Saurav + Quinn)
    - allow percpu_ida_alloc() to receive task state bitmask (Kent)
    - fix >= v3.12 iscsi-target session reset hung task regression (nab)
    - fix >= v3.13 percpu_ref se_lun->lun_ref_active race (nab)
    - fix a long-standing network portal creation race (Andy)"

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (51 commits)
    target: Fix percpu_ref_put race in transport_lun_remove_cmd
    target/iscsi: Fix network portal creation race
    target: Report bad sector in sense data for DIF errors
    iscsi-target: Convert gfp_t parameter to task state bitmask
    iscsi-target: Fix connection reset hang with percpu_ida_alloc
    percpu_ida: Make percpu_ida_alloc + callers accept task state bitmask
    iscsi-target: Pre-allocate more tags to avoid ack starvation
    qla2xxx: Configure NPIV fc_vport via tcm_qla2xxx_npiv_make_lport
    qla2xxx: Enhancements to enable NPIV support for QLOGIC ISPs with TCM/LIO.
    qla2xxx: Fix scsi_host leak on qlt_lport_register callback failure
    IB/isert: pass scatterlist instead of cmd to fast_reg_mr routine
    IB/isert: Move fastreg descriptor creation to a function
    IB/isert: Avoid frwr notation, user fastreg
    IB/isert: seperate connection protection domains and dma MRs
    tcm_loop: Enable DIF/DIX modes in SCSI host LLD
    target/rd: Add DIF protection into rd_execute_rw
    target/rd: Add support for protection SGL setup + release
    target/rd: Refactor rd_build_device_space + rd_release_device_space
    target/file: Add DIF protection support to fd_execute_rw
    target/file: Add DIF protection init/format support
    ...

    Linus Torvalds
     

19 Jan, 2014

2 commits

  • This patch adds support for DIF protection into fd_execute_rw() code
    for WRITE/READ I/O using sbc_dif_verify_[write,read]() logic.

    It adds fd_do_prot_rw() for handling interface with FILEIO PI, and
    uses a locally allocated fd_prot->prot_buf + fd_prot->prot_sg for
    interacting with SBC DIF verify emulation code.

    Cc: Martin K. Petersen
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Sagi Grimberg
    Cc: Or Gerlitz
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     
  • This patch adds support for DIF protection init/format support into
    the FILEIO backend.

    It involves using a seperate $FILE.protection for storing PI that is
    opened via fd_init_prot() using the common pi_prot_type attribute.
    The actual formatting of the protection is done via fd_format_prot()
    using the common pi_prot_format attribute, that will populate the
    initial PI data based upon the currently configured pi_prot_type.

    Based on original FILEIO code from Sagi.

    v1 changes:
    - Fix sparse warnings in fd_init_format_buf (Fengguang)

    Cc: Martin K. Petersen
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Sagi Grimberg
    Cc: Or Gerlitz
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

19 Dec, 2013

1 commit

  • This patch allows FILEIO to update hw_max_sectors based on the current
    max_bytes_per_io. This is required because vfs_[writev,readv]() can accept
    a maximum of 2048 iovecs per call, so the enforced hw_max_sectors really
    needs to be calculated based on block_size.

    This addresses a >= v3.5 bug where block_size=512 was rejecting > 1M
    sized I/O requests, because FD_MAX_SECTORS was hardcoded to 2048 for
    the block_size=4096 case.

    (v2: Use max_bytes_per_io instead of ->update_hw_max_sectors)

    Reported-by: Henrik Goldman
    Cc: #3.5+
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

21 Nov, 2013

1 commit


11 Sep, 2013

1 commit


10 Sep, 2013

1 commit

  • COMPARE_AND_WRITE expects to be able to send down a DMA_FROM_DEVICE
    to obtain the necessary READ payload for comparision against the
    first half of the WRITE payload containing the verify user data.

    Currently virtual backends expect to internally reference SGLs,
    SGL nents, and data_direction, so change IBLOCK, FILEIO and RD
    sbc_ops->execute_rw() to accept this values as function parameters.

    Also add default sbc_execute_rw() handler for the typical case for
    cmd->execute_rw() submission using cmd->t_data_sg, cmd->t_data_nents,
    and cmd->data_direction).

    v2 Changes:
    - Add SCF_COMPARE_AND_WRITE command flag
    - Use sbc_execute_rw() for normal cmd->execute_rw() submission
    with expected se_cmd members.

    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Martin Petersen
    Cc: Chris Mason
    Cc: James Bottomley
    Cc: Nicholas Bellinger
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

13 Aug, 2013

1 commit

  • The usage of strict_strtoul() and strict_strtoull() is not preferred,
    because strict_strtoul() and strict_strtoull() are obsolete. Thus,
    kstrtoul() and kstrtoull() should be used.

    v2: Fix incorrect return in ft_add_tpg (Fengguang)

    Signed-off-by: Jingoo Han
    Signed-off-by: Nicholas Bellinger

    Jingoo Han
     

31 May, 2013

1 commit

  • This patch fixes a bug where FILEIO was incorrectly reporting the number
    of logical blocks (+ 1) when using non struct block_device export mode.

    It changes fd_get_blocks() to follow all other backend ->get_blocks() cases,
    and reduces the calculated dev_size by one dev->dev_attrib.block_size
    number of bytes, and also fixes initial fd_block_size assignment at
    fd_configure_device() time introduced in commit 0fd97ccf4.

    Reported-by: Wenchao Xia
    Reported-by: Badari Pulavarty
    Tested-by: Badari Pulavarty
    Cc: stable@vger.kernel.org
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

04 May, 2013

1 commit

  • We can still see the error reported in

    https://patchwork.kernel.org/patch/2338981/

    when using fileio backed by a block device.

    I'm assuming this will get us past that error (from sbc_parse_cdb),
    and also assuming it's OK to have our max_sectors be larger than
    the block's queue max hw sectors?

    Reported-by: Eric Harney
    Signed-off-by: Andy Grover
    Cc:
    Signed-off-by: Nicholas Bellinger

    Andy Grover
     

25 Apr, 2013

5 commits

  • Set is_nonrot attribute according to the block queue if the backend
    device is a block device.

    Signed-off-by: Asias He
    Signed-off-by: Nicholas Bellinger

    Asias He
     
  • iblock_execute_unmap() and fd_execute_unmap share a lot of code.
    Add sbc_execute_unmap() helper to remove duplicated code for
    iblock_execute_unmap() and fd_execute_unmap().

    Cc: Christoph Hellwig
    Cc: Martin K. Petersen
    Cc: Nicholas Bellinger
    Signed-off-by: Asias He
    Signed-off-by: Nicholas Bellinger

    Asias He
     
  • Add helper fd_do_unmap() to remove duplicated code in
    fd_execute_write_same_unmap() and fd_execute_unmap().

    Cc: Christoph Hellwig
    Cc: Martin K. Petersen
    Cc: Nicholas Bellinger
    Signed-off-by: Asias He
    Signed-off-by: Nicholas Bellinger

    Asias He
     
  • This patch adds support for emulation of UNMAP within
    fd_execute_unmap() backend code.

    If the FILEIO backend is normal file, the emulation uses fallocate to
    punch hole to reclaim the free space used by the file. If the FILEIO
    backend is block device, the emulation uses blkdev_issue_discard().

    Cc: Christoph Hellwig
    Cc: Martin K. Petersen
    Cc: Nicholas Bellinger
    Signed-off-by: Asias He
    Signed-off-by: Nicholas Bellinger

    Asias He
     
  • This patch adds support for emulation of WRITE_SAME w/ UNMAP=1 within
    fd_execute_write_same_unmap() backend code.

    If the FILEIO backend is normal file, the emulation uses fallocate to
    punch hole to reclaim the free space used by the file. If the FILEIO
    backend is block device, the emulation uses blkdev_issue_discard().

    Tested with 512, 1k, 2k, and 4k block_sizes.

    Changes in v2:
    - Set the various dev->dev_attrib.*unmap* values (nab)

    Cc: Christoph Hellwig
    Cc: Martin K. Petersen
    Cc: Nicholas Bellinger
    Signed-off-by: Asias He
    Signed-off-by: Nicholas Bellinger

    Asias He
     

03 Mar, 2013

1 commit

  • Pull SCSI target patches from Nicholas Bellinger:
    "Here are the remaining target-pending patches for v3.9-rc1.

    The most important one here is the immediate queue starvation
    regression fix for iscsi-target, which addresses a bug that's
    effecting v3.5+ kernels under heavy sustained READ only workloads.
    Thanks alot to Benjamin Estrabaud for helping to track this down!

    Also included is a pSCSI exception bugfix from Asias, along with a
    handful of other minor changes. Both bugfixes are CC'ed to stable."

    * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending:
    target/pscsi: Rename sg_num to nr_vecs in pscsi_get_bio()
    target/pscsi: Fix page increment
    target/pscsi: Drop unnecessary NULL assignment to bio->bi_next
    target: Add __exit annotation for module_exit functions
    iscsi-target: Fix immediate queue starvation regression with DATAIN

    Linus Torvalds
     

28 Feb, 2013

1 commit


27 Feb, 2013

1 commit

  • Pull vfs pile (part one) from Al Viro:
    "Assorted stuff - cleaning namei.c up a bit, fixing ->d_name/->d_parent
    locking violations, etc.

    The most visible changes here are death of FS_REVAL_DOT (replaced with
    "has ->d_weak_revalidate()") and a new helper getting from struct file
    to inode. Some bits of preparation to xattr method interface changes.

    Misc patches by various people sent this cycle *and* ocfs2 fixes from
    several cycles ago that should've been upstream right then.

    PS: the next vfs pile will be xattr stuff."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits)
    saner proc_get_inode() calling conventions
    proc: avoid extra pde_put() in proc_fill_super()
    fs: change return values from -EACCES to -EPERM
    fs/exec.c: make bprm_mm_init() static
    ocfs2/dlm: use GFP_ATOMIC inside a spin_lock
    ocfs2: fix possible use-after-free with AIO
    ocfs2: Fix oops in ocfs2_fast_symlink_readpage() code path
    get_empty_filp()/alloc_file() leave both ->f_pos and ->f_version zero
    target: writev() on single-element vector is pointless
    export kernel_write(), convert open-coded instances
    fs: encode_fh: return FILEID_INVALID if invalid fid_type
    kill f_vfsmnt
    vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op
    nfsd: handle vfs_getattr errors in acl protocol
    switch vfs_getattr() to struct path
    default SET_PERSONALITY() in linux/elf.h
    ceph: prepopulate inodes only when request is aborted
    d_hash_and_lookup(): export, switch open-coded instances
    9p: switch v9fs_set_create_acl() to inode+fid, do it before d_instantiate()
    9p: split dropping the acls from v9fs_set_create_acl()
    ...

    Linus Torvalds
     

24 Feb, 2013

1 commit


23 Feb, 2013

1 commit


21 Feb, 2013

1 commit

  • This patch adds support for emulation of WRITE_SAME w/ UNMAP=0 within
    fd_execute_write_same() backend code.

    The emulation uses vfs_writev() to submit a locally populated buffer
    from the received WRITE_SAME scatterlist block for duplication, and by
    default enforces a limit of max_write_same_len=0x1000 (8192) sectors up
    to the limit of 1024 iovec entries for the single call to vfs_writev().

    It also sets max_write_same_len to the operational default at setup ->
    fd_configure_device() time.

    Tested with 512, 1k, 2k, and 4k block_sizes.

    (asias: convert to vzalloc)

    Cc: Martin K. Petersen
    Cc: Christoph Hellwig
    Cc: Asias He
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

06 Dec, 2012

2 commits


28 Nov, 2012

1 commit


07 Nov, 2012

5 commits

  • Pass the sense reason as an explicit return value from the I/O submission
    path instead of storing it in struct se_cmd and using negative return
    values. This cleans up a lot of the code pathes, and with the sparse
    annotations for the new sense_reason_t type allows for much better
    error checking.

    (nab: Convert spc_emulate_modesense + spc_emulate_modeselect to use
    sense_reason_t with Roland's MODE SELECT changes)

    Signed-off-by: Christoph Hellwig
    Cc: Roland Dreier
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Now that the reservations and ALUA code have been cleaned up there is no need
    for the get_device_rev method, as we only need the standards revision in the
    inquiry data, where we can hardcode it.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • These really are sbc_ops, so name them correctly.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Simplify the code a lot by killing the superflous struct se_subsystem_dev.
    Instead se_device is allocated early on by the backend driver, which allocates
    it as part of its own per-device structure, borrowing the scheme that is for
    example used for inode allocation.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     

03 Oct, 2012

1 commit

  • This patch re-adds the ability to optionally run in buffered FILEIO mode
    (eg: w/o O_DSYNC) for device backends in order to once again use the
    Linux buffered cache as a write-back storage mechanism.

    This logic was originally dropped with mainline v3.5-rc commit:

    commit a4dff3043c231d57f982af635c9d2192ee40e5ae
    Author: Nicholas Bellinger
    Date: Wed May 30 16:25:41 2012 -0700

    target/file: Use O_DSYNC by default for FILEIO backends

    This difference with this patch is that fd_create_virtdevice() now
    forces the explicit setting of emulate_write_cache=1 when buffered FILEIO
    operation has been enabled.

    (v2: Switch to FDBD_HAS_BUFFERED_IO_WCE + add more detailed
    comment as requested by hch)

    Reported-by: Ferry
    Cc: Christoph Hellwig
    Cc:
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

18 Sep, 2012

1 commit

  • This patch drops se_subsystem_api->[write_cache,fua_write]_emulated flags
    set by viritual FILEIO/IBLOCK/RD_MCP backend drivers in favor of explict
    TRANSPORT_PLUGIN_PHBA_PDEV checks to know when to fail if userspace is
    attempting to set virtual emulation bits for an pSCSI (passthrough)
    backend device.

    Reported-by: Christoph Hellwig
    Cc: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Nicholas Bellinger
     

02 Aug, 2012

1 commit

  • Pull second vfs pile from Al Viro:
    "The stuff in there: fsfreeze deadlock fixes by Jan (essentially, the
    deadlock reproduced by xfstests 068), symlink and hardlink restriction
    patches, plus assorted cleanups and fixes.

    Note that another fsfreeze deadlock (emergency thaw one) is *not*
    dealt with - the series by Fernando conflicts a lot with Jan's, breaks
    userland ABI (FIFREEZE semantics gets changed) and trades the deadlock
    for massive vfsmount leak; this is going to be handled next cycle.
    There probably will be another pull request, but that stuff won't be
    in it."

    Fix up trivial conflicts due to unrelated changes next to each other in
    drivers/{staging/gdm72xx/usb_boot.c, usb/gadget/storage_common.c}

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (54 commits)
    delousing target_core_file a bit
    Documentation: Correct s_umount state for freeze_fs/unfreeze_fs
    fs: Remove old freezing mechanism
    ext2: Implement freezing
    btrfs: Convert to new freezing mechanism
    nilfs2: Convert to new freezing mechanism
    ntfs: Convert to new freezing mechanism
    fuse: Convert to new freezing mechanism
    gfs2: Convert to new freezing mechanism
    ocfs2: Convert to new freezing mechanism
    xfs: Convert to new freezing code
    ext4: Convert to new freezing mechanism
    fs: Protect write paths by sb_start_write - sb_end_write
    fs: Skip atime update on frozen filesystem
    fs: Add freezing handling to mnt_want_write() / mnt_drop_write()
    fs: Improve filesystem freezing handling
    switch the protection of percpu_counter list to spinlock
    nfsd: Push mnt_want_write() outside of i_mutex
    btrfs: Push mnt_want_write() outside of i_mutex
    fat: Push mnt_want_write() outside of i_mutex
    ...

    Linus Torvalds
     

01 Aug, 2012

1 commit

  • * set_fs(KERNEL_DS) + getname() is probably the weirdest implementation
    of strdup() I've seen. Especially since they don't to copy it at all...
    * filp_open() never returns NULL; it's ERR_PTR(-E...) on failure.
    * file->f_dentry is never going to be NULL, TYVM.
    * match_strdup() + snprintf() + kfree() is a bloody weird way to spell
    match_strlcpy().

    Pox on cargo-cult programmers...

    Signed-off-by: Al Viro

    Al Viro
     

17 Jul, 2012

3 commits

  • Add spc_ops->execute_sync_cache() caller for ->execute_cmd() setup,
    and update IBLOCK + FILEIO backends to use it.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Remove the execute_cmd method in struct se_subsystem_api, and always use the
    one directly in struct se_cmd. To make life simpler for SBC virtual backends
    a struct spc_ops that is passed to sbc_parse_cmd is added. For now it
    only contains an execute_rw member, but more will follow with the subsequent
    commits.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig
     
  • Instead of trying to handle all SCSI command sets in one function
    (transport_generic_cmd_sequencer) call out to the backend driver to perform
    this functionality. For pSCSI a copy of the existing code is used, but for
    all virtual backends we can use a new parse_sbc_cdb helper is used to
    provide a simple SBC emulation.

    For now this setups means a fair amount of duplication between pSCSI and the
    SBC library, but patches later in this series will sort out that problem.

    (nab: Fix up build failure in target_core_pscsi.c)

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Nicholas Bellinger

    Christoph Hellwig