1. 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
  2. 03 12月, 2016 1 次提交
  3. 23 11月, 2016 2 次提交
  4. 18 11月, 2016 1 次提交
  5. 24 9月, 2016 1 次提交
  6. 09 9月, 2016 4 次提交
  7. 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
  8. 08 6月, 2016 3 次提交
  9. 13 4月, 2016 1 次提交
  10. 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
  11. 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
  12. 05 2月, 2016 5 次提交
    • 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
    • M
      nbd: Move flag parsing to a function · d02cf531
      Markus Pargmann 提交于
      nbd changes properties of the blockdevice depending on flags that were
      received. This patch moves this flag parsing into a separate function
      nbd_parse_flags().
      Signed-off-by: NMarkus Pargmann <mpa@pengutronix.de>
      d02cf531
    • M
      nbd: Cleanup reset of nbd and bdev after a disconnect · 0e4f0f6f
      Markus Pargmann 提交于
      Group all variables that are reset after a disconnect into reset
      functions. This patch adds two of these functions, nbd_reset() and
      nbd_bdev_reset().
      Signed-off-by: NMarkus Pargmann <mpa@pengutronix.de>
      0e4f0f6f
    • M
      nbd: Timeouts are not user requested disconnects · 1f7b5cf1
      Markus Pargmann 提交于
      It may be useful to know in the client that a connection timed out. The
      current code returns success for a timeout.
      
      This patch reports the error code -ETIMEDOUT for a timeout.
      Signed-off-by: NMarkus Pargmann <mpa@pengutronix.de>
      1f7b5cf1
    • M
      nbd: Remove signal usage · 23272a67
      Markus Pargmann 提交于
      As discussed on the mailing list, the usage of signals for timeout
      handling has a lot of potential issues. The nbd driver used for some
      time signals for timeouts. These signals where able to get the threads
      out of the blocking socket operations.
      
      This patch removes all signal usage and uses a socket shutdown instead.
      The socket descriptor itself is cleared later when the whole nbd device
      is closed.
      
      The tasks_lock is removed as we do not depend on this anymore. Instead
      a new lock for the socket is introduced so we can safely work with the
      socket in the timeout handler outside of the two main threads.
      
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Signed-off-by: NMarkus Pargmann <mpa@pengutronix.de>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      23272a67
  13. 03 2月, 2016 1 次提交
    • M
      nbd: Fix debugfs error handling · 27ea43fe
      Markus Pargmann 提交于
      Static checker complains about the implemented error handling. It is
      indeed wrong. We don't care about the return values of created debugfs
      files.
      
      We only have to check the return values of created dirs for NULL
      pointer. If we use a null pointer as parent directory for files, this
      may lead to debugfs files in wrong places.
      Signed-off-by: NMarkus Pargmann <mpa@pengutronix.de>
      27ea43fe
  14. 09 1月, 2016 1 次提交
  15. 07 11月, 2015 1 次提交
  16. 09 10月, 2015 1 次提交
  17. 17 8月, 2015 10 次提交
  18. 17 7月, 2015 1 次提交
  19. 20 5月, 2015 1 次提交
  20. 06 5月, 2015 2 次提交