linux-2.6-block.git
8 years agoMerge branch 'for-4.11/next' into for-next
Jens Axboe [Thu, 2 Feb 2017 17:20:23 +0000 (10:20 -0700)]
Merge branch 'for-4.11/next' into for-next

8 years agoblktrace: use existing disk debugfs directory
Omar Sandoval [Tue, 31 Jan 2017 22:53:22 +0000 (14:53 -0800)]
blktrace: use existing disk debugfs directory

We may already have a directory to put the blktrace stuff in if

1. The disk uses blk-mq
2. CONFIG_BLK_DEBUG_FS is enabled
3. We are tracing the whole disk and not a partition

Instead of hardcoding this very specific case, let's use the new
debugfs_lookup(). If the directory exists, we use it, otherwise we
create one and clean it up later.

Fixes: 07e4fead45e6 ("blk-mq: create debugfs directory tree")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq: move debugfs_remove() of disk dir to blk_release_queue()
Omar Sandoval [Tue, 31 Jan 2017 22:53:21 +0000 (14:53 -0800)]
blk-mq: move debugfs_remove() of disk dir to blk_release_queue()

This needs to happen after we tear down blktrace.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: use same block debugfs directory for blk-mq and blktrace
Omar Sandoval [Tue, 31 Jan 2017 22:53:20 +0000 (14:53 -0800)]
block: use same block debugfs directory for blk-mq and blktrace

When I added the blk-mq debugging information to debugfs, I didn't
notice that blktrace also creates a "block" directory in debugfs. Make
them use the same dentry, now created in the core block code. Based on a
patch from Jens.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblktrace: make do_blk_trace_setup() static
Omar Sandoval [Tue, 31 Jan 2017 22:53:19 +0000 (14:53 -0800)]
blktrace: make do_blk_trace_setup() static

This isn't used outside of blktrace.c anymore.

Fixes: 62c2a7d969f3 ("block: push BKL into blktrace ioctls")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: fix debugfs config conditional in struct request_queue
Omar Sandoval [Tue, 31 Jan 2017 22:53:18 +0000 (14:53 -0800)]
block: fix debugfs config conditional in struct request_queue

The debugfs dentries are only used for CONFIG_BLK_DEBUG_FS, so make them
conditional on that instead of CONFIG_DEBUG_FS.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agodebugfs: add debugfs_lookup()
Omar Sandoval [Tue, 31 Jan 2017 22:53:17 +0000 (14:53 -0800)]
debugfs: add debugfs_lookup()

We don't always have easy access to the dentry of a file or directory we
created in debugfs. Add a helper which allows us to get a dentry we
previously created.

