1. 25 3月, 2017 4 次提交
    • R
      nbd: replace kill_bdev() with __invalidate_device() · abbbdf12
      Ratna Manoj Bolla 提交于
      When a filesystem is mounted on a nbd device and on a disconnect, because
      of kill_bdev(), and resetting bdev size to zero, buffer_head mappings are
      getting destroyed under mounted filesystem.
      
      After a bdev size reset(i.e bdev->bd_inode->i_size = 0) on a disconnect,
      followed by a sys_umount(),
              generic_shutdown_super()->...
              ->__sync_blockdev()->...
              -blkdev_writepages()->...
              ->do_invalidatepage()->...
              -discard_buffer()   is discarding superblock buffer_head assumed
      to be in mapped state by ext4_commit_super().
      
      [mlin: ported to 4.11-rc2]
      Signed-off-by: Ratna Manoj Bolla <manoj.br@gmail.com
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      abbbdf12
    • J
      nbd: set queue timeout properly · f8586855
      Josef Bacik 提交于
      We can't just set the timeout on the tagset, we have to set it on the
      queue as it would have been setup already at this point.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      f8586855
    • J
      nbd: set rq->errors to actual error code · c103b4da
      Josef Bacik 提交于
      We've been relying on the block layer to assume rq->errors being set
      translates into -EIO.  I noticed in testing that sometimes this isn't
      true, and really there's not much of a reason to have a counter instead
      of just using -EIO.  So set it properly so we don't leak random numbers
      to unsuspecting victims.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      c103b4da
    • J
      nbd: handle ERESTARTSYS properly · 9dd5d3ab
      Josef Bacik 提交于
      We can submit IO in a processes context, which means there can be
      pending signals.  This isn't a fatal error for NBD, but it does require
      some finesse.  If the signal happens before we transmit anything then we
      are ok, just requeue the request and carry on.  However if we've done a
      partial transmit we can't allow anything else to be transmitted on this
      socket until we transmit the remaining part of the request.  Deal with
      this by keeping track of how much we've sent for the current request,
      and if we get an ERESTARTSYS during any part of our transmission save
      the state of that request and requeue the IO.  If anybody tries to
      submit a request that isn't our pending request then requeue that
      request until we are able to service the one that is pending.
      Signed-off-by: NJosef Bacik <jbacik@fb.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      9dd5d3ab
  2. 02 3月, 2017 1 次提交
  3. 22 2月, 2017 3 次提交
  4. 02 2月, 2017 2 次提交
  5. 01 2月, 2017 3 次提交
  6. 20 1月, 2017 1 次提交
  7. 11 1月, 2017 1 次提交
  8. 27 12月, 2016 2 次提交
  9. 25 12月, 2016 1 次提交
  10. 09 12月, 2016 2 次提交
  11. 04 12月, 2016 1 次提交
    • J
      nbd: fix 64-bit division · e88f72cb
      Jens Axboe 提交于
      We have this:
      
      ERROR: "__aeabi_ldivmod" [drivers/block/nbd.ko] undefined!
      ERROR: "__divdi3" [drivers/block/nbd.ko] undefined!
      nbd.c:(.text+0x247c72): undefined reference to `__divdi3'
      
      due to a recent commit, that did 64-bit division. Use the proper
      divider function so that 32-bit compiles don't break.
      
      Fixes: ef77b515 ("nbd: use loff_t for blocksize and nbd_set_size args")
      Signed-off-by: NJens Axboe <axboe@fb.com>
      e88f72cb
  12. 03 12月, 2016 1 次提交
  13. 23 11月, 2016 2 次提交
  14. 18 11月, 2016 1 次提交
  15. 07 11月, 2016 1 次提交
  16. 25 10月, 2016 1 次提交
  17. 24 9月, 2016 1 次提交
  18. 09 9月, 2016 4 次提交
  19. 05 8月, 2016 1 次提交
    • V
      nbd: fix race in ioctl · 97240963
      Vegard Nossum 提交于
      Quentin ran into this bug:
      
      WARNING: CPU: 64 PID: 10085 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x65/0x80
      sysfs: cannot create duplicate filename '/devices/virtual/block/nbd3/pid'
      Modules linked in: nbd
      CPU: 64 PID: 10085 Comm: qemu-nbd Tainted: G      D         4.6.0+ #7
       0000000000000000 ffff8820330bba68 ffffffff814b8791 ffff8820330bbac8
       0000000000000000 ffff8820330bbab8 ffffffff810d04ab ffff8820330bbaa8
       0000001f00000296 0000000000017681 ffff8810380bf000 ffffffffa0001790
      Call Trace:
       [<ffffffff814b8791>] dump_stack+0x4d/0x6c
       [<ffffffff810d04ab>] __warn+0xdb/0x100
       [<ffffffff810d0574>] warn_slowpath_fmt+0x44/0x50
       [<ffffffff81218c65>] sysfs_warn_dup+0x65/0x80
       [<ffffffff81218a02>] sysfs_add_file_mode_ns+0x172/0x180
       [<ffffffff81218a35>] sysfs_create_file_ns+0x25/0x30
       [<ffffffff81594a76>] device_create_file+0x36/0x90
       [<ffffffffa0000e8d>] __nbd_ioctl+0x32d/0x9b0 [nbd]
       [<ffffffff814cc8e8>] ? find_next_bit+0x18/0x20
       [<ffffffff810f7c29>] ? select_idle_sibling+0xe9/0x120
       [<ffffffff810f6cd7>] ? __enqueue_entity+0x67/0x70
       [<ffffffff810f9bf0>] ? enqueue_task_fair+0x630/0xe20
       [<ffffffff810efa76>] ? resched_curr+0x36/0x70
       [<ffffffff810f0078>] ? check_preempt_curr+0x78/0x90
       [<ffffffff810f00a2>] ? ttwu_do_wakeup+0x12/0x80
       [<ffffffff810f01b1>] ? ttwu_do_activate.constprop.86+0x61/0x70
       [<ffffffff810f0c15>] ? try_to_wake_up+0x185/0x2d0
       [<ffffffff810f0d6d>] ? default_wake_function+0xd/0x10
       [<ffffffff81105471>] ? autoremove_wake_function+0x11/0x40
       [<ffffffffa0001577>] nbd_ioctl+0x67/0x94 [nbd]
       [<ffffffff814ac0fd>] blkdev_ioctl+0x14d/0x940
       [<ffffffff811b0da2>] ? put_pipe_info+0x22/0x60
       [<ffffffff811d96cc>] block_ioctl+0x3c/0x40
       [<ffffffff811ba08d>] do_vfs_ioctl+0x8d/0x5e0
       [<ffffffff811aa329>] ? ____fput+0x9/0x10
       [<ffffffff810e9092>] ? task_work_run+0x72/0x90
       [<ffffffff811ba627>] SyS_ioctl+0x47/0x80
       [<ffffffff8185f5df>] entry_SYSCALL_64_fastpath+0x17/0x93
      ---[ end trace 7899b295e4f850c8 ]---
      
      It seems fairly obvious that device_create_file() is not being protected
      from being run concurrently on the same nbd.
      
      Quentin found the following relevant commits:
      
      1a2ad211 nbd: add locking to nbd_ioctl
      90b8f282 [PATCH] end of methods switch: remove the old ones
      d4430d62 [PATCH] beginning of methods conversion
      08f85851 [PATCH] move block_device_operations to blkdev.h
      
      It would seem that the race was introduced in the process of moving nbd
      from BKL to unlocked ioctls.
      
      By setting nbd->task_recv while the mutex is held, we can prevent other
      processes from running concurrently (since nbd->task_recv is also checked
      while the mutex is held).
      Reported-and-tested-by: NQuentin Casasnovas <quentin.casasnovas@oracle.com>
      Cc: Markus Pargmann <mpa@pengutronix.de>
      Cc: Paul Clements <paul.clements@steeleye.com>
      Cc: Pavel Machek <pavel@suse.cz>
      Cc: Jens Axboe <axboe@fb.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NVegard Nossum <vegard.nossum@oracle.com>
      Signed-off-by: NJens Axboe <axboe@fb.com>
      97240963
  20. 08 6月, 2016 3 次提交
  21. 13 4月, 2016 1 次提交
  22. 05 3月, 2016 1 次提交
    • A
      nbd: use correct div_s64 helper · 5e454c67
      Arnd Bergmann 提交于
      The do_div() macro now checks its arguments for the correct type,
      and refuses anything other than u64, so we get a warning about
      nbd_ioctl passing in an loff_t:
      
      drivers/block/nbd.c: In function '__nbd_ioctl':
      drivers/block/nbd.c:757:77: error: comparison of distinct pointer types lacks a cast [-Werror]
      
      This changes the nbd code to use div_s64() instead, which takes
      a signed argument.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: 37091fdd ("nbd: Create size change events for userspace")
      Signed-off-by: NJens Axboe <axboe@fb.com>
      5e454c67
  23. 15 2月, 2016 1 次提交
    • M
      nbd: Create size change events for userspace · 37091fdd
      Markus Pargmann 提交于
      The userspace needs to know when nbd devices are ready for use.
      Currently no events are created for the userspace which doesn't work for
      systemd.
      
      See the discussion here: https://github.com/systemd/systemd/pull/358
      
      This patch uses a central point to setup the nbd-internal sizes. A ioctl
      to set a size does not lead to a visible size change. The size of the
      block device will be kept at 0 until nbd is connected. As soon as it
      connects, the size will be changed to the real value and a uevent is
      created. When disconnecting, the blockdevice is set to 0 size and
      another uevent is generated.
      Signed-off-by: NMarkus Pargmann <mpa@pengutronix.de>
      37091fdd
  24. 05 2月, 2016 1 次提交
    • D
      nbd: ratelimit error msgs after socket close · da6ccaaa
      Dan Streetman 提交于
      Make the "Attempted send on closed socket" error messages generated in
      nbd_request_handler() ratelimited.
      
      When the nbd socket is shutdown, the nbd_request_handler() function emits
      an error message for every request remaining in its queue.  If the queue
      is large, this will spam a large amount of messages to the log.  There's
      no need for a separate error message for each request, so this patch
      ratelimits it.
      
      In the specific case this was found, the system was virtual and the error
      messages were logged to the serial port, which overwhelmed it.
      
      Fixes: 4d48a542 ("nbd: fix I/O hang on disconnected nbds")
      Signed-off-by: NDan Streetman <dan.streetman@canonical.com>
      Signed-off-by: NMarkus Pargmann <mpa@pengutronix.de>
      da6ccaaa