1. 21 4月, 2017 19 次提交
  2. 20 4月, 2017 4 次提交
    • R
      ligtnvm: fix double blk_put_queue on same queue · 75ba4ada
      Rakesh Pandit 提交于
      On an error path in NVM_DEV_CREATE ioctl blk_put_queue is being called
      twice: one via blk_cleanup_queue and another via put_disk.  Straight fix
      seems to remove queue pointer so that disk_release never ends up caling
      blk_put_queue again.
      
        [  391.808827] WARNING: CPU: 1 PID: 1250 at lib/refcount.c:128 refcount_sub_and_test+0x70/0x80
        [  391.808830] refcount_t: underflow; use-after-free.
        [ 391.808832] Modules linked in: nf_conntrack_netbios_ns............
        [  391.809052] CPU: 1 PID: 1250 Comm: nvme Not tainted.........
        [  391.809057] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
                   BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014
        [  391.809060] Call Trace:
        [  391.809079]  dump_stack+0x63/0x86
        [  391.809094]  __warn+0xcb/0xf0
        [  391.809103]  warn_slowpath_fmt+0x5f/0x80
        [  391.809118]  refcount_sub_and_test+0x70/0x80
        [  391.809125]  refcount_dec_and_test+0x11/0x20
        [  391.809136]  kobject_put+0x1f/0x60
        [  391.809149]  blk_put_queue+0x15/0x20
        [  391.809159]  disk_release+0xae/0xf0
        [  391.809172]  device_release+0x32/0x90
        [  391.809184]  kobject_release+0x6a/0x170
        [  391.809196]  kobject_put+0x2f/0x60
        [  391.809206]  put_disk+0x17/0x20
        [  391.809219]  nvm_ioctl_dev_create.isra.16+0x897/0xa30
        [  391.809236]  nvm_ctl_ioctl+0x23c/0x4c0
        [  391.809248]  do_vfs_ioctl+0xa3/0x5f0
        [  391.809258]  SyS_ioctl+0x79/0x90
        [  391.809271]  entry_SYSCALL_64_fastpath+0x1a/0xa9
        [  391.809280] RIP: 0033:0x7f5d3ef363c7
        [  391.809286] RSP: 002b:00007ffc72ed8d78 EFLAGS: 00000206 ORIG_RAX: 0000000000000010
        [  391.809296] RAX: ffffffffffffffda RBX: 00007ffc72edb552 RCX: 00007f5d3ef363c7
        [  391.809301] RDX: 00007ffc72ed8d90 RSI: 0000000040804c22 RDI: 0000000000000003
        [  391.809306] RBP: 0000000000000001 R08: 0000000000000020 R09: 0000000000000001
        [  391.809311] R10: 000000000000053f R11: 0000000000000206 R12: 0000000000000000
        [  391.809316] R13: 0000000000000000 R14: 00007ffc72edb58d R15: 00007ffc72edb581
      Signed-off-by: NRakesh Pandit <rakesh@tuxera.com>
      Reviewed-by: NMatias Bjørling <matias@cnexlabs.com>
      Fixes: 7d1ef2f4 "lightnvm: fix cleanup order of disk on init error"
      Signed-off-by: NJens Axboe <axboe@fb.com>
      75ba4ada
    • B
      lightnvm: Use blk_init_request_from_bio() instead of open-coding it · 9460e280
      Bart Van Assche 提交于
      This patch changes the behavior of the lightnvm driver as follows:
      * REQ_FAILFAST_MASK is set for read-ahead requests.
      * If no I/O priority has been set in the bio, the I/O priority is
        copied from the I/O context.
      * The rq_disk member is initialized if bio->bi_bdev != NULL.
      * The bio sector offset is copied into req->__sector instead of
        retaining the value -1 set by blk_mq_alloc_request().
      * req->errors is initialized to zero.
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Matias Bjørling <m@bjorling.me>
      Cc: Adam Manzanares <adam.manzanares@wdc.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      9460e280
    • B
      null_blk: Use blk_init_request_from_bio() instead of open-coding it · 2644a3cc
      Bart Van Assche 提交于
      This patch changes the behavior of the null_blk driver for the
      LightNVM mode as follows:
      * REQ_FAILFAST_MASK is set for read-ahead requests.
      * If no I/O priority has been set in the bio, the I/O priority is
        copied from the I/O context.
      * The rq_disk member is initialized if bio->bi_bdev != NULL.
      * req->errors is initialized to zero.
      Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Matias Bjørling <m@bjorling.me>
      Cc: Adam Manzanares <adam.manzanares@wdc.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      2644a3cc
    • A
      lightnvm: assume 64-bit lba numbers · ef697902
      Arnd Bergmann 提交于
      The driver uses both u64 and sector_t to refer to offsets, and assigns between the
      two. This causes one harmless warning when sector_t is 32-bit:
      
      drivers/lightnvm/pblk-rb.c: In function 'pblk_rb_write_entry_gc':
      include/linux/lightnvm.h:215:20: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
      drivers/lightnvm/pblk-rb.c:324:22: note: in expansion of macro 'ADDR_EMPTY'
      
      As the driver is already doing this inconsistently, changing the type
      won't make it worse and is an easy way to avoid the warning.
      
      Fixes: a4bd217b ("lightnvm: physical block device (pblk) target")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      ef697902
  3. 19 4月, 2017 2 次提交
  4. 18 4月, 2017 1 次提交
  5. 17 4月, 2017 14 次提交
    • J
      nbd: add a flag to destroy an nbd device on disconnect · a2c97909
      Josef Bacik 提交于
      For ease of management it would be nice for users to specify that the
      device node for a nbd device is destroyed once it is disconnected and
      there are no more users.  Add a client flag and enable this operation to
      happen.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      a2c97909
    • J
      nbd: add device refcounting · c6a4759e
      Josef Bacik 提交于
      In order to support deleting the device on disconnect we need to
      refcount the actual nbd_device struct.  So add the refcounting framework
      and change how we free the normal devices at rmmod time so we can catch
      reference leaks.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      c6a4759e
    • J
      nbd: add a status netlink command · 47d902b9
      Josef Bacik 提交于
      Allow users to query the status of existing nbd devices.  Right now this
      only returns whether or not the device is connected, but could be
      extended in the future to include more information.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      47d902b9
    • J
      nbd: handle dead connections · 560bc4b3
      Josef Bacik 提交于
      Sometimes we like to upgrade our server without making all of our
      clients freak out and reconnect.  This patch provides a way to specify a
      dead connection timeout to allow us to pause all requests and wait for
      new connections to be opened.  With this in place I can take down the
      nbd server for less than the dead connection timeout time and bring it
      back up and everything resumes gracefully.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      560bc4b3
    • J
      nbd: only clear the queue on device teardown · 2516ab15
      Josef Bacik 提交于
      When running a disconnect torture test I noticed that sometimes we would
      crash with a negative ref count on our queue.  This was because we were
      ending the same request twice.  Turns out we were racing with
      NBD_CLEAR_SOCK clearing the requests as well as the teardown of the
      device clearing the requests.  So instead make the ioctl only shutdown
      the sockets and make it so that we only ever run nbd_clear_que from the
      device teardown.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      2516ab15
    • J
      nbd: multicast dead link notifications · 799f9a38
      Josef Bacik 提交于
      Provide a mechanism to notify userspace that there's been a link problem
      on a NBD device.  This will allow userspace to re-establish a connection
      and provide the new socket to the device without disrupting the device.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      799f9a38
    • J
      nbd: add a reconfigure netlink command · b7aa3d39
      Josef Bacik 提交于
      We want to be able to reconnect dead connections to existing block
      devices, so add a reconfigure netlink command.  We will also allow users
      to change their timeout on the fly, but everything else will require a
      disconnect and reconnect.  You won't be able to add more connections
      either, simply replace dead connections with new more lively
      connections.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      b7aa3d39
    • J
      nbd: add a basic netlink interface · e46c7287
      Josef Bacik 提交于
      The existing ioctl interface for configuring NBD devices is a bit
      cumbersome and hard to extend.  The other problem is we leave a
      userspace app sitting in it's syscall until the device disconnects,
      which is less than ideal.
      
      This patch introduces a netlink interface for adding and disconnecting
      nbd devices.  This has the benefits of being easily extendable without
      breaking older userspace applications, and allows us to configure a nbd
      device without leaving a userspace app sitting waiting for the device to
      disconnect.
      
      With this interface we also gain the ability to configure more devices
      than are preallocated at insmod time.  We also have gained the ability
      to not specify a particular device and be provided one for us so that
      userspace doesn't need to find a free device to configure.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      e46c7287
    • J
      nbd: stop using the bdev everywhere · 29eaadc0
      Josef Bacik 提交于
      In preparation for the upcoming netlink interface we need to not rely on
      already having the bdev for the NBD device we are doing operations on.
      Instead of passing the bdev around, just use it in places where we know
      we already have the bdev.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      29eaadc0
    • J
      nbd: separate out the config information · 5ea8d108
      Josef Bacik 提交于
      In order to properly refcount the various aspects of a NBD device we
      need to separate out the configuration elements of the nbd device.  The
      configuration of a NBD device has a different lifetime from the actual
      device, so it doesn't make sense to bundle these two concepts.  Add a
      config_refs to keep track of the configuration structure, that way we
      can be sure that we never access it when we've torn down the device.
      Add a new nbd_config structure to hold all of the transient
      configuration information.  Finally create this when we open the device
      so that it is in place when we start to configure the device.  This has
      a nice side-effect of fixing a long standing problem where you could end
      up with a half-configured nbd device that needed to be "disconnected" in
      order to be usable again.  Now once we close our device the
      configuration will be discarded.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      5ea8d108
    • J
      nbd: handle single path failures gracefully · f3733247
      Josef Bacik 提交于
      Currently if we have multiple connections and one of them goes down we will tear
      down the whole device.  However there's no reason we need to do this as we
      could have other connections that are working fine.  Deal with this by keeping
      track of the state of the different connections, and if we lose one we mark it
      as dead and send all IO destined for that socket to one of the other healthy
      sockets.  Any outstanding requests that were on the dead socket will timeout and
      be re-submitted properly.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      f3733247
    • J
      nbd: put socket in error cases · 9b1355d5
      Josef Bacik 提交于
      When adding a new socket we look it up and then try to add it to our
      configuration.  If any of those steps fail we need to make sure we put
      the socket so we don't leak them.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      9b1355d5
    • D
      lightnvm: fix some error code in pblk-init.c · 1c6286f2
      Dan Carpenter 提交于
      There were a bunch of places in pblk_lines_init() where we didn't set an
      error code.  And in pblk_writer_init() we accidentally return 1 instead
      of a correct error code, which would result in a Oops later.
      
      Fixes: 11a5d6fdf919 ("lightnvm: physical block device (pblk) target")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMatias Bjørling <matias@cnexlabs.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      1c6286f2
    • D
      lightnvm: fix some WARN() messages · 2a79efd8
      Dan Carpenter 提交于
      WARN_ON() takes a condition, not an error message.  I slightly tweaked
      some conditions so hopefully it's more clear.
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMatias Bjørling <matias@cnexlabs.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      2a79efd8