The motivation for this change is a problem with blktrace and the blk-mq
debugfs entries introduced in 07e4fead45e6 ("blk-mq: create debugfs
directory tree"). Namely, in some cases, the directory that blktrace
needs to create may already exist, but in other cases, it may not. We
_could_ rely on a bunch of implied knowledge to decide whether to create
the directory or not, but it's much cleaner on our end to just look it
up.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/next' into for-next
Jens Axboe [Thu, 2 Feb 2017 15:23:30 +0000 (08:23 -0700)]
Merge branch 'for-4.11/next' into for-next

8 years agoscsi, block: fix duplicate bdi name registration crashes
Dan Williams [Wed, 1 Feb 2017 22:05:23 +0000 (14:05 -0800)]
scsi, block: fix duplicate bdi name registration crashes

Warnings of the following form occur because scsi reuses a devt number
while the block layer still has it referenced as the name of the bdi
[1]:

 WARNING: CPU: 1 PID: 93 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80
 sysfs: cannot create duplicate filename '/devices/virtual/bdi/8:192'
 [..]
 Call Trace:
  dump_stack+0x86/0xc3
  __warn+0xcb/0xf0
  warn_slowpath_fmt+0x5f/0x80
  ? kernfs_path_from_node+0x4f/0x60
  sysfs_warn_dup+0x62/0x80
  sysfs_create_dir_ns+0x77/0x90
  kobject_add_internal+0xb2/0x350
  kobject_add+0x75/0xd0
  device_add+0x15a/0x650
  device_create_groups_vargs+0xe0/0xf0
  device_create_vargs+0x1c/0x20
  bdi_register+0x90/0x240
  ? lockdep_init_map+0x57/0x200
  bdi_register_owner+0x36/0x60
  device_add_disk+0x1bb/0x4e0
  ? __pm_runtime_use_autosuspend+0x5c/0x70
  sd_probe_async+0x10d/0x1c0
  async_run_entry_fn+0x39/0x170

This is a brute-force fix to pass the devt release information from
sd_probe() to the locations where we register the bdi,
device_add_disk(), and unregister the bdi, blk_cleanup_queue().

Thanks to Omar for the quick reproducer script [2]. This patch survives
where an unmodified kernel fails in a few seconds.

[1]: https://marc.info/?l=linux-scsi&m=147116857810716&w=4
[2]: http://marc.info/?l=linux-block&m=148554717109098&w=2

Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jan Kara <jack@suse.cz>
Reported-by: Omar Sandoval <osandov@osandov.com>
Tested-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: Get rid of blk_get_backing_dev_info()
Jan Kara [Thu, 2 Feb 2017 14:56:53 +0000 (15:56 +0100)]
block: Get rid of blk_get_backing_dev_info()

blk_get_backing_dev_info() is now a simple dereference. Remove that
function and simplify some code around that.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: Make blk_get_backing_dev_info() safe without open bdev
Jan Kara [Thu, 2 Feb 2017 14:56:52 +0000 (15:56 +0100)]
block: Make blk_get_backing_dev_info() safe without open bdev

Currenly blk_get_backing_dev_info() is not safe to be called when the
block device is not open as bdev->bd_disk is NULL in that case. However
inode_to_bdi() uses this function and may be call called from flusher
worker or other writeback related functions without bdev being open
which leads to crashes such as:

[113031.075540] Unable to handle kernel paging request for data at address 0x00000000
[113031.075614] Faulting instruction address: 0xc0000000003692e0
0:mon> t
[c0000000fb65f900c00000000036cb6c writeback_sb_inodes+0x30c/0x590
[c0000000fb65fa10c00000000036ced4 __writeback_inodes_wb+0xe4/0x150
[c0000000fb65fa70c00000000036d33c wb_writeback+0x30c/0x450
[c0000000fb65fb40c00000000036e198 wb_workfn+0x268/0x580
[c0000000fb65fc50c0000000000f3470 process_one_work+0x1e0/0x590
[c0000000fb65fce0c0000000000f38c8 worker_thread+0xa8/0x660
[c0000000fb65fd80c0000000000fc4b0 kthread+0x110/0x130
[c0000000fb65fe30c0000000000098f0 ret_from_kernel_thread+0x5c/0x6c

Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: Dynamically allocate and refcount backing_dev_info
Jan Kara [Thu, 2 Feb 2017 14:56:51 +0000 (15:56 +0100)]
block: Dynamically allocate and refcount backing_dev_info

Instead of storing backing_dev_info inside struct request_queue,
allocate it dynamically, reference count it, and free it when the last
reference is dropped. Currently only request_queue holds the reference
but in the following patch we add other users referencing
backing_dev_info.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: Use pointer to backing_dev_info from request_queue
Jan Kara [Thu, 2 Feb 2017 14:56:50 +0000 (15:56 +0100)]
block: Use pointer to backing_dev_info from request_queue

We will want to have struct backing_dev_info allocated separately from
struct request_queue. As the first step add pointer to backing_dev_info
to request_queue and convert all users touching it. No functional
changes in this patch.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: Unhash block device inodes on gendisk destruction
Jan Kara [Thu, 2 Feb 2017 14:56:49 +0000 (15:56 +0100)]
block: Unhash block device inodes on gendisk destruction

Currently, block device inodes stay around after corresponding gendisk
hash died until memory reclaim finds them and frees them. Since we will
make block device inode pin the bdi, we want to free the block device
inode as soon as the device goes away so that bdi does not stay around
unnecessarily. Furthermore we need to avoid issues when new device with
the same major,minor pair gets created since reusing the bdi structure
would be rather difficult in this case.

Unhashing block device inode on gendisk destruction nicely deals with
these problems. Once last block device inode reference is dropped (which
may be directly in del_gendisk()), the inode gets evicted. Furthermore if
the major,minor pair gets reallocated, we are guaranteed to get new
block device inode even if old block device inode is not yet evicted and
thus we avoid issues with possible reuse of bdi.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/next' into for-next
Jens Axboe [Wed, 1 Feb 2017 23:28:56 +0000 (16:28 -0700)]
Merge branch 'for-4.11/next' into for-next

8 years agonbd: use an idr to keep track of nbd devices
Josef Bacik [Wed, 1 Feb 2017 21:11:40 +0000 (16:11 -0500)]
nbd: use an idr to keep track of nbd devices

To prepare for dynamically adding new nbd devices to the system switch
from using an array for the nbd devices and instead use an idr.  This
copies what loop does for keeping track of its devices.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agonbd: use our own workqueue for recv threads
Josef Bacik [Wed, 1 Feb 2017 21:11:11 +0000 (16:11 -0500)]
nbd: use our own workqueue for recv threads

Since we are in the memory reclaim path we need our recv work to be on a
workqueue that has WQ_MEM_RECLAIM set so we can avoid deadlocks.  Also
set WQ_HIGHPRI since we are in the completion path for IO.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Wed, 1 Feb 2017 22:31:30 +0000 (15:31 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agoblock: queue lock must be acquired when iterating over rls
Tahsin Erdogan [Wed, 1 Feb 2017 06:36:50 +0000 (22:36 -0800)]
block: queue lock must be acquired when iterating over rls

blk_set_queue_dying() does not acquire queue lock before it calls
blk_queue_for_each_rl(). This allows a racing blkg_destroy() to
remove blkg->q_node from the linked list and have
blk_queue_for_each_rl() loop infitely over the removed blkg->q_node
list node.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Wed, 1 Feb 2017 19:32:37 +0000 (12:32 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agoblock: Update comments that refer to __bio_map_user() and bio_map_user()
Bart Van Assche [Wed, 1 Feb 2017 16:20:08 +0000 (08:20 -0800)]
block: Update comments that refer to __bio_map_user() and bio_map_user()

Since __bio_map_user() and bio_map_user() have been removed, update
the comments that still refer to these functions.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
References: commit ddad8dd0a162 ("block: use blk_rq_map_user_iov to implement blk_rq_map_user")
Cc: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/rq-refactor' into for-next
Jens Axboe [Wed, 1 Feb 2017 19:23:09 +0000 (12:23 -0700)]
Merge branch 'for-4.11/rq-refactor' into for-next

8 years agoblk-mq-debug: Introduce debugfs_create_files() for-4.11/rq-refactor
Bart Van Assche [Wed, 1 Feb 2017 18:20:59 +0000 (10:20 -0800)]
blk-mq-debug: Introduce debugfs_create_files()

Replace the two debugfs_create_file() loops by a call to the new
debugfs_create_files() function. Add an empty element at the end
of the two attribute arrays such that the array size does not have
to be passed to debugfs_create_files().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq-debug: Make show() operations interruptible
Bart Van Assche [Wed, 1 Feb 2017 18:20:58 +0000 (10:20 -0800)]
blk-mq-debug: Make show() operations interruptible

Allow users to interrupt show operations instead of making a user
space process unkillable if ownership of q->sysfs_lock cannot be
obtained.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq-debug: Avoid that sparse complains about req_flags_t usage
Bart Van Assche [Wed, 1 Feb 2017 19:22:23 +0000 (12:22 -0700)]
blk-mq-debug: Avoid that sparse complains about req_flags_t usage

Avoid that sparse reports the following complaints:

block/elevator.c:541:29: warning: incorrect type in assignment (different base types)
block/elevator.c:541:29:    expected bool [unsigned] [usertype] next_sorted
block/elevator.c:541:29:    got restricted req_flags_t

block/blk-mq-debugfs.c:92:54: warning: cast from restricted req_flags_t

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq-debugfs: Add missing __acquires() / __releases() annotations
Bart Van Assche [Wed, 1 Feb 2017 18:20:56 +0000 (10:20 -0800)]
blk-mq-debugfs: Add missing __acquires() / __releases() annotations

This patch avoids that sparse complains about lock imbalances.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Wed, 1 Feb 2017 06:36:32 +0000 (23:36 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agoblk-mq: don't fail allocating driver tag for stopped hw queue
Jens Axboe [Wed, 1 Feb 2017 06:32:50 +0000 (23:32 -0700)]
blk-mq: don't fail allocating driver tag for stopped hw queue

We rely on blk_mq_get_driver_tag() not failing if 'wait' is true,
but it currently fails in that case if the queue happens to be
stopped at the time of the call.

We don't need to check for stopped here, it's just assigning
the tag. If the queue is stopped, we'll handle it when
attempting to run the queue.

This fixes a stall/crash on flush intensive workloads, where
we proceed to process a flush that doesn't have a valid tag
assigned.

Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/rq-refactor' into for-next
Jens Axboe [Tue, 31 Jan 2017 21:06:20 +0000 (14:06 -0700)]
Merge branch 'for-4.11/rq-refactor' into for-next

8 years agoblock: move internal_tag to same cache line as tag
Jens Axboe [Tue, 31 Jan 2017 19:34:41 +0000 (12:34 -0700)]
block: move internal_tag to same cache line as tag

Since we removed cmd_type, we now have a hole in the struct. Move
the internal_tag member to the same cacheline as tag, since we
use them at the same time.

This doesn't fix the hole, just moves it elsewhere.

Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: fold cmd_type into the REQ_OP_ space
Christoph Hellwig [Tue, 31 Jan 2017 15:57:31 +0000 (16:57 +0100)]
block: fold cmd_type into the REQ_OP_ space

Instead of keeping two levels of indirection for requests types, fold it
all into the operations.  The little caveat here is that previously
cmd_type only applied to struct request, while the request and bio op
fields were set to plain REQ_OP_READ/WRITE even for passthrough
operations.

Instead this patch adds new REQ_OP_* for SCSI passthrough and driver
private requests, althought it has to add two for each so that we
can communicate the data in/out nature of the request.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoide: don't abuse cmd_type
Christoph Hellwig [Tue, 31 Jan 2017 15:57:30 +0000 (16:57 +0100)]
ide: don't abuse cmd_type

Currently the legacy ide driver defines several request types of it's own,
which is in the way of removing that field entirely.

Instead add a type field to struct ide_request and use that to distinguish
the different types of IDE-internal requests.

It's a bit of a mess, but so is the surrounding code..

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: introduce blk_rq_is_passthrough
Christoph Hellwig [Tue, 31 Jan 2017 15:57:29 +0000 (16:57 +0100)]
block: introduce blk_rq_is_passthrough

This can be used to check for fs vs non-fs requests and basically
removes all knowledge of BLOCK_PC specific from the block layer,
as well as preparing for removing the cmd_type field in struct request.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agonbd: move request validity checking into nbd_send_cmd
Christoph Hellwig [Tue, 31 Jan 2017 15:57:28 +0000 (16:57 +0100)]
nbd: move request validity checking into nbd_send_cmd

This is where we do the rest of the request handling, which will
become much simpler soon, too.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agonbd: remove REQ_TYPE_DRV_PRIV leftovers
Christoph Hellwig [Tue, 31 Jan 2017 15:57:27 +0000 (16:57 +0100)]
nbd: remove REQ_TYPE_DRV_PRIV leftovers

Disconnects don't use block layer requests these days, so all handling
of private requests is dead code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agomspro_block: remove pointless prep_fn
Christoph Hellwig [Tue, 31 Jan 2017 15:57:26 +0000 (16:57 +0100)]
mspro_block: remove pointless prep_fn

This driver will never see non-fs requests, and doesn't do anything
else in the prep_fn.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoms_block: remove pointless prep_fn
Christoph Hellwig [Tue, 31 Jan 2017 15:57:25 +0000 (16:57 +0100)]
ms_block: remove pointless prep_fn

This driver will never see non-fs requests, and doesn't do anything
else in the prep_fn.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agommc: remove pointless request type check in mmc_prep_request
Christoph Hellwig [Tue, 31 Jan 2017 15:57:24 +0000 (16:57 +0100)]
mmc: remove pointless request type check in mmc_prep_request

The block layer won't send requests the driver isn't asking for,
so remove this check.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoѕd: remove pointless REQ_TYPE_FS check
Christoph Hellwig [Tue, 31 Jan 2017 15:57:23 +0000 (16:57 +0100)]
ѕd: remove pointless REQ_TYPE_FS check

->done can only be called for fs requests, so no need to check again here.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscm_blk: remove unneeded REQ_TYPE_FS check
Christoph Hellwig [Tue, 31 Jan 2017 15:57:22 +0000 (16:57 +0100)]
scm_blk: remove unneeded REQ_TYPE_FS check

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/rq-refactor' into for-next
Jens Axboe [Tue, 31 Jan 2017 17:55:25 +0000 (10:55 -0700)]
Merge branch 'for-4.11/rq-refactor' into for-next

8 years agovirtio_blk: make SCSI passthrough support configurable
Christoph Hellwig [Sat, 28 Jan 2017 08:32:53 +0000 (09:32 +0100)]
virtio_blk: make SCSI passthrough support configurable

The SCSI passthrough idea was a a bad idea to start with (guess who came
up with it?), and has been removed from the virtio 1.O spec, and is not
enabled by defauly by any host I know of.  Add a separate config option
for it so that we don't need to enable it for most setups.  That way
any bugs related to it (like the one recently fixed for vmapped stacks)
do not affect other users, and the size of the virtblk_req structure
also shrinks significantly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agovirtio_blk: remove struct request backpointer from virtblk_req
Christoph Hellwig [Sat, 28 Jan 2017 08:32:52 +0000 (09:32 +0100)]
virtio_blk: remove struct request backpointer from virtblk_req

We can simply use blk_mq_rq_from_pdu to get back at the request at
I/O completion time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: make scsi_request and scsi ioctl support optional
Christoph Hellwig [Sat, 28 Jan 2017 08:32:51 +0000 (09:32 +0100)]
block: make scsi_request and scsi ioctl support optional

We only need this code to support scsi, ide, cciss and virtio.  And at
least for virtio it's a deprecated feature to start with.

This should shrink the kernel size for embedded device that only use,
say eMMC a bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoskd: implement trivial scsi ioctls directly
Christoph Hellwig [Sat, 28 Jan 2017 08:32:50 +0000 (09:32 +0100)]
skd: implement trivial scsi ioctls directly

This way there is no need to drag in a dependency on the
BLOCK_PC code, which is going to become optional.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Tue, 31 Jan 2017 15:34:53 +0000 (08:34 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agonvme/pci: Don't mark IOD as aborted if abort wasn't sent
Keith Busch [Tue, 24 Jan 2017 23:07:00 +0000 (18:07 -0500)]
nvme/pci: Don't mark IOD as aborted if abort wasn't sent

This patch sets the aborted flag only if an abort was sent, reducing
excessive kernel message spamming for completed IO that wasn't actually
aborted.

Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Tue, 31 Jan 2017 15:33:10 +0000 (08:33 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agolightnvm: allow targets to use sysfs
Javier González [Tue, 31 Jan 2017 12:17:20 +0000 (13:17 +0100)]
lightnvm: allow targets to use sysfs

In order to register through the sysfs interface, a driver needs to know
its kobject. On a disk structure, this happens when the partition
information is added (device_add_disk), which for lightnvm takes place
after the target has been initialized. This means that on target
initialization, the kboject has not been created yet.

This patch adds a target function to let targets initialize their own
kboject as a child of the disk kobject.

Signed-off-by: Javier González <javier@cnexlabs.com>
Added exit typedef and passed gendisk instead of void pointer for exit.
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: free properly on target creation error
Javier González [Tue, 31 Jan 2017 12:17:19 +0000 (13:17 +0100)]
lightnvm: free properly on target creation error

Fix a memory leak when target creation fails. More specifically, free
the entire device structure given to the target (tgt_dev).

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: Add CRC read error
Javier González [Tue, 31 Jan 2017 12:17:18 +0000 (13:17 +0100)]
lightnvm: Add CRC read error

Let the host differentiate between a read error and a CRC check error on
the device side.

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: use end_io callback instead of instance
Matias Bjørling [Tue, 31 Jan 2017 12:17:17 +0000 (13:17 +0100)]
lightnvm: use end_io callback instead of instance

When the lightnvm core had the "gennvm" layer between the device and the
target, there was a need for the core to be able to figure out which
target it should send an end_io callback to. Leading to a "double"
end_io, first for the media manager instance, and then for the target
instance. Now that core and gennvm is merged, there is no longer a need
for this, and a single end_io callback will do.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: add ioctls for vector I/Os
Matias Bjørling [Tue, 31 Jan 2017 12:17:16 +0000 (13:17 +0100)]
lightnvm: add ioctls for vector I/Os

Enable user-space to issue vector I/O commands through ioctls. To issue
a vector I/O, the ppa list with addresses is also required and must be
mapped for the controller to access.

For each ioctl, the result and status bits are returned as well, such
that user-space can retrieve the open-channel SSD completion bits.

The implementation covers the traditional use-cases of bad block
management, and vectored read/write/erase.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Metadata implementation, test, and fixes.
Signed-off-by: Simon A.F. Lund <slund@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: reduce number of nvm_id groups to one
Matias Bjørling [Tue, 31 Jan 2017 12:17:15 +0000 (13:17 +0100)]
lightnvm: reduce number of nvm_id groups to one

The number of configuration groups has been limited to one in current
code, even if there is support for up to four. With the introduction
of the open-channel SSD 1.3 specification, only a single
group is exposed onwards. Reflect this in the nvm_id structure.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: cleanup nvm transformation functions
Matias Bjørling [Tue, 31 Jan 2017 12:17:14 +0000 (13:17 +0100)]
lightnvm: cleanup nvm transformation functions

Going from target specific ppa addresses to device was accomplished by
first converting target to generic ppa addresses and generic to device
addresses. The conversion was either open-coded or used the built-in
nvm_trans_* and nvm_map_* functions for conversion. Simplify the
interface and cleanup the calls to provide clean functions that now
either take a list of ppas or a nvm_rq, and is exposed through:

 void nvm_ppa_* - target to/from device with a list of PPAs,
 void nvm_rq_* - target to/from device with a nvm_rq.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: make nvm_map_* return void
Matias Bjørling [Tue, 31 Jan 2017 12:17:13 +0000 (13:17 +0100)]
lightnvm: make nvm_map_* return void

The only check there was done was a debugging check. Remove it and
replace the return value with void to reduce error checking.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: remove nvm_get_bb_tbl and nvm_set_bb_tbl
Matias Bjørling [Tue, 31 Jan 2017 12:17:12 +0000 (13:17 +0100)]
lightnvm: remove nvm_get_bb_tbl and nvm_set_bb_tbl

Since the merge of gennvm and core, there is no longer a need for the
device specific bad block functions.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: remove nvm_submit_ppa* functions
Matias Bjørling [Tue, 31 Jan 2017 12:17:11 +0000 (13:17 +0100)]
lightnvm: remove nvm_submit_ppa* functions

The nvm_submit_ppa* functions are no longer needed after gennvm and core
have been merged.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: collapse nvm_erase_ppa and nvm_erase_blk
Matias Bjørling [Tue, 31 Jan 2017 12:17:10 +0000 (13:17 +0100)]
lightnvm: collapse nvm_erase_ppa and nvm_erase_blk

After gennvm and core have been merged, there are no more callers to
nvm_erase_ppa. Therefore collapse the device specific and target
specific erase functions.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agolightnvm: merge gennvm with core
Matias Bjørling [Tue, 31 Jan 2017 12:17:09 +0000 (13:17 +0100)]
lightnvm: merge gennvm with core

For the first iteration of Open-Channel SSDs, it was anticipated that
there could be various media managers on top of an open-channel SSD,
such to allow vendors to plug in their own host-side FTLs, without the
media manager in between.

Now that an Open-Channel SSD is exposed as a traditional block device,
there is no longer a need for this. Therefore lets merge the gennvm code
with core and simplify the stack.

Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/rq-refactor' into for-next
Jens Axboe [Mon, 30 Jan 2017 15:34:03 +0000 (08:34 -0700)]
Merge branch 'for-4.11/rq-refactor' into for-next

8 years agonvme/scsi: don't rely on BLK_MAX_CDB
Christoph Hellwig [Sat, 28 Jan 2017 08:32:49 +0000 (09:32 +0100)]
nvme/scsi: don't rely on BLK_MAX_CDB

The NVMe SCSI emulation doesn't use BLOCK_PC requests, so BLK_MAX_CDB
doesn't have a meaning for it.  Instead opencode the value of 16
and refactor the code a bit so that related checks are next to each
other and we only need to use the value in one place.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/rq-refactor' into for-next
Jens Axboe [Mon, 30 Jan 2017 03:07:10 +0000 (20:07 -0700)]
Merge branch 'for-4.11/rq-refactor' into for-next

8 years agonvme: fix compilation of scsi component
Jens Axboe [Mon, 30 Jan 2017 03:04:49 +0000 (20:04 -0700)]
nvme: fix compilation of scsi component

Since we moved the cdb parts and define out of the block proper,
we need to include scsi/scsi_request.h for the nvme scsi layer.

Fixes: 82ed4db499b8 ("block: split scsi_request out of struct request")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/rq-refactor' into for-next
Jens Axboe [Sat, 28 Jan 2017 02:21:05 +0000 (19:21 -0700)]
Merge branch 'for-4.11/rq-refactor' into for-next

8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Fri, 27 Jan 2017 22:15:58 +0000 (15:15 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agoblock: don't assign cmd_flags in __blk_rq_prep_clone
Christoph Hellwig [Mon, 23 Jan 2017 13:31:09 +0000 (14:31 +0100)]
block: don't assign cmd_flags in __blk_rq_prep_clone

These days we have the proper flags set since request allocation time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: split scsi_request out of struct request
Christoph Hellwig [Fri, 27 Jan 2017 08:46:29 +0000 (09:46 +0100)]
block: split scsi_request out of struct request

And require all drivers that want to support BLOCK_PC to allocate it
as the first thing of their private data.  To support this the legacy
IDE and BSG code is switched to set cmd_size on their queues to let
the block layer allocate the additional space.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock/bsg: move queue creation into bsg_setup_queue
Christoph Hellwig [Tue, 3 Jan 2017 12:25:02 +0000 (15:25 +0300)]
block/bsg: move queue creation into bsg_setup_queue

Simply the boilerplate code needed for bsg nodes a bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi: allocate scsi_cmnd structures as part of struct request
Christoph Hellwig [Mon, 2 Jan 2017 18:55:26 +0000 (21:55 +0300)]
scsi: allocate scsi_cmnd structures as part of struct request

Rely on the new block layer functionality to allocate additional driver
specific data behind struct request instead of implementing it in SCSI
itѕelf.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi: remove __scsi_alloc_queue
Christoph Hellwig [Mon, 2 Jan 2017 18:52:10 +0000 (21:52 +0300)]
scsi: remove __scsi_alloc_queue

Instead do an internal export of __scsi_init_queue for the transport
classes that export BSG nodes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi: remove scsi_cmd_dma_pool
Christoph Hellwig [Mon, 2 Jan 2017 12:26:34 +0000 (15:26 +0300)]
scsi: remove scsi_cmd_dma_pool

There is no need for GFP_DMA allocations of the scsi_cmnd structures
themselves, all that might be DMAed to or from is the actual payload,
or the sense buffers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi: respect unchecked_isa_dma for blk-mq
Christoph Hellwig [Tue, 3 Jan 2017 05:28:41 +0000 (08:28 +0300)]
scsi: respect unchecked_isa_dma for blk-mq

Currently blk-mq always allocates the sense buffer using normal GFP_KERNEL
allocation.  Refactor the cmd pool code to split the cmd and sense allocation
and share the code to allocate the sense buffers as well as the sense buffer
slab caches between the legacy and blk-mq path.

Note that this switches to lazy allocation of the sense slab caches - the
slab caches (not the actual allocations) won't be destroy until the scsi
module is unloaded instead of keeping track of hosts using them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi: remove gfp_flags member in scsi_host_cmd_pool
Christoph Hellwig [Mon, 2 Jan 2017 11:38:03 +0000 (14:38 +0300)]
scsi: remove gfp_flags member in scsi_host_cmd_pool

When using the slab allocator we already decide at cache creation time if
an allocation comes from a GFP_DMA pool using the SLAB_CACHE_DMA flag,
and there is no point passing the kmalloc-family only GFP_DMA flag to
kmem_cache_alloc.  Drop all the infrastructure for doing so.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi_dh_hp_sw: switch to scsi_execute_req_flags()
Hannes Reinecke [Thu, 3 Nov 2016 13:20:23 +0000 (14:20 +0100)]
scsi_dh_hp_sw: switch to scsi_execute_req_flags()

Switch to scsi_execute_req_flags() instead of using the block interface
directly.  This will set REQ_QUIET and REQ_PREEMPT, but this is okay as
we're evaluating the errors anyway and should be able to send the command
even if the device is quiesced.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi_dh_emc: switch to scsi_execute_req_flags()
Hannes Reinecke [Thu, 3 Nov 2016 13:20:22 +0000 (14:20 +0100)]
scsi_dh_emc: switch to scsi_execute_req_flags()

Switch to scsi_execute_req_flags() and scsi_get_vpd_page() instead of
open-coding it.  Using scsi_execute_req_flags() will set REQ_QUIET and
REQ_PREEMPT, but this is okay as we're evaluating the errors anyway and
should be able to send the command even if the device is quiesced.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoscsi_dh_rdac: switch to scsi_execute_req_flags()
Hannes Reinecke [Thu, 3 Nov 2016 13:20:21 +0000 (14:20 +0100)]
scsi_dh_rdac: switch to scsi_execute_req_flags()

Switch to scsi_execute_req_flags() and scsi_get_vpd_page() instead of
open-coding it.  Using scsi_execute_req_flags() will set REQ_QUIET and
REQ_PREEMPT, but this is okay as we're evaluating the errors anyway and
should be able to send the command even if the device is quiesced.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agodm: always defer request allocation to the owner of the request_queue
Christoph Hellwig [Sun, 22 Jan 2017 17:32:46 +0000 (18:32 +0100)]
dm: always defer request allocation to the owner of the request_queue

DM already calls blk_mq_alloc_request on the request_queue of the
underlying device if it is a blk-mq device.  But now that we allow drivers
to allocate additional data and initialize it ahead of time we need to do
the same for all drivers.   Doing so and using the new cmd_size
infrastructure in the block layer greatly simplifies the dm-rq and mpath
code, and should also make arbitrary combinations of SQ and MQ devices
with SQ or MQ device mapper tables easily possible as a further step.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agodm: remove incomplete BLOCK_PC support
Christoph Hellwig [Tue, 10 Jan 2017 09:03:39 +0000 (10:03 +0100)]
dm: remove incomplete BLOCK_PC support

DM tries to copy a few fields around for BLOCK_PC requests, but given
that no dm-target ever wires up scsi_cmd_ioctl BLOCK_PC can't actually
be sent to dm.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: cleanup tracing
Christoph Hellwig [Fri, 27 Jan 2017 08:35:54 +0000 (09:35 +0100)]
block: cleanup tracing

A couple tweaks to the tracing code:

 - trace the request size for all requests
 - trace request sector and nr_sectors only for fs requests, enforced by
   helpers
 - drop SCSI CDB tracing - we have SCSI tracing for this and are going
   to me the CDB out of the generic struct request soon.

With this the tracing code stops to know about BLOCK_PC requests entirely,
it's just FS vs passthrough requests now, where the latter includes any
driver-private requests.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: allow specifying size for extra command data
Christoph Hellwig [Fri, 27 Jan 2017 16:51:45 +0000 (09:51 -0700)]
block: allow specifying size for extra command data

This mirrors the blk-mq capabilities to allocate extra drivers-specific
data behind struct request by setting a cmd_size field, as well as having
a constructor / destructor for it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: simplify blk_init_allocated_queue
Christoph Hellwig [Tue, 3 Jan 2017 11:52:44 +0000 (14:52 +0300)]
block: simplify blk_init_allocated_queue

Return an errno value instead of the passed in queue so that the callers
don't have to keep track of two queues, and move the assignment of the
request_fn and lock to the caller as passing them as argument doesn't
simplify anything.  While we're at it also remove two pointless NULL
assignments, given that the request structure is zeroed on allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: fix elevator init check
Christoph Hellwig [Wed, 25 Jan 2017 10:17:11 +0000 (11:17 +0100)]
block: fix elevator init check

We can't initalize the elevator fields for flushes as flush share space
in struct request with the elevator data.  But currently we can't
communicate that a request is a flush through blk_get_request as we
can only pass READ or WRITE, and the low-level code looks at the
possible NULL bio to check for a flush.

Fix this by allowing to pass any block op and flags, and by checking for
the flush flags in __get_request.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agomd: cleanup bio op / flags handling in raid1_write_request
Christoph Hellwig [Wed, 25 Jan 2017 10:15:20 +0000 (11:15 +0100)]
md: cleanup bio op / flags handling in raid1_write_request

No need for the local variables, the bio is still live and we can just
assign the bits we want directly.  Make me wonder why we can't assign
all the bio flags to start with.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/block' into for-4.11/rq-refactor
Jens Axboe [Fri, 27 Jan 2017 22:08:31 +0000 (15:08 -0700)]
Merge branch 'for-4.11/block' into for-4.11/rq-refactor

Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq: fix debugfs compilation issues
Omar Sandoval [Fri, 27 Jan 2017 22:03:01 +0000 (15:03 -0700)]
blk-mq: fix debugfs compilation issues

This fixes a couple of problems:

1. In the !CONFIG_DEBUG_FS case, the stub definitions were bogus.
2. In the !CONFIG_BLOCK case, blk-mq-debugfs.c shouldn't be compiled at
   all.

Fix the stub definitions and add a CONFIG_BLK_DEBUG_FS Kconfig option.

Fixes: 07e4fead45e6 ("blk-mq: create debugfs directory tree")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Augment Kconfig description.

Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Fri, 27 Jan 2017 16:09:00 +0000 (09:09 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agoMerge branch 'master' into for-next
Jens Axboe [Fri, 27 Jan 2017 16:08:54 +0000 (09:08 -0700)]
Merge branch 'master' into for-next

8 years agoblock: cleanup remaining manual checks for PREFLUSH|FUA
Jens Axboe [Fri, 27 Jan 2017 16:08:23 +0000 (09:08 -0700)]
block: cleanup remaining manual checks for PREFLUSH|FUA

Use op_is_flush() where applicable.

Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq-sched: add flush insertion into blk_mq_sched_insert_request()
Jens Axboe [Fri, 27 Jan 2017 08:00:47 +0000 (01:00 -0700)]
blk-mq-sched: add flush insertion into blk_mq_sched_insert_request()

Instead of letting the caller check this and handle the details
of inserting a flush request, put the logic in the scheduler
insertion function. This fixes direct flush insertion outside
of the usual make_request_fn calls, like from dm via
blk_insert_cloned_request().

Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblock: add a op_is_flush helper
Christoph Hellwig [Fri, 27 Jan 2017 15:30:47 +0000 (08:30 -0700)]
block: add a op_is_flush helper

This centralizes the checks for bios that needs to be go into the flush
state machine.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq-sched: change ->dispatch_requests() to ->dispatch_request()
Jens Axboe [Thu, 26 Jan 2017 19:40:07 +0000 (12:40 -0700)]
blk-mq-sched: change ->dispatch_requests() to ->dispatch_request()

When we invoke dispatch_requests(), the scheduler empties everything
into the passed in list. This isn't always a good thing, since it
means that we remove items that we could have potentially merged
with.

Change the function to dispatch single requests at the time. If
we do that, we can backoff exactly at the point where the device
can't consume more IO, and leave the rest with the scheduler for
better merging and future dispatch decision making.

Signed-off-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Tested-by: Hannes Reinecke <hare@suse.com>
8 years agoblk-mq-sched: fix starvation for multiple hardware queues and shared tags
Jens Axboe [Thu, 26 Jan 2017 21:42:34 +0000 (14:42 -0700)]
blk-mq-sched: fix starvation for multiple hardware queues and shared tags

If we have both multiple hardware queues and shared tag map between
devices, we need to ensure that we propagate the hardware queue
restart bit higher up. This is because we can get into a situation
where we don't have any IO pending on a hardware queue, yet we fail
getting a tag to start new IO. If that happens, it's not enough to
mark the hardware queue as needing a restart, we need to bubble
that up to the higher level queue as well.

Signed-off-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Tested-by: Hannes Reinecke <hare@suse.com>
8 years agoblk-mq: release driver tag on a requeue event
Jens Axboe [Thu, 26 Jan 2017 19:32:32 +0000 (12:32 -0700)]
blk-mq: release driver tag on a requeue event

We don't want to hold on to this resource when we have a scheduler
attached.

Signed-off-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Tested-by: Hannes Reinecke <hare@suse.com>
8 years agoblk-mq: fix potential race in queue restart and driver tag allocation
Jens Axboe [Thu, 26 Jan 2017 19:50:36 +0000 (12:50 -0700)]
blk-mq: fix potential race in queue restart and driver tag allocation

Once we mark the queue as needing a restart, re-check if we can
get a driver tag. This fixes a theoretical issue where the needed
IO completes _after_ blk_mq_get_driver_tag() fails, but before we
manage to set the restart bit.

Signed-off-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Tested-by: Hannes Reinecke <hare@suse.com>
8 years agoblk-mq: improve scheduler queue sync/async running
Jens Axboe [Thu, 26 Jan 2017 19:28:10 +0000 (12:28 -0700)]
blk-mq: improve scheduler queue sync/async running

We'll use the same criteria for whether we need to run the queue sync
or async when we have a scheduler, as we do without one.

Signed-off-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Tested-by: Hannes Reinecke <hare@suse.com>
8 years agoMerge branch 'for-4.11/block' into for-next
Jens Axboe [Fri, 27 Jan 2017 15:18:09 +0000 (08:18 -0700)]
Merge branch 'for-4.11/block' into for-next

8 years agoblk-mq: move hctx and ctx counters from sysfs to debugfs
Omar Sandoval [Wed, 25 Jan 2017 16:06:49 +0000 (08:06 -0800)]
blk-mq: move hctx and ctx counters from sysfs to debugfs

These counters aren't as out-of-place in sysfs as the other stuff, but
debugfs is a slightly better home for them.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq: move hctx io_poll, stats, and dispatched from sysfs to debugfs
Omar Sandoval [Wed, 25 Jan 2017 16:06:48 +0000 (08:06 -0800)]
blk-mq: move hctx io_poll, stats, and dispatched from sysfs to debugfs

These statistics _might_ be useful to userspace, but it's better not to
commit to an ABI for these yet. Also, the dispatched file in sysfs
couldn't be cleared, so make it clearable like the others in debugfs.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
8 years agoblk-mq: add tags and sched_tags bitmaps to debugfs
Omar Sandoval [Wed, 25 Jan 2017 16:06:47 +0000 (08:06 -0800)]
blk-mq: add tags and sched_tags bitmaps to debugfs

These can be used to debug issues like tag leaks and stuck requests.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>