* Re: [GIT PULL] Block pull request for- 4.11-rc1
From: Jens Axboe @ 2017-02-20 3:02 UTC (permalink / raw)
To: James Bottomley, Bart Van Assche, Linus Torvalds
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Hellwig, Mike Snitzer
In-Reply-To: <75b9d9d8-9395-c7af-b29d-f016e9921498@kernel.dk>
On 02/19/2017 07:59 PM, Jens Axboe wrote:
> On 02/19/2017 07:12 PM, James Bottomley wrote:
>> On Sun, 2017-02-19 at 18:15 -0700, Jens Axboe wrote:
>>> On 02/19/2017 06:09 PM, Bart Van Assche wrote:
>>>> On 02/19/2017 04:11 PM, Jens Axboe wrote:
>>>>> - Removal of the BLOCK_PC support in struct request, and
>>>>> refactoring of
>>>>> carrying SCSI payloads in the block layer. This cleans up the
>>>>> code
>>>>> nicely, and enables us to kill the SCSI specific parts of
>>>>> struct
>>>>> request, shrinking it down nicely. From Christoph mainly, with
>>>>> help
>>>>> from Hannes.
>>>>
>>>> Hello Jens, Christoph and Mike,
>>>>
>>>> Is anyone working on a fix for the regression introduced by the
>>>> BLOCK_PC removal changes (general protection fault) that I had
>>>> reported three weeks ago? See also
>>>> https://www.spinics.net/lists/raid/msg55494.html
>>>
>>> I don't think that's a regression in this series, it just triggers
>>> more easily with this series. The BLOCK_PC removal fixes aren't
>>> touching device life times at all.
>>>
>>> That said, we will look into this again, of course. Christoph, any
>>> idea?
>>
>> We could do with tracing the bdi removal failure issue fingered both by
>> the block xfstests and Omar. It's something to do with this set of
>> commits
>>
>>> - Fixes for duplicate bdi registrations and bdi/queue life time
>>> problems from Jan and Dan.
>>
>> But no-one has actually root caused it yet.
>
> The above set from Jan and Dan fixed one set of issues around this, and
> the reproducer test case was happy as well. But we've recently found
> that there are still corner cases that aren't happy, Omar reported that
> separately on Friday. So there will be a followup set for that,
> hopefully intersecting with the issue that Bart reported.
Forgot to mention, that these cases exist in 4.0 and 4.6 as well, so
neither are a new problem with this series. The fixes from Jan and
Dan didn't close all of them.
--
Jens Axboe
^ permalink raw reply
* Re: [GIT PULL] Block pull request for- 4.11-rc1
From: Jens Axboe @ 2017-02-20 2:59 UTC (permalink / raw)
To: James Bottomley, Bart Van Assche, Linus Torvalds
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Hellwig, Mike Snitzer
In-Reply-To: <1487556740.2244.15.camel@HansenPartnership.com>
On 02/19/2017 07:12 PM, James Bottomley wrote:
> On Sun, 2017-02-19 at 18:15 -0700, Jens Axboe wrote:
>> On 02/19/2017 06:09 PM, Bart Van Assche wrote:
>>> On 02/19/2017 04:11 PM, Jens Axboe wrote:
>>>> - Removal of the BLOCK_PC support in struct request, and
>>>> refactoring of
>>>> carrying SCSI payloads in the block layer. This cleans up the
>>>> code
>>>> nicely, and enables us to kill the SCSI specific parts of
>>>> struct
>>>> request, shrinking it down nicely. From Christoph mainly, with
>>>> help
>>>> from Hannes.
>>>
>>> Hello Jens, Christoph and Mike,
>>>
>>> Is anyone working on a fix for the regression introduced by the
>>> BLOCK_PC removal changes (general protection fault) that I had
>>> reported three weeks ago? See also
>>> https://www.spinics.net/lists/raid/msg55494.html
>>
>> I don't think that's a regression in this series, it just triggers
>> more easily with this series. The BLOCK_PC removal fixes aren't
>> touching device life times at all.
>>
>> That said, we will look into this again, of course. Christoph, any
>> idea?
>
> We could do with tracing the bdi removal failure issue fingered both by
> the block xfstests and Omar. It's something to do with this set of
> commits
>
>> - Fixes for duplicate bdi registrations and bdi/queue life time
>> problems from Jan and Dan.
>
> But no-one has actually root caused it yet.
The above set from Jan and Dan fixed one set of issues around this, and
the reproducer test case was happy as well. But we've recently found
that there are still corner cases that aren't happy, Omar reported that
separately on Friday. So there will be a followup set for that,
hopefully intersecting with the issue that Bart reported.
--
Jens Axboe
^ permalink raw reply
* Re: Manual driver binding and unbinding broken for SCSI
From: Omar Sandoval @ 2017-02-20 2:19 UTC (permalink / raw)
To: James Bottomley
Cc: Dan Williams, Jan Kara, Martin K. Petersen, Jens Axboe,
linux-scsi, linux-block
In-Reply-To: <1487378636.4351.45.camel@HansenPartnership.com>
On Fri, Feb 17, 2017 at 04:43:56PM -0800, James Bottomley wrote:
> This seems to be related to a 0day test we got on the block tree,
> details here:
>
> http://marc.info/?t=148624068800001
>
> I root caused the above to something not being released when it should
> be, so it looks like you have the same problem. It seems to be a
> recent commit in the block tree, so could you bisect it since you have
> a nice reproducer?
These appear to actually be two separate issues.
The unbind followed by bind crash only happens with scsi-mq. It reproes
since at least 4.0.
The unbind followed by a new device coming up crash happens both with
and without scsi-mq. The earliest version I was able to check for that
was 4.6, which did reproduce.
I'll see if I can get some more info on these two issues separately.
^ permalink raw reply
* Re: [GIT PULL] Block pull request for- 4.11-rc1
From: James Bottomley @ 2017-02-20 2:12 UTC (permalink / raw)
To: Jens Axboe, Bart Van Assche, Linus Torvalds
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Hellwig, Mike Snitzer
In-Reply-To: <633d226d-cec3-a01f-a069-ffff307e9715@kernel.dk>
On Sun, 2017-02-19 at 18:15 -0700, Jens Axboe wrote:
> On 02/19/2017 06:09 PM, Bart Van Assche wrote:
> > On 02/19/2017 04:11 PM, Jens Axboe wrote:
> > > - Removal of the BLOCK_PC support in struct request, and
> > > refactoring of
> > > carrying SCSI payloads in the block layer. This cleans up the
> > > code
> > > nicely, and enables us to kill the SCSI specific parts of
> > > struct
> > > request, shrinking it down nicely. From Christoph mainly, with
> > > help
> > > from Hannes.
> >
> > Hello Jens, Christoph and Mike,
> >
> > Is anyone working on a fix for the regression introduced by the
> > BLOCK_PC removal changes (general protection fault) that I had
> > reported three weeks ago? See also
> > https://www.spinics.net/lists/raid/msg55494.html
>
> I don't think that's a regression in this series, it just triggers
> more easily with this series. The BLOCK_PC removal fixes aren't
> touching device life times at all.
>
> That said, we will look into this again, of course. Christoph, any
> idea?
We could do with tracing the bdi removal failure issue fingered both by
the block xfstests and Omar. It's something to do with this set of
commits
> - Fixes for duplicate bdi registrations and bdi/queue life time
> problems from Jan and Dan.
But no-one has actually root caused it yet.
James
^ permalink raw reply
* Re: [GIT PULL] Block pull request for- 4.11-rc1
From: Jens Axboe @ 2017-02-20 1:15 UTC (permalink / raw)
To: Bart Van Assche, Linus Torvalds
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Hellwig, Mike Snitzer
In-Reply-To: <1D08B61A9CF0974AA09887BE32D889DA0A74F3@ULS-OP-MBXIP03.sdcorp.global.sandisk.com>
On 02/19/2017 06:09 PM, Bart Van Assche wrote:
> On 02/19/2017 04:11 PM, Jens Axboe wrote:
>> - Removal of the BLOCK_PC support in struct request, and refactoring of
>> carrying SCSI payloads in the block layer. This cleans up the code
>> nicely, and enables us to kill the SCSI specific parts of struct
>> request, shrinking it down nicely. From Christoph mainly, with help
>> from Hannes.
>
> Hello Jens, Christoph and Mike,
>
> Is anyone working on a fix for the regression introduced by the BLOCK_PC removal
> changes (general protection fault) that I had reported three weeks ago? See also
> https://www.spinics.net/lists/raid/msg55494.html
I don't think that's a regression in this series, it just triggers more easily
with this series. The BLOCK_PC removal fixes aren't touching device life times
at all.
That said, we will look into this again, of course. Christoph, any idea?
--
Jens Axboe
^ permalink raw reply
* RE: [GIT PULL] Block pull request for- 4.11-rc1
From: Bart Van Assche @ 2017-02-20 1:09 UTC (permalink / raw)
To: Jens Axboe, Linus Torvalds
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Hellwig, Mike Snitzer
In-Reply-To: <dea6290e-0cfa-a93d-b03d-f6f3cd74d20f@kernel.dk>
On 02/19/2017 04:11 PM, Jens Axboe wrote:=0A=
> - Removal of the BLOCK_PC support in struct request, and refactoring of=
=0A=
> carrying SCSI payloads in the block layer. This cleans up the code=0A=
> nicely, and enables us to kill the SCSI specific parts of struct=0A=
> request, shrinking it down nicely. From Christoph mainly, with help=0A=
> from Hannes.=0A=
=0A=
Hello Jens, Christoph and Mike,=0A=
=0A=
Is anyone working on a fix for the regression introduced by the BLOCK_PC re=
moval=0A=
changes (general protection fault) that I had reported three weeks ago? See=
also=0A=
https://www.spinics.net/lists/raid/msg55494.html=0A=
=0A=
Thanks,=0A=
=0A=
Bart.=
^ permalink raw reply
* [GIT PULL] Block pull request for- 4.11-rc1
From: Jens Axboe @ 2017-02-20 0:10 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Hi Linus,
This is the collected pull request for 4.11 for the block core and
drivers. It's really two different branches:
for-4.11/block-signed
for-4.11/next-signed
for-4.11/next exists because some of Christoph's patch series were based
on patches that were added after for-4.11/block was forked off, which
would have caused needless merge pain. So for-4.11/next was forked off
v4.10-rc5, with for-4.11/block pulled in. Feel free to pull each of
these in succession instead of this pre-merged branch. Note that if you
do opt for pulling the two branches, for-4.11/block will throw a trivial
merge conflict in block/blk-mq.c, where you need to delete a function.
for-4.11/next merges cleanly, HOWEVER, a commit that was added in
mainline since v4.10-rc5 (f2e767bb5d6e) adds a line of code that is no
longer valid with the changes in for-4.11/next. Hence, if you do pull in
separately, you'll want to --no-commit and edit:
drivers/scsi/mpt3sas/mpt3sas_scsih.c
to fix up that one line, like I did in the for-4.11/linus-merge branch.
With that said, this pull request contains:
- blk-mq scheduling framework from me and Omar, with a port of the
deadline scheduler for this framework. A port of BFQ from Paolo
is in the works, and should be ready for 4.12.
- Various fixups and improvements to the above scheduling framework
from Omar, Paolo, Bart, me, others.
- Cleanup of the exported sysfs blk-mq data into debugfs, from
Omar. This allows us to export more information that helps
debug hangs or performance issues, without cluttering or
abusing the sysfs API.
- Fixes for the sbitmap code, the scalable bitmap code that was
migrated from blk-mq, from Omar.
- Removal of the BLOCK_PC support in struct request, and refactoring of
carrying SCSI payloads in the block layer. This cleans up the code
nicely, and enables us to kill the SCSI specific parts of struct
request, shrinking it down nicely. From Christoph mainly, with help
from Hannes.
- Support for ranged discard requests and discard merging, also from
Christoph.
- Support for OPAL in the block layer, and for NVMe as well. Mainly
from Scott Bauer, with fixes/updates from various others folks.
- Error code fixup for gdrom from Christophe.
- cciss pci irq allocation cleanup from Christoph.
- Making the cdrom device operations read only, from Kees Cook.
- Fixes for duplicate bdi registrations and bdi/queue life time
problems from Jan and Dan.
- Set of fixes and updates for lightnvm, from Matias and Javier.
- A few fixes for nbd from Josef, using idr to name devices and
a workqueue deadlock fix on receive. Also marks Josef as the
current maintainer of nbd.
- Fix from Josef, overwriting queue settings when the number of
hardware queues is updated for a blk-mq device.
- NVMe fix from Keith, ensuring that we don't repeatedly mark
and IO aborted, if we didn't end up aborting it.
- SG gap merging fix from Ming Lei for block.
- Loop fix also from Ming, fixing a race and crash between setting
loop status and IO.
- Two block race fixes from Tahsin, fixing request list iteration
and fixing a race between device registration and udev device add
notifiations.
- Double free fix from cgroup writeback, from Tejun.
- Another double free fix in blkcg, from Hou Tao.
- Partition overflow fix for EFI from Alden Tondettar.
Please pull! Either this pre-merged branch:
git://git.kernel.dk/linux-block.git for-4.11/linus-merge-signed
or
git://git.kernel.dk/linux-block.git for-4.11/block-signed
git://git.kernel.dk/linux-block.git for-4.11/next-signed
in that order. All branches are signed tags.
----------------------------------------------------------------
Alden Tondettar (1):
partitions/efi: Fix integer overflow in GPT size calculation
Alexander Potapenko (1):
block: Initialize cfqq->ioprio_class in cfq_get_queue()
Bart Van Assche (5):
blk-mq-debugfs: Add missing __acquires() / __releases() annotations
blk-mq-debug: Avoid that sparse complains about req_flags_t usage
blk-mq-debug: Make show() operations interruptible
blk-mq-debug: Introduce debugfs_create_files()
block: Update comments that refer to __bio_map_user() and bio_map_user()
Christoph Hellwig (39):
block: add a op_is_flush helper
md: cleanup bio op / flags handling in raid1_write_request
block: fix elevator init check
block: simplify blk_init_allocated_queue
block: allow specifying size for extra command data
block: cleanup tracing
dm: remove incomplete BLOCK_PC support
dm: always defer request allocation to the owner of the request_queue
scsi: remove gfp_flags member in scsi_host_cmd_pool
scsi: respect unchecked_isa_dma for blk-mq
scsi: remove scsi_cmd_dma_pool
scsi: remove __scsi_alloc_queue
scsi: allocate scsi_cmnd structures as part of struct request
block/bsg: move queue creation into bsg_setup_queue
block: split scsi_request out of struct request
block: don't assign cmd_flags in __blk_rq_prep_clone
nvme/scsi: don't rely on BLK_MAX_CDB
skd: implement trivial scsi ioctls directly
block: make scsi_request and scsi ioctl support optional
virtio_blk: remove struct request backpointer from virtblk_req
virtio_blk: make SCSI passthrough support configurable
scm_blk: remove unneeded REQ_TYPE_FS check
ѕd: remove pointless REQ_TYPE_FS check
mmc: remove pointless request type check in mmc_prep_request
ms_block: remove pointless prep_fn
mspro_block: remove pointless prep_fn
nbd: remove REQ_TYPE_DRV_PRIV leftovers
nbd: move request validity checking into nbd_send_cmd
block: introduce blk_rq_is_passthrough
ide: don't abuse cmd_type
block: fold cmd_type into the REQ_OP_ space
dm: don't allow ioctls to targets that don't map to whole devices
block: move req_set_nomerge to blk.h
block: enumify ELEVATOR_*_MERGE
block: optionally merge discontiguous discard bios into a single request
nvme: support ranged discard requests
cciss: switch to pci_irq_alloc_vectors
block/sed-opal: tone down not supported warnings
block/sed-opal: allocate struct opal_dev dynamically
Christophe JAILLET (1):
gdrom: Add missing error code
Dan Williams (1):
scsi, block: fix duplicate bdi name registration crashes
Hannes Reinecke (3):
scsi_dh_rdac: switch to scsi_execute_req_flags()
scsi_dh_emc: switch to scsi_execute_req_flags()
scsi_dh_hp_sw: switch to scsi_execute_req_flags()
Hou Tao (1):
blkcg: fix double free of new_blkg in blkcg_init_queue
Jan Kara (5):
block: Unhash block device inodes on gendisk destruction
block: Use pointer to backing_dev_info from request_queue
block: Dynamically allocate and refcount backing_dev_info
block: Make blk_get_backing_dev_info() safe without open bdev
block: Get rid of blk_get_backing_dev_info()
Javier González (3):
lightnvm: Add CRC read error
lightnvm: free properly on target creation error
lightnvm: allow targets to use sysfs
Jens Axboe (43):
blk-mq: make mq_ops a const pointer
block: move existing elevator ops to union
block: move rq_ioc() to blk.h
blk-mq: un-export blk_mq_free_hctx_request()
blk-mq: export some helpers we need to the scheduling framework
blk-mq-tag: cleanup the normal/reserved tag allocation
blk-mq: abstract out helpers for allocating/freeing tag maps
blk-mq: add support for carrying internal tag information in blk_qc_t
blk-mq: split tag ->rqs[] into two
blk-mq-sched: add framework for MQ capable IO schedulers
mq-deadline: add blk-mq adaptation of the deadline IO scheduler
blk-mq-sched: allow setting of default IO scheduler
blk-cgroup: ensure that we clear the stop bit on quiesced queues
blk-cgroup: don't quiesce the queue on policy activate/deactivate
elevator: fix unnecessary put of elevator in failure case
blk-mq-tag: remove redundant check for 'data->hctx' being non-NULL
blk-mq: stop hardware queue in blk_mq_delay_queue()
blk-mq: allow resize of scheduler requests
blk-mq: only apply active queue tag throttling for driver tags
blk-mq: don't lose flags passed in to blk_mq_alloc_request()
blk-mq-sched: check for successful allocation before assigning tag
blk-mq: improve scheduler queue sync/async running
blk-mq: fix potential race in queue restart and driver tag allocation
blk-mq: release driver tag on a requeue event
blk-mq-sched: fix starvation for multiple hardware queues and shared tags
blk-mq-sched: change ->dispatch_requests() to ->dispatch_request()
blk-mq-sched: add flush insertion into blk_mq_sched_insert_request()
block: cleanup remaining manual checks for PREFLUSH|FUA
Merge branch 'for-4.11/block' into for-4.11/rq-refactor
nvme: fix compilation of scsi component
block: move internal_tag to same cache line as tag
blk-mq: don't fail allocating driver tag for stopped hw queue
zram_drv: update for backing dev info changes
blk-merge: return the merged request
block: free merged request in the caller
elevator: fix loading wrong elevator type for blk-mq devices
blk-mq: have blk_mq_dispatch_rq_list() return if we queued IO or not
blk-mq-sched: don't add flushes to the head of requeue queue
blk-mq: don't special case flush inserts for blk-mq-sched
blk-mq-sched: ask scheduler for work, if we failed dispatching leftovers
block: don't defer flushes on blk-mq + scheduling
Merge branch 'for-4.11/block' into for-4.11/linus-merge
Merge branch 'for-4.11/next' into for-4.11/linus-merge
Josef Bacik (4):
MAINTAINERS: Update maintainer entry for NBD
nbd: use our own workqueue for recv threads
nbd: use an idr to keep track of nbd devices
block: set make_request_fn manually in blk_mq_update_nr_hw_queues
Kees Cook (1):
cdrom: Make device operations read-only
Keith Busch (1):
nvme/pci: Don't mark IOD as aborted if abort wasn't sent
Markus Elfring (2):
blk-throttle: Adjust two function calls together with a variable assignment
cfq-iosched: Adjust one function call together with a variable assignment
Matias Bjørling (11):
lightnvm: merge gennvm with core
lightnvm: collapse nvm_erase_ppa and nvm_erase_blk
lightnvm: remove nvm_submit_ppa* functions
lightnvm: remove nvm_get_bb_tbl and nvm_set_bb_tbl
lightnvm: make nvm_map_* return void
lightnvm: cleanup nvm transformation functions
lightnvm: reduce number of nvm_id groups to one
lightnvm: add ioctls for vector I/Os
lightnvm: use end_io callback instead of instance
lightnvm: fix off-by-one error on target initialization
lightnvm: set default lun range when no luns are specified
Ming Lei (2):
block: relax check on sg gap
block/loop: fix race between I/O and set_status
Omar Sandoval (22):
sbitmap: use smp_mb__after_atomic() in sbq_wake_up()
sbitmap: fix wakeup hang after sbq resize
blk-mq: create debugfs directory tree
blk-mq: add hctx->{state,flags} to debugfs
blk-mq: move hctx->dispatch and ctx->rq_list from sysfs to debugfs
blk-mq: add extra request information to debugfs
sbitmap: add helpers for dumping to a seq_file
blk-mq: export software queue pending map to debugfs
blk-mq: move tags and sched_tags info from sysfs to debugfs
blk-mq: add tags and sched_tags bitmaps to debugfs
blk-mq: move hctx io_poll, stats, and dispatched from sysfs to debugfs
blk-mq: move hctx and ctx counters from sysfs to debugfs
blk-mq: fix debugfs compilation issues
debugfs: add debugfs_lookup()
block: fix debugfs config conditional in struct request_queue
blktrace: make do_blk_trace_setup() static
block: use same block debugfs directory for blk-mq and blktrace
blk-mq: move debugfs_remove() of disk dir to blk_release_queue()
blktrace: use existing disk debugfs directory
blk-mq-sched: bypass the scheduler for flushes entirely
blk-mq-sched: (un)register elevator when (un)registering queue
blk-mq-sched: don't hold queue_lock when calling exit_icq
Paolo Valente (1):
blk-mq: pass bio to blk_mq_sched_get_rq_priv
Scott Bauer (8):
Include: Uapi: Add user ABI for Sed/Opal
block: Add Sed-opal library
nvme: Add Support for Opal: Unlock from S3 & Opal Allocation/Ioctls
Fix SED-OPAL UAPI structs to prevent 32/64 bit size differences.
uapi: sed-opal fix IOW for activate lsp to use correct struct
Move stack parameters for sed_ioctl to prevent oversized stack with CONFIG_KASAN
Maintainers: Modify SED list from nvme to block
nvme: Check for Security send/recv support before issuing commands.
Tahsin Erdogan (2):
block: queue lock must be acquired when iterating over rls
block: do not allow updates through sysfs until registration completes
Tejun Heo (1):
block: fix double-free in the failure path of cgwb_bdi_init()
Vlastimil Babka (1):
floppy: replace wrong kmalloc(GFP_USER) with GFP_KERNEL
Documentation/cdrom/cdrom-standard.tex | 9 +-
MAINTAINERS | 15 +-
block/Kconfig | 24 +
block/Kconfig.iosched | 50 +
block/Makefile | 10 +-
block/bio.c | 16 +-
block/blk-cgroup.c | 32 +-
block/blk-core.c | 355 ++--
block/blk-exec.c | 22 +-
block/blk-flush.c | 26 +-
block/blk-integrity.c | 4 +-
block/blk-ioc.c | 34 +-
block/blk-map.c | 13 +-
block/blk-merge.c | 62 +-
block/blk-mq-debugfs.c | 772 +++++++++
block/blk-mq-sched.c | 515 ++++++
block/blk-mq-sched.h | 143 ++
block/blk-mq-sysfs.c | 235 +--
block/blk-mq-tag.c | 190 +-
block/blk-mq-tag.h | 10 +-
block/blk-mq.c | 590 ++++---
block/blk-mq.h | 72 +
block/blk-settings.c | 22 +-
block/blk-sysfs.c | 68 +-
block/blk-tag.c | 1 +
block/blk-throttle.c | 6 +-
block/blk-wbt.c | 8 +-
block/blk.h | 47 +-
block/bsg-lib.c | 49 +-
block/bsg.c | 64 +-
block/cfq-iosched.c | 14 +-
block/compat_ioctl.c | 7 +-
block/deadline-iosched.c | 14 +-
block/elevator.c | 267 ++-
block/genhd.c | 25 +-
block/ioctl.c | 7 +-
block/mq-deadline.c | 556 ++++++
block/noop-iosched.c | 2 +-
block/opal_proto.h | 452 +++++
block/partitions/efi.c | 17 +-
block/scsi_ioctl.c | 83 +-
block/sed-opal.c | 2488 +++++++++++++++++++++++++++
drivers/ata/libata-scsi.c | 4 +-
drivers/block/Kconfig | 13 +
drivers/block/aoe/aoeblk.c | 4 +-
drivers/block/cciss.c | 131 +-
drivers/block/cciss.h | 6 +-
drivers/block/drbd/drbd_main.c | 6 +-
drivers/block/drbd/drbd_nl.c | 12 +-
drivers/block/drbd/drbd_proc.c | 2 +-
drivers/block/drbd/drbd_req.c | 2 +-
drivers/block/floppy.c | 6 +-
drivers/block/hd.c | 45 +-
drivers/block/loop.c | 17 +-
drivers/block/mg_disk.c | 31 +-
drivers/block/nbd.c | 258 +--
drivers/block/null_blk.c | 10 +-
drivers/block/osdblk.c | 6 -
drivers/block/paride/Kconfig | 1 +
drivers/block/paride/pcd.c | 2 +-
drivers/block/paride/pd.c | 15 +-
drivers/block/pktcdvd.c | 12 +-
drivers/block/ps3disk.c | 15 +-
drivers/block/rbd.c | 24 +-
drivers/block/skd_main.c | 15 +-
drivers/block/sx8.c | 4 +-
drivers/block/virtio_blk.c | 205 ++-
drivers/block/xen-blkfront.c | 2 +-
drivers/block/xsysace.c | 2 +-
drivers/block/zram/zram_drv.c | 2 +-
drivers/cdrom/cdrom.c | 92 +-
drivers/cdrom/gdrom.c | 41 +-
drivers/ide/Kconfig | 1 +
drivers/ide/ide-atapi.c | 78 +-
drivers/ide/ide-cd.c | 192 ++-
drivers/ide/ide-cd_ioctl.c | 5 +-
drivers/ide/ide-cd_verbose.c | 6 +-
drivers/ide/ide-devsets.c | 13 +-
drivers/ide/ide-disk.c | 12 +-
drivers/ide/ide-eh.c | 8 +-
drivers/ide/ide-floppy.c | 37 +-
drivers/ide/ide-io.c | 13 +-
drivers/ide/ide-ioctls.c | 14 +-
drivers/ide/ide-park.c | 20 +-
drivers/ide/ide-pm.c | 20 +-
drivers/ide/ide-probe.c | 36 +-
drivers/ide/ide-tape.c | 41 +-
drivers/ide/ide-taskfile.c | 8 +-
drivers/ide/sis5513.c | 2 +-
drivers/lightnvm/Kconfig | 9 -
drivers/lightnvm/Makefile | 3 +-
drivers/lightnvm/core.c | 1027 ++++++-----
drivers/lightnvm/gennvm.c | 657 -------
drivers/lightnvm/gennvm.h | 62 -
drivers/lightnvm/rrpc.c | 7 +-
drivers/lightnvm/rrpc.h | 3 -
drivers/lightnvm/sysblk.c | 733 --------
drivers/md/bcache/request.c | 12 +-
drivers/md/bcache/super.c | 8 +-
drivers/md/dm-cache-target.c | 15 +-
drivers/md/dm-core.h | 1 -
drivers/md/dm-era-target.c | 2 +-
drivers/md/dm-mpath.c | 132 +-
drivers/md/dm-rq.c | 268 +--
drivers/md/dm-rq.h | 2 +-
drivers/md/dm-table.c | 2 +-
drivers/md/dm-target.c | 7 -
drivers/md/dm-thin.c | 15 +-
drivers/md/dm.c | 49 +-
drivers/md/dm.h | 3 +-
drivers/md/linear.c | 2 +-
drivers/md/md.c | 6 +-
drivers/md/multipath.c | 2 +-
drivers/md/raid0.c | 6 +-
drivers/md/raid1.c | 11 +-
drivers/md/raid10.c | 10 +-
drivers/md/raid5.c | 12 +-
drivers/memstick/core/ms_block.c | 11 -
drivers/memstick/core/mspro_block.c | 13 -
drivers/message/fusion/mptsas.c | 8 +-
drivers/mmc/core/queue.c | 9 -
drivers/mtd/mtd_blkdevs.c | 13 +-
drivers/mtd/ubi/block.c | 15 +-
drivers/nvme/host/core.c | 86 +-
drivers/nvme/host/fc.c | 2 +-
drivers/nvme/host/lightnvm.c | 315 +++-
drivers/nvme/host/nvme.h | 13 +
drivers/nvme/host/pci.c | 19 +-
drivers/nvme/host/rdma.c | 6 +-
drivers/nvme/host/scsi.c | 7 +-
drivers/nvme/target/loop.c | 2 +-
drivers/s390/block/scm_blk.c | 7 -
drivers/scsi/Kconfig | 1 +
drivers/scsi/device_handler/scsi_dh_emc.c | 247 +--
drivers/scsi/device_handler/scsi_dh_hp_sw.c | 222 +--
drivers/scsi/device_handler/scsi_dh_rdac.c | 174 +-
drivers/scsi/hosts.c | 24 +-
drivers/scsi/hpsa.c | 4 +-
drivers/scsi/libfc/fc_lport.c | 2 +-
drivers/scsi/libsas/sas_expander.c | 8 +-
drivers/scsi/libsas/sas_host_smp.c | 38 +-
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +-
drivers/scsi/mpt3sas/mpt3sas_transport.c | 8 +-
drivers/scsi/osd/osd_initiator.c | 22 +-
drivers/scsi/osst.c | 18 +-
drivers/scsi/qla2xxx/qla_bsg.c | 2 +-
drivers/scsi/qla2xxx/qla_isr.c | 6 +-
drivers/scsi/qla2xxx/qla_mr.c | 2 +-
drivers/scsi/scsi.c | 354 +---
drivers/scsi/scsi_error.c | 43 +-
drivers/scsi/scsi_lib.c | 264 ++-
drivers/scsi/scsi_priv.h | 5 +-
drivers/scsi/scsi_transport_fc.c | 34 +-
drivers/scsi/scsi_transport_iscsi.c | 14 +-
drivers/scsi/scsi_transport_sas.c | 5 +
drivers/scsi/sd.c | 48 +-
drivers/scsi/sg.c | 33 +-
drivers/scsi/smartpqi/smartpqi_init.c | 2 +-
drivers/scsi/sr.c | 11 +-
drivers/scsi/st.c | 28 +-
drivers/scsi/sun3_scsi.c | 2 +-
drivers/target/Kconfig | 1 +
drivers/target/target_core_pscsi.c | 14 +-
fs/block_dev.c | 22 +
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/volumes.c | 2 +-
fs/debugfs/inode.c | 36 +
fs/gfs2/ops_fstype.c | 2 +-
fs/nfsd/Kconfig | 1 +
fs/nfsd/blocklayout.c | 19 +-
fs/nilfs2/super.c | 2 +-
fs/super.c | 2 +-
fs/xfs/xfs_buf.c | 3 +-
fs/xfs/xfs_buf.h | 1 -
include/linux/backing-dev-defs.h | 2 +
include/linux/backing-dev.h | 12 +-
include/linux/blk-mq.h | 9 +-
include/linux/blk_types.h | 38 +-
include/linux/blkdev.h | 124 +-
include/linux/blktrace_api.h | 18 +-
include/linux/bsg-lib.h | 5 +-
include/linux/cdrom.h | 5 +-
include/linux/debugfs.h | 8 +
include/linux/device-mapper.h | 3 -
include/linux/elevator.h | 63 +-
include/linux/fs.h | 2 +
include/linux/genhd.h | 8 +
include/linux/ide.h | 58 +-
include/linux/lightnvm.h | 138 +-
include/linux/nvme.h | 3 +
include/linux/sbitmap.h | 30 +
include/linux/sed-opal.h | 70 +
include/scsi/scsi_cmnd.h | 4 +-
include/scsi/scsi_host.h | 5 -
include/scsi/scsi_request.h | 30 +
include/scsi/scsi_transport.h | 2 +
include/trace/events/block.h | 27 +-
include/uapi/linux/lightnvm.h | 50 +
include/uapi/linux/sed-opal.h | 119 ++
kernel/trace/blktrace.c | 78 +-
lib/sbitmap.c | 139 +-
mm/backing-dev.c | 43 +-
mm/page-writeback.c | 4 +-
203 files changed, 9729 insertions(+), 5577 deletions(-)
create mode 100644 block/blk-mq-debugfs.c
create mode 100644 block/blk-mq-sched.c
create mode 100644 block/blk-mq-sched.h
create mode 100644 block/mq-deadline.c
create mode 100644 block/opal_proto.h
create mode 100644 block/sed-opal.c
delete mode 100644 drivers/lightnvm/gennvm.c
delete mode 100644 drivers/lightnvm/gennvm.h
delete mode 100644 drivers/lightnvm/sysblk.c
create mode 100644 include/linux/sed-opal.h
create mode 100644 include/scsi/scsi_request.h
create mode 100644 include/uapi/linux/sed-opal.h
--
Jens Axboe
^ permalink raw reply
* [PATCH] lightnvm: Fix error handling
From: Christophe JAILLET @ 2017-02-19 14:09 UTC (permalink / raw)
To: mb; +Cc: linux-block, linux-kernel, kernel-janitors, Christophe JAILLET
According to error handling in this function, it is likely that going to
'out' was expected here.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/lightnvm/rrpc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index e00b1d7b976f..e68efbcf1188 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -1275,8 +1275,10 @@ static int rrpc_bb_discovery(struct nvm_tgt_dev *dev, struct rrpc_lun *rlun)
}
nr_blks = nvm_bb_tbl_fold(dev->parent, blks, nr_blks);
- if (nr_blks < 0)
- return nr_blks;
+ if (nr_blks < 0) {
+ ret = nr_blks;
+ goto out;
+ }
for (i = 0; i < nr_blks; i++) {
if (blks[i] == NVM_BLK_T_FREE)
--
2.9.3
^ permalink raw reply related
* Re: [PATCHv3,4/4] MAINTAINERS: Remove powerpc's opal match
From: Michael Ellerman @ 2017-02-19 11:33 UTC (permalink / raw)
To: Stewart Smith, Jon Derrick
Cc: Jens Axboe, Rafael Antognolli, Greg Kroah-Hartman, linux-kernel,
linux-block, Jon Derrick, linuxppc-dev, Christoph Hellwig,
Scott Bauer
In-Reply-To: <87h93v7yys.fsf@linux.vnet.ibm.com>
On Thu, 2017-02-16 at 00:37:15 UTC, Stewart Smith wrote:
> Remove OPAL regex in powerpc to avoid false match
>
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/a42715830d552d7c0e3be709383ece
cheers
^ permalink raw reply
* Re: [PATCHv2] scsi: use 'scsi_device_from_queue()' for scsi_dh
From: Mike Snitzer @ 2017-02-19 5:59 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Hannes Reinecke, Keith Busch, Martin K. Petersen,
linux-scsi@vger.kernel.org, Bart van Assche, Hannes Reinecke,
device-mapper development, linux-block
In-Reply-To: <20170217082752.GA18258@lst.de>
On Fri, Feb 17, 2017 at 3:27 AM, Christoph Hellwig <hch@lst.de> wrote:
>
> On Fri, Feb 17, 2017 at 09:06:14AM +0100, Hannes Reinecke wrote:
> > We could, but why?
> > ATM we're only having SCSI devices able to use device handler; adding
> > another layer of indirection doesn't solve anything here.
> > Moving the infrastructure one level up will only make sense if we're
> > getting non-SCSI device handler (ANA?), but until then I'd think it's
> > just overengineering.
>
> Agreed. Independent of what does the balancing between queues hardware
> handler should be attached by the low-level driver for any future
> transport without any control from DM.
But doesn't Keith's abstraction makes a lot of sense given that you're
providing a device handler interface for NVMe?
The most important part of scsi_dh that DM uses is its calls to
scsi_dh_activate. Attachment isn't interesting or the issue (DM's
call to scsi_dh_attach is purely legacy now that SCSI attaches the
proper scsi_dh during SCSI's device scan).
^ permalink raw reply
* Re: [PATCHv2 4/5] block/sed: Embed function data into the function sequence
From: Christoph Hellwig @ 2017-02-18 16:22 UTC (permalink / raw)
To: Scott Bauer
Cc: Christoph Hellwig, Jon Derrick, Jens Axboe, Rafael Antognolli,
linux-nvme, linux-block, Scott Bauer
In-Reply-To: <d6d1c65a-4422-97d7-8ee8-fef46159b143@eng.utah.edu>
On Sat, Feb 18, 2017 at 08:52:19AM -0700, Scott Bauer wrote:
> >> +static int set_mbr_done(struct opal_dev *dev, void *data)
> >> {
> >> - u8 mbr_done_tf = *(u8 *)dev->func_data[dev->state];
> >> + u8 mbr_done_tf = *(u8 *)data;
> >
> > No need for casts when going from void * to any pointer type. There are
> > a couple more instance below where the cast should be removed as well.
>
> In this case he's actually casting & dereferencing the pointer, so it should be fine in this scenario?
Oh, right. As-is we'll obviously need the casts. But what we could
do instead is the following:
u8 *mbr_done_tf = data;
..
add_token_u8(&err, dev, *mbr_done_tf); /* Done T or F */
or alternatively just pass the whole struct opal_mbr_data pointer
as the private data.
^ permalink raw reply
* Re: [PATCH] block/sed-opal: Introduce free_opal_dev to free the structure and clean up state
From: Christoph Hellwig @ 2017-02-18 16:14 UTC (permalink / raw)
To: Scott Bauer; +Cc: linux-block, axboe, keith.busch, jonathan.derrick, hch
In-Reply-To: <1487352313-3539-1-git-send-email-scott.bauer@intel.com>
On Fri, Feb 17, 2017 at 10:25:13AM -0700, Scott Bauer wrote:
> Before we free the opal structure we need to clean up any saved
> locking ranges that the user had told us to unlock from a suspend.
> Also fixup a list_for_each to list_for_each_safe in the save path.
>
> Signed-off-by: Scott Bauer <scott.bauer@intel.com>
This looks fine to me, but I think the fix to add_suspend_info
should be a separate patch:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply
* Re: [PATCHv2 4/5] block/sed: Embed function data into the function sequence
From: Scott Bauer @ 2017-02-18 15:52 UTC (permalink / raw)
To: Christoph Hellwig, Jon Derrick
Cc: Jens Axboe, Rafael Antognolli, linux-block, Scott Bauer,
linux-nvme
In-Reply-To: <20170218083605.GB11798@lst.de>
On 02/18/2017 01:36 AM, Christoph Hellwig wrote:
> Hi Jon,
>
> I think this is a great cleanup!
>
> A few nitpicky comments below:
>
>> -typedef int (*opal_step)(struct opal_dev *dev);
>> +typedef struct opal_step {
>> + int (*fn)(struct opal_dev *dev, void *data);
>> + void *data;
>> +} opal_step;
>
> no typedefs for structure types, please.
>
>> + opal_step *funcs;
>
> maybe calls this member steps?
>
>> +static int set_mbr_done(struct opal_dev *dev, void *data)
>> {
>> - u8 mbr_done_tf = *(u8 *)dev->func_data[dev->state];
>> + u8 mbr_done_tf = *(u8 *)data;
>
> No need for casts when going from void * to any pointer type. There are
> a couple more instance below where the cast should be removed as well.
In this case he's actually casting & dereferencing the pointer, so it should be fine in this scenario?
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply
* Re: [PATCHv2 5/5] block/sed: Eliminate state variable
From: Christoph Hellwig @ 2017-02-18 8:36 UTC (permalink / raw)
To: Jon Derrick
Cc: linux-block, linux-nvme, Scott Bauer, Rafael Antognolli,
Jens Axboe, Christoph Hellwig
In-Reply-To: <1487376029-22662-6-git-send-email-jonathan.derrick@intel.com>
Looks fine:
Reviewed-by: Christoph Hellwig <hch@lst.de>
But I would just fold it into the previous patch.
^ permalink raw reply
* Re: [PATCHv2 4/5] block/sed: Embed function data into the function sequence
From: Christoph Hellwig @ 2017-02-18 8:36 UTC (permalink / raw)
To: Jon Derrick
Cc: Jens Axboe, Rafael Antognolli, linux-nvme, linux-block,
Christoph Hellwig, Scott Bauer
In-Reply-To: <1487376029-22662-5-git-send-email-jonathan.derrick@intel.com>
Hi Jon,
I think this is a great cleanup!
A few nitpicky comments below:
> -typedef int (*opal_step)(struct opal_dev *dev);
> +typedef struct opal_step {
> + int (*fn)(struct opal_dev *dev, void *data);
> + void *data;
> +} opal_step;
no typedefs for structure types, please.
> + opal_step *funcs;
maybe calls this member steps?
> +static int set_mbr_done(struct opal_dev *dev, void *data)
> {
> - u8 mbr_done_tf = *(u8 *)dev->func_data[dev->state];
> + u8 mbr_done_tf = *(u8 *)data;
No need for casts when going from void * to any pointer type. There are
a couple more instance below where the cast should be removed as well.
> +static int __opal_lock_unlock(struct opal_dev *dev,
> + struct opal_lock_unlock *lk_unlk)
> {
> + opal_step _unlock_funcs[] = {
> + { opal_discovery0, },
> + { start_auth_opal_session, &lk_unlk->session },
> + { NULL, lk_unlk },
> + { end_opal_session, },
> + { NULL, }
> };
>
> + if (lk_unlk->session.sum)
> + _unlock_funcs[2].fn = lock_unlock_locking_range_sum;
> + else
> + _unlock_funcs[2].fn = lock_unlock_locking_range;
>
> dev->funcs = _unlock_funcs;
I would suggest to just have two different arrays, and merge
__opal_lock_unlock into opal_lock_unlock. E.g. something like:
static int opal_lock_unlock(struct opal_dev *dev,
struct opal_lock_unlock *lk_unlk)
{
const struct opal_step unlock_funcs[] = {
{ opal_discovery0, },
{ start_auth_opal_session, &lk_unlk->session },
{ lock_unlock_locking_range, lk_unlk },
{ end_opal_session, },
{ NULL, }
};
const struct opal_step unlock_sun_funcs[] = {
{ opal_discovery0, },
{ start_auth_opal_session, &lk_unlk->session },
{ lock_unlock_locking_range_sum, lk_unlk },
{ end_opal_session, },
{ NULL, }
};
int ret;
if (lk_unlk->session.who < OPAL_ADMIN1 ||
lk_unlk->session.who > OPAL_USER9)
return -EINVAL;
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, lk_unlk->session.sum ?
unlock_sum_funcs : unlock_funcs);
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
}
and yes, I noticed that all the opal_step structures really should
be marked const, especially given that they contain function pointers
and are potential exploit targets. Please apply that everywhere.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply
* Re: [PATCHv2 0/5] OPAL patche'd cont'd
From: Christoph Hellwig @ 2017-02-18 8:24 UTC (permalink / raw)
To: Jon Derrick
Cc: linux-block, linux-nvme, Scott Bauer, Rafael Antognolli,
Jens Axboe, Christoph Hellwig
In-Reply-To: <1487376029-22662-1-git-send-email-jonathan.derrick@intel.com>
On Fri, Feb 17, 2017 at 05:00:24PM -0700, Jon Derrick wrote:
> v1->v2:
> Moved misplaced code from 5/5 to 4/5
>
> The first three in the series have been reviewed already but I wanted to
> squash them with the next two since they haven't been pulled yet.
Next time please carry the reviewed-by tags over to make everyones
life easier.
^ permalink raw reply
* Re: Some throughput tests with MQ and BFQ on MMC/SD
From: Ziji Hu @ 2017-02-18 4:57 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-mmc@vger.kernel.org, linux-block, Ulf Hansson,
Adrian Hunter, Ritesh Harjani, Avri Altman, Arnd Bergmann,
Christoph Hellwig, Jens Axboe, Paolo Valente, Per Förlin
In-Reply-To: <CACRpkda+p4erE9CdMUWi55-Ji8rj8TNOeJadHeOkHT7a1wbLmA@mail.gmail.com>
Hi Linus,
On 2017/2/17 21:22, Linus Walleij wrote:
> On Fri, Feb 17, 2017 at 12:53 PM, Ziji Hu <huziji@marvell.com> wrote:
>
>> I would like to suggest that you should try the multiple thread
>> test mode of iozone, since you are testing *Multi* Queue.
>
> Good point. This target has only 2 CPUs but still, maybe it performs!
>
In my very own opinion, (although I'm not the expert of marketing),
quad-core platforms will be more and more popular.
Quad-core might have a different result, especially when we are
testing multiple threads.
>> Besides, it seems that your eMMC transfer speed is quite low.
>> It is normal that read speed can reach more than 100MB/s in HS400.
>> Could you try a higher speed mode? The test result might be
>> limited by the bus clock frequency.
>
> The iozone tests are done on an SDcard. And I only did read tests on
> the eMMC I have.
>
> It's because I'm afriad of wearing out my eMMC :(
>
> But OK I'll just take the risk and run iozone on the eMMC.
>
Actually, there is a parameter to limit the size of test file in iozone.
I'm not sure why you need to scan the whole eMMC. But I personally
believe it is unnecessary.
Sorry for delay reply. Hope your eMMC is not broken yet. :p
eMMC usually contains much more physical pages than the capacity
it shows. Thus I guess your eMMC should be fine unless you torture
it by entirely writing it again and again.
>> Actually I have been following your thread for some time.
>> But currently I'm a little confused.
>> May I know the purpose of your patch?
>
> Ulf describes it: we want to switch MMC/SD to MQ.
>
> To me, there are two reasons for that (no secret agendas...)
>
> 1. To get away from the legacy codebase in the old block layer.
> Christoph and Jens have been very clear stating that the old block
> layer is in maintenance mode and should be phased out, and they
> asked explicitly for out help to do so. Currently
> MMC/SD is a big fat roadblock to these plans so it is win-win for
> MMC/SD and the block layer if we can just switch over to MQ.
>
> 2. My colleague Paolo Valente is working on the next generation
> block scheduler BFQ which has very promising potential for
> interactive loads. (Like taking a backup of your harddrive while
> playing 1080p video let's say.) Since the
> old block layer is no longer maintained, this scheduler will only
> be merged and made available for systems deploying MQ. He's
> already working full steam on that.
>
> I would like to make 1+2 happen in the next merge window
> ultimately, but yeah, maybe I'm overly optimistic. But I will sure
> try.
I see. Thank you for the details.
>
> Maybe I should add:
>
> 3. MQ is a better and future-proof fit for command queueing.
I strongly agree with you on it.
Thank you.
Best regards,
Hu Ziji
>
> Yours,
> Linus Walleij
>
^ permalink raw reply
* Re: Some throughput tests with MQ and BFQ on MMC/SD
From: Ziji Hu @ 2017-02-18 4:36 UTC (permalink / raw)
To: Ulf Hansson
Cc: Linus Walleij, linux-mmc@vger.kernel.org, linux-block,
Adrian Hunter, Ritesh Harjani, Avri Altman, Arnd Bergmann,
Christoph Hellwig, Jens Axboe, Paolo Valente, Per Förlin
In-Reply-To: <CAPDyKFo_-SykPX5LjUB2VMBVaa05EPJ0OYzpCLCpCO9Sug+Feg@mail.gmail.com>
Hi Ulf,
On 2017/2/17 20:09, Ulf Hansson wrote:
> [...]
>
>>
>> I would like to suggest that you should try the multiple thread
>> test mode of iozone, since you are testing *Multi* Queue.
>
> Yes. That seems reasonable.
>
> However, the most important part here is the comparison between the
> different code bases.
>
>>
>> Besides, it seems that your eMMC transfer speed is quite low.
>> It is normal that read speed can reach more than 100MB/s in HS400.
>> Could you try a higher speed mode? The test result might be
>> limited by the bus clock frequency.
>
> Perhaps if Linus can share a branch of the code integrated for the
> different tests, we all can help out running them on those HW we have
> at hand. Would you be willing to help out here?
>
I'm glad to.
But my available platforms all stay in Linux v4.4/v4.1.
I can help when my platforms can upgrade.
>>
>>>
>>> As you can see there are no huge performance regressions with these
>>> kinds of "raw" throughput tests.
>>>
>>> These iozone figures are unintuitive unless your head can
>>> plot logarithmic, look at the charts here for a more visual presentation
>>> of the iozone results:
>>> https://docs.google.com/spreadsheets/d/1rm72TiGlTnzDeGLR__aqvjcJ2UkA-Ro3-XyKA8r1M-c
>>>
>>> Compare this to the performance change we got when first introducing
>>> the asynchronous requests:
>>> https://wiki.linaro.org/WorkingGroups/KernelArchived/Specs/StoragePerfMMC-async-req
>>>
>>> The patches need some issues fixed from the build server
>>> complaints and some robustness hammering, but after that I
>>> think they will be ripe for merging for v4.12.
>>>
>>
>> Actually I have been following your thread for some time.
>> But currently I'm a little confused.
>> May I know the purpose of your patch?
>
> I want MMC to move to the new BLKMQ interface and I want that because
> of several reasons, see below.
>
> 1. It's new blk interface, all new development happens here. We should
> use it to benefit from that.
> 2. The BLKMQ interface allow the MMC block device driver to be
> significantly cleaner implemented - and I need that to be able to
> maintain the code.
> 3. We want to make use of Paolo's BFQ-MK I/O scheduler, which
> addresses provides guaranteed low latency. For example being able to
> play a video clip, while doing a disc backup without getting frame
> drops.
>
Got it. Thanks a lot for your detailed explanation.
If we focus on the low latency, we shall get a cleaner result
of IOPS in tests.
IOPS is a more common performance index in eMMC/SD.
Thank you.
Best regards,
Hu Ziji
> Kind regards
> Uffe
>
^ permalink raw reply
* Re: [PATCH 1/2] blk-mq: use sbq wait queues instead of restart for driver tags
From: Jens Axboe @ 2017-02-18 3:08 UTC (permalink / raw)
To: Omar Sandoval, linux-block; +Cc: kernel-team
In-Reply-To: <d91d1df06ad9292459400637118bca8d09c88dcf.1487379857.git.osandov@fb.com>
On 02/17/2017 06:05 PM, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> Commit 50e1dab86aa2 ("blk-mq-sched: fix starvation for multiple hardware
> queues and shared tags") fixed one starvation issue for shared tags.
> However, we can still get into a situation where we fail to allocate a
> tag because all tags are allocated but we don't have any pending
> requests on any hardware queue.
>
> One solution for this would be to restart all queues that share a tag
> map, but that really sucks. Ideally, we could just block and wait for a
> tag, but that isn't always possible from blk_mq_dispatch_rq_list().
>
> However, we can still use the struct sbitmap_queue wait queues with a
> custom callback instead of blocking. This has a few benefits:
>
> 1. It avoids iterating over all hardware queues when completing an I/O,
> which the current restart code has to do.
> 2. It benefits from the existing rolling wakeup code.
> 3. It avoids punting to another thread just to have it block.
This is a great and innovative solution to this problem, it's much
better than stacked restart bits. Thanks Omar, I'll queue this up
for testing.
--
Jens Axboe
^ permalink raw reply
* [PATCH 2/2] blk-mq-sched: separate mark hctx and queue restart operations
From: Omar Sandoval @ 2017-02-18 1:05 UTC (permalink / raw)
To: Jens Axboe, linux-block; +Cc: kernel-team
In-Reply-To: <d91d1df06ad9292459400637118bca8d09c88dcf.1487379857.git.osandov@fb.com>
From: Omar Sandoval <osandov@fb.com>
In blk_mq_sched_dispatch_requests(), we call blk_mq_sched_mark_restart()
after we dispatch requests left over on our hardware queue dispatch
list. This is so we'll go back and dispatch requests from the scheduler.
In this case, it's only necessary to restart the hardware queue that we
are running; there's no reason to run other hardware queues just because
we are using shared tags.
So, split out blk_mq_sched_mark_restart() into two operations, one for
just the hardware queue and one for the whole request queue. The core
code only needs the hctx variant, but I/O schedulers will want to use
both.
This also requires adjusting blk_mq_sched_restart_queues() to always
check the queue restart flag, not just when using shared tags.
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
block/blk-mq-sched.c | 20 ++++++++------------
block/blk-mq-sched.h | 26 ++++++++++++++++++--------
2 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index 97fe904f0a04..aa27ecab0d3f 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -203,7 +203,7 @@ void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx)
* needing a restart in that case.
*/
if (!list_empty(&rq_list)) {
- blk_mq_sched_mark_restart(hctx);
+ blk_mq_sched_mark_restart_hctx(hctx);
blk_mq_dispatch_rq_list(hctx, &rq_list);
} else if (!e || !e->type->ops.mq.dispatch_request) {
blk_mq_flush_busy_ctxs(hctx, &rq_list);
@@ -322,20 +322,16 @@ static void blk_mq_sched_restart_hctx(struct blk_mq_hw_ctx *hctx)
void blk_mq_sched_restart_queues(struct blk_mq_hw_ctx *hctx)
{
+ struct request_queue *q = hctx->queue;
unsigned int i;
- if (!(hctx->flags & BLK_MQ_F_TAG_SHARED))
+ if (test_bit(QUEUE_FLAG_RESTART, &q->queue_flags)) {
+ if (test_and_clear_bit(QUEUE_FLAG_RESTART, &q->queue_flags)) {
+ queue_for_each_hw_ctx(q, hctx, i)
+ blk_mq_sched_restart_hctx(hctx);
+ }
+ } else {
blk_mq_sched_restart_hctx(hctx);
- else {
- struct request_queue *q = hctx->queue;
-
- if (!test_bit(QUEUE_FLAG_RESTART, &q->queue_flags))
- return;
-
- clear_bit(QUEUE_FLAG_RESTART, &q->queue_flags);
-
- queue_for_each_hw_ctx(q, hctx, i)
- blk_mq_sched_restart_hctx(hctx);
}
}
diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h
index 7b5f3b95c78e..a75b16b123f7 100644
--- a/block/blk-mq-sched.h
+++ b/block/blk-mq-sched.h
@@ -122,17 +122,27 @@ static inline bool blk_mq_sched_has_work(struct blk_mq_hw_ctx *hctx)
return false;
}
-static inline void blk_mq_sched_mark_restart(struct blk_mq_hw_ctx *hctx)
+/*
+ * Mark a hardware queue as needing a restart.
+ */
+static inline void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx)
{
- if (!test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state)) {
+ if (!test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
set_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
- if (hctx->flags & BLK_MQ_F_TAG_SHARED) {
- struct request_queue *q = hctx->queue;
+}
+
+/*
+ * Mark a hardware queue and the request queue it belongs to as needing a
+ * restart.
+ */
+static inline void blk_mq_sched_mark_restart_queue(struct blk_mq_hw_ctx *hctx)
+{
+ struct request_queue *q = hctx->queue;
- if (!test_bit(QUEUE_FLAG_RESTART, &q->queue_flags))
- set_bit(QUEUE_FLAG_RESTART, &q->queue_flags);
- }
- }
+ if (!test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state))
+ set_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
+ if (!test_bit(QUEUE_FLAG_RESTART, &q->queue_flags))
+ set_bit(QUEUE_FLAG_RESTART, &q->queue_flags);
}
static inline bool blk_mq_sched_needs_restart(struct blk_mq_hw_ctx *hctx)
--
2.11.1
^ permalink raw reply related
* [PATCH 1/2] blk-mq: use sbq wait queues instead of restart for driver tags
From: Omar Sandoval @ 2017-02-18 1:05 UTC (permalink / raw)
To: Jens Axboe, linux-block; +Cc: kernel-team
From: Omar Sandoval <osandov@fb.com>
Commit 50e1dab86aa2 ("blk-mq-sched: fix starvation for multiple hardware
queues and shared tags") fixed one starvation issue for shared tags.
However, we can still get into a situation where we fail to allocate a
tag because all tags are allocated but we don't have any pending
requests on any hardware queue.
One solution for this would be to restart all queues that share a tag
map, but that really sucks. Ideally, we could just block and wait for a
tag, but that isn't always possible from blk_mq_dispatch_rq_list().
However, we can still use the struct sbitmap_queue wait queues with a
custom callback instead of blocking. This has a few benefits:
1. It avoids iterating over all hardware queues when completing an I/O,
which the current restart code has to do.
2. It benefits from the existing rolling wakeup code.
3. It avoids punting to another thread just to have it block.
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
block/blk-mq.c | 60 ++++++++++++++++++++++++++++++++++++++++++++------
include/linux/blk-mq.h | 2 ++
2 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5564a9d103ca..0dacb743d4d7 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -904,6 +904,44 @@ static bool reorder_tags_to_front(struct list_head *list)
return first != NULL;
}
+static int blk_mq_dispatch_wake(wait_queue_t *wait, unsigned mode, int flags,
+ void *key)
+{
+ struct blk_mq_hw_ctx *hctx;
+
+ hctx = container_of(wait, struct blk_mq_hw_ctx, dispatch_wait);
+
+ list_del(&wait->task_list);
+ clear_bit_unlock(BLK_MQ_S_TAG_WAITING, &hctx->state);
+ blk_mq_run_hw_queue(hctx, true);
+ return 1;
+}
+
+static bool blk_mq_dispatch_wait_add(struct blk_mq_hw_ctx *hctx)
+{
+ struct sbq_wait_state *ws;
+
+ /*
+ * The TAG_WAITING bit serves as a lock protecting hctx->dispatch_wait.
+ * The thread which wins the race to grab this bit adds the hardware
+ * queue to the wait queue.
+ */
+ if (test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state) ||
+ test_and_set_bit_lock(BLK_MQ_S_TAG_WAITING, &hctx->state))
+ return false;
+
+ init_waitqueue_func_entry(&hctx->dispatch_wait, blk_mq_dispatch_wake);
+ ws = bt_wait_ptr(&hctx->tags->bitmap_tags, hctx);
+
+ /*
+ * As soon as this returns, it's no longer safe to fiddle with
+ * hctx->dispatch_wait, since a completion can wake up the wait queue
+ * and unlock the bit.
+ */
+ add_wait_queue(&ws->wait, &hctx->dispatch_wait);
+ return true;
+}
+
bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
{
struct request_queue *q = hctx->queue;
@@ -926,20 +964,27 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list)
struct blk_mq_queue_data bd;
rq = list_first_entry(list, struct request, queuelist);
- if (!blk_mq_get_driver_tag(rq, &hctx, false)) {
+ if (!blk_mq_get_driver_tag(rq, NULL, false)) {
if (!queued && reorder_tags_to_front(list))
continue;
/*
- * We failed getting a driver tag. Mark the queue(s)
- * as needing a restart. Retry getting a tag again,
- * in case the needed IO completed right before we
- * marked the queue as needing a restart.
+ * The initial allocation attempt failed, so we need to
+ * rerun the hardware queue when a tag is freed.
*/
- blk_mq_sched_mark_restart(hctx);
- if (!blk_mq_get_driver_tag(rq, &hctx, false))
+ if (blk_mq_dispatch_wait_add(hctx)) {
+ /*
+ * It's possible that a tag was freed in the
+ * window between the allocation failure and
+ * adding the hardware queue to the wait queue.
+ */
+ if (!blk_mq_get_driver_tag(rq, NULL, false))
+ break;
+ } else {
break;
+ }
}
+
list_del_init(&rq->queuelist);
bd.rq = rq;
@@ -1051,6 +1096,7 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx)
void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
{
if (unlikely(blk_mq_hctx_stopped(hctx) ||
+ test_bit(BLK_MQ_S_TAG_WAITING, &hctx->state) ||
!blk_mq_hw_queue_mapped(hctx)))
return;
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 8e4df3d6c8cd..001d30d727c5 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -33,6 +33,7 @@ struct blk_mq_hw_ctx {
struct blk_mq_ctx **ctxs;
unsigned int nr_ctx;
+ wait_queue_t dispatch_wait;
atomic_t wait_index;
struct blk_mq_tags *tags;
@@ -160,6 +161,7 @@ enum {
BLK_MQ_S_STOPPED = 0,
BLK_MQ_S_TAG_ACTIVE = 1,
BLK_MQ_S_SCHED_RESTART = 2,
+ BLK_MQ_S_TAG_WAITING = 3,
BLK_MQ_MAX_DEPTH = 10240,
--
2.11.1
^ permalink raw reply related
* Re: Manual driver binding and unbinding broken for SCSI
From: James Bottomley @ 2017-02-18 0:43 UTC (permalink / raw)
To: Omar Sandoval, Dan Williams, Jan Kara, Martin K. Petersen
Cc: Jens Axboe, linux-scsi, linux-block
In-Reply-To: <20170218003015.GA19776@vader.DHCP.thefacebook.com>
On Fri, 2017-02-17 at 16:30 -0800, Omar Sandoval wrote:
> Hi, everyone,
>
> As per $SUBJECT, I can cause a crash on v4.10-rc8, Jens' block/for
> -next,
> and Jan's bdi branch [1] by doing this:
>
> # lsscsi
> [0:0:0:0] disk QEMU QEMU HARDDISK 2.5+ /dev/sda
> # echo 0:0:0:0 > /sys/bus/scsi/drivers/sd/unbind
> # echo 0:0:0:0 > /sys/bus/scsi/drivers/sd/bind
>
> The resulting trace looks like this:
>
> [ 19.347924] kobject (ffff8800791ea0b8): tried to init an
> initialized object, something is seriously wrong.
> [ 19.349781] CPU: 1 PID: 84 Comm: kworker/u8:1 Not tainted 4.10.0
> -rc7-00210-g53f39eeaa263 #34
> [ 19.350686] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> BIOS 1.10.1-20161122_114906-anatol 04/01/2014
> [ 19.350920] Workqueue: events_unbound async_run_entry_fn
> [ 19.350920] Call Trace:
> [ 19.350920] dump_stack+0x63/0x83
> [ 19.350920] kobject_init+0x77/0x90
> [ 19.350920] blk_mq_register_dev+0x40/0x130
> [ 19.350920] blk_register_queue+0xb6/0x190
> [ 19.350920] device_add_disk+0x1ec/0x4b0
> [ 19.350920] sd_probe_async+0x10d/0x1c0 [sd_mod]
> [ 19.350920] async_run_entry_fn+0x48/0x150
> [ 19.350920] process_one_work+0x1d0/0x480
> [ 19.350920] worker_thread+0x48/0x4e0
> [ 19.350920] kthread+0x101/0x140
> [ 19.350920] ? process_one_work+0x480/0x480
> [ 19.350920] ? kthread_create_on_node+0x60/0x60
> [ 19.350920] ret_from_fork+0x2c/0x40
>
> Additionally, on v4.10-rc8, but not on block/for-next or Jan's
> branch,
> doing this:
>
> # echo 0:0:0:0 > /sys/bus/scsi/drivers/sd/unbind
> # modprobe scsi_debug
>
> Causes this trace:
>
> [ 18.876096] ------------[ cut here ]------------
> [ 18.877057] WARNING: CPU: 1 PID: 90 at fs/sysfs/dir.c:31
> sysfs_warn_dup+0x62/0x80
> [ 18.878270] sysfs: cannot create duplicate filename
> '/devices/virtual/bdi/8:0'
> [ 18.879435] Modules linked in: scsi_debug btrfs xor raid6_pq
> sd_mod virtio_scsi scsi_mod nvme nvme_core virtio_net
> [ 18.881118] CPU: 1 PID: 90 Comm: kworker/u8:2 Not tainted 4.10.0
> -rc8 #34
> [ 18.882114] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> BIOS 1.10.1-20161122_114906-anatol 04/01/2014
> [ 18.883872] Workqueue: events_unbound async_run_entry_fn
> [ 18.884408] Call Trace:
> [ 18.884408] dump_stack+0x63/0x83
> [ 18.884408] __warn+0xcb/0xf0
> [ 18.884408] warn_slowpath_fmt+0x5f/0x80
> [ 18.884408] ? kernfs_path_from_node+0x4f/0x60
> [ 18.884408] sysfs_warn_dup+0x62/0x80
> [ 18.884408] sysfs_create_dir_ns+0x77/0x90
> [ 18.884408] kobject_add_internal+0xbe/0x350
> [ 18.884408] kobject_add+0x75/0xd0
> [ 18.884408] device_add+0x121/0x680
> [ 18.884408] device_create_groups_vargs+0xe0/0xf0
> [ 18.884408] device_create_vargs+0x1c/0x20
> [ 18.884408] bdi_register+0x90/0x1b0
> [ 18.884408] ? sd_revalidate_disk+0x34a/0x1d00 [sd_mod]
> [ 18.884408] bdi_register_owner+0x36/0x60
> [ 18.884408] device_add_disk+0x165/0x4a0
> [ 18.884408] ? update_autosuspend+0x51/0x60
> [ 18.884408] ? __pm_runtime_use_autosuspend+0x5c/0x70
> [ 18.884408] sd_probe_async+0x10d/0x1c0 [sd_mod]
> [ 18.884408] async_run_entry_fn+0x4a/0x170
> [ 18.884408] process_one_work+0x165/0x430
> [ 18.884408] worker_thread+0x4e/0x490
> [ 18.884408] kthread+0x101/0x140
> [ 18.884408] ? process_one_work+0x430/0x430
> [ 18.884408] ? kthread_create_on_node+0x60/0x60
> [ 18.884408] ret_from_fork+0x2c/0x40
> [ 18.913090] ---[ end trace f43b051485c2a749 ]---
>
> On all three kernels, it looks like the bdi sysfs entry hangs around
> after the block device has already been removed:
This seems to be related to a 0day test we got on the block tree,
details here:
http://marc.info/?t=148624068800001
I root caused the above to something not being released when it should
be, so it looks like you have the same problem. It seems to be a
recent commit in the block tree, so could you bisect it since you have
a nice reproducer?
Thanks,
James
^ permalink raw reply
* Manual driver binding and unbinding broken for SCSI
From: Omar Sandoval @ 2017-02-18 0:30 UTC (permalink / raw)
To: Dan Williams, Jan Kara, James Bottomley, Martin K. Petersen
Cc: Jens Axboe, linux-scsi, linux-block
Hi, everyone,
As per $SUBJECT, I can cause a crash on v4.10-rc8, Jens' block/for-next,
and Jan's bdi branch [1] by doing this:
# lsscsi
[0:0:0:0] disk QEMU QEMU HARDDISK 2.5+ /dev/sda
# echo 0:0:0:0 > /sys/bus/scsi/drivers/sd/unbind
# echo 0:0:0:0 > /sys/bus/scsi/drivers/sd/bind
The resulting trace looks like this:
[ 19.347924] kobject (ffff8800791ea0b8): tried to init an initialized object, something is seriously wrong.
[ 19.349781] CPU: 1 PID: 84 Comm: kworker/u8:1 Not tainted 4.10.0-rc7-00210-g53f39eeaa263 #34
[ 19.350686] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-20161122_114906-anatol 04/01/2014
[ 19.350920] Workqueue: events_unbound async_run_entry_fn
[ 19.350920] Call Trace:
[ 19.350920] dump_stack+0x63/0x83
[ 19.350920] kobject_init+0x77/0x90
[ 19.350920] blk_mq_register_dev+0x40/0x130
[ 19.350920] blk_register_queue+0xb6/0x190
[ 19.350920] device_add_disk+0x1ec/0x4b0
[ 19.350920] sd_probe_async+0x10d/0x1c0 [sd_mod]
[ 19.350920] async_run_entry_fn+0x48/0x150
[ 19.350920] process_one_work+0x1d0/0x480
[ 19.350920] worker_thread+0x48/0x4e0
[ 19.350920] kthread+0x101/0x140
[ 19.350920] ? process_one_work+0x480/0x480
[ 19.350920] ? kthread_create_on_node+0x60/0x60
[ 19.350920] ret_from_fork+0x2c/0x40
Additionally, on v4.10-rc8, but not on block/for-next or Jan's branch,
doing this:
# echo 0:0:0:0 > /sys/bus/scsi/drivers/sd/unbind
# modprobe scsi_debug
Causes this trace:
[ 18.876096] ------------[ cut here ]------------
[ 18.877057] WARNING: CPU: 1 PID: 90 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x62/0x80
[ 18.878270] sysfs: cannot create duplicate filename '/devices/virtual/bdi/8:0'
[ 18.879435] Modules linked in: scsi_debug btrfs xor raid6_pq sd_mod virtio_scsi scsi_mod nvme nvme_core virtio_net
[ 18.881118] CPU: 1 PID: 90 Comm: kworker/u8:2 Not tainted 4.10.0-rc8 #34
[ 18.882114] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-20161122_114906-anatol 04/01/2014
[ 18.883872] Workqueue: events_unbound async_run_entry_fn
[ 18.884408] Call Trace:
[ 18.884408] dump_stack+0x63/0x83
[ 18.884408] __warn+0xcb/0xf0
[ 18.884408] warn_slowpath_fmt+0x5f/0x80
[ 18.884408] ? kernfs_path_from_node+0x4f/0x60
[ 18.884408] sysfs_warn_dup+0x62/0x80
[ 18.884408] sysfs_create_dir_ns+0x77/0x90
[ 18.884408] kobject_add_internal+0xbe/0x350
[ 18.884408] kobject_add+0x75/0xd0
[ 18.884408] device_add+0x121/0x680
[ 18.884408] device_create_groups_vargs+0xe0/0xf0
[ 18.884408] device_create_vargs+0x1c/0x20
[ 18.884408] bdi_register+0x90/0x1b0
[ 18.884408] ? sd_revalidate_disk+0x34a/0x1d00 [sd_mod]
[ 18.884408] bdi_register_owner+0x36/0x60
[ 18.884408] device_add_disk+0x165/0x4a0
[ 18.884408] ? update_autosuspend+0x51/0x60
[ 18.884408] ? __pm_runtime_use_autosuspend+0x5c/0x70
[ 18.884408] sd_probe_async+0x10d/0x1c0 [sd_mod]
[ 18.884408] async_run_entry_fn+0x4a/0x170
[ 18.884408] process_one_work+0x165/0x430
[ 18.884408] worker_thread+0x4e/0x490
[ 18.884408] kthread+0x101/0x140
[ 18.884408] ? process_one_work+0x430/0x430
[ 18.884408] ? kthread_create_on_node+0x60/0x60
[ 18.884408] ret_from_fork+0x2c/0x40
[ 18.913090] ---[ end trace f43b051485c2a749 ]---
On all three kernels, it looks like the bdi sysfs entry hangs around
after the block device has already been removed:
┌[root@silver ~]
└# lsblk /dev/sda
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 16G 0 disk
┌[root@silver ~]
└# ls -al /sys/devices/virtual/bdi
total 0
drwxr-xr-x 6 root root 0 Feb 17 16:19 .
drwxr-xr-x 13 root root 0 Feb 17 16:19 ..
drwxr-xr-x 3 root root 0 Feb 17 16:19 254:0
drwxr-xr-x 3 root root 0 Feb 17 16:19 259:0
drwxr-xr-x 3 root root 0 Feb 17 16:19 8:0
drwxr-xr-x 3 root root 0 Feb 17 16:19 9p-1
┌[root@silver ~]
└# echo 0:0:0:0 > /sys/bus/scsi/drivers/sd/unbind
┌[root@silver ~]
└# ls -al /sys/devices/virtual/bdi
total 0
drwxr-xr-x 6 root root 0 Feb 17 16:19 .
drwxr-xr-x 13 root root 0 Feb 17 16:19 ..
drwxr-xr-x 3 root root 0 Feb 17 16:19 254:0
drwxr-xr-x 3 root root 0 Feb 17 16:19 259:0
drwxr-xr-x 3 root root 0 Feb 17 16:19 8:0
drwxr-xr-x 3 root root 0 Feb 17 16:19 9p-1
┌[root@silver ~]
└# lsblk /dev/sda
lsblk: /dev/sda: not a block device
Any ideas here?
1: https://git.kernel.org/cgit/linux/kernel/git/jack/linux-fs.git/tree/?h=bdi
^ permalink raw reply
* [PATCHv2 4/5] block/sed: Embed function data into the function sequence
From: Jon Derrick @ 2017-02-18 0:00 UTC (permalink / raw)
Cc: Jon Derrick, linux-block, linux-nvme, Scott Bauer,
Rafael Antognolli, Jens Axboe, Christoph Hellwig
In-Reply-To: <1487376029-22662-1-git-send-email-jonathan.derrick@intel.com>
By embedding the function data with the function sequence, this
eliminates a lot of the code that needs to set it in other places.
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
block/sed-opal.c | 358 +++++++++++++++++++++----------------------------------
1 file changed, 138 insertions(+), 220 deletions(-)
diff --git a/block/sed-opal.c b/block/sed-opal.c
index 4fc4d7b..e2e3228 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -34,7 +34,11 @@
#define IO_BUFFER_LENGTH 2048
#define MAX_TOKS 64
-typedef int (*opal_step)(struct opal_dev *dev);
+typedef struct opal_step {
+ int (*fn)(struct opal_dev *dev, void *data);
+ void *data;
+} opal_step;
+typedef int (cont_fn)(struct opal_dev *dev);
enum opal_atom_width {
OPAL_WIDTH_TINY,
@@ -80,8 +84,7 @@ struct opal_dev {
void *data;
sec_send_recv *send_recv;
- const opal_step *funcs;
- void **func_data;
+ opal_step *funcs;
int state;
struct mutex dev_lock;
u16 comid;
@@ -213,8 +216,6 @@ struct opal_dev {
{ 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x08, 0x03 },
};
-typedef int (cont_fn)(struct opal_dev *dev);
-
static int end_opal_session_error(struct opal_dev *dev);
struct opal_suspend_data {
@@ -375,15 +376,15 @@ static void check_geometry(struct opal_dev *dev, const void *data)
static int next(struct opal_dev *dev)
{
- opal_step func;
+ opal_step *func;
int error = 0;
do {
- func = dev->funcs[dev->state];
- if (!func)
+ func = &dev->funcs[dev->state];
+ if (!func->fn)
break;
- error = func(dev);
+ error = func->fn(dev, func->data);
if (error) {
pr_err("Error on step function: %d with error %d: %s\n",
dev->state, error,
@@ -483,7 +484,7 @@ static int opal_discovery0_end(struct opal_dev *dev)
return 0;
}
-static int opal_discovery0(struct opal_dev *dev)
+static int opal_discovery0(struct opal_dev *dev, void *data)
{
int ret;
@@ -1018,7 +1019,7 @@ static int finalize_and_send(struct opal_dev *dev, cont_fn cont)
return opal_send_recv(dev, cont);
}
-static int gen_key(struct opal_dev *dev)
+static int gen_key(struct opal_dev *dev, void *data)
{
const u8 *method;
u8 uid[OPAL_UID_LENGTH];
@@ -1072,15 +1073,14 @@ static int get_active_key_cont(struct opal_dev *dev)
return 0;
}
-static int get_active_key(struct opal_dev *dev)
+static int get_active_key(struct opal_dev *dev, void *data)
{
u8 uid[OPAL_UID_LENGTH];
int err = 0;
- u8 *lr;
+ u8 *lr = data;
clear_opal_cmd(dev);
set_comid(dev, dev->comid);
- lr = dev->func_data[dev->state];
err = build_locking_range(uid, sizeof(uid), *lr);
if (err)
@@ -1163,17 +1163,16 @@ static inline int enable_global_lr(struct opal_dev *dev, u8 *uid,
return err;
}
-static int setup_locking_range(struct opal_dev *dev)
+static int setup_locking_range(struct opal_dev *dev, void *data)
{
u8 uid[OPAL_UID_LENGTH];
- struct opal_user_lr_setup *setup;
+ struct opal_user_lr_setup *setup = data;
u8 lr;
int err = 0;
clear_opal_cmd(dev);
set_comid(dev, dev->comid);
- setup = dev->func_data[dev->state];
lr = setup->session.opal_key.lr;
err = build_locking_range(uid, sizeof(uid), lr);
if (err)
@@ -1286,20 +1285,19 @@ static int start_generic_opal_session(struct opal_dev *dev,
return finalize_and_send(dev, start_opal_session_cont);
}
-static int start_anybodyASP_opal_session(struct opal_dev *dev)
+static int start_anybodyASP_opal_session(struct opal_dev *dev, void *data)
{
return start_generic_opal_session(dev, OPAL_ANYBODY_UID,
OPAL_ADMINSP_UID, NULL, 0);
}
-static int start_SIDASP_opal_session(struct opal_dev *dev)
+static int start_SIDASP_opal_session(struct opal_dev *dev, void *data)
{
int ret;
const u8 *key = dev->prev_data;
- struct opal_key *okey;
if (!key) {
- okey = dev->func_data[dev->state];
+ const struct opal_key *okey = data;
ret = start_generic_opal_session(dev, OPAL_SID_UID,
OPAL_ADMINSP_UID,
okey->key,
@@ -1314,22 +1312,21 @@ static int start_SIDASP_opal_session(struct opal_dev *dev)
return ret;
}
-static inline int start_admin1LSP_opal_session(struct opal_dev *dev)
+static inline int start_admin1LSP_opal_session(struct opal_dev *dev, void *data)
{
- struct opal_key *key = dev->func_data[dev->state];
-
+ struct opal_key *key = data;
return start_generic_opal_session(dev, OPAL_ADMIN1_UID,
OPAL_LOCKINGSP_UID,
key->key, key->key_len);
}
-static int start_auth_opal_session(struct opal_dev *dev)
+static int start_auth_opal_session(struct opal_dev *dev, void *data)
{
+ struct opal_session_info *session = data;
u8 lk_ul_user[OPAL_UID_LENGTH];
+ size_t keylen = session->opal_key.key_len;
int err = 0;
- struct opal_session_info *session = dev->func_data[dev->state];
- size_t keylen = session->opal_key.key_len;
u8 *key = session->opal_key.key;
u32 hsn = GENERIC_HOST_SESSION_NUM;
@@ -1379,7 +1376,7 @@ static int start_auth_opal_session(struct opal_dev *dev)
return finalize_and_send(dev, start_opal_session_cont);
}
-static int revert_tper(struct opal_dev *dev)
+static int revert_tper(struct opal_dev *dev, void *data)
{
int err = 0;
@@ -1401,9 +1398,9 @@ static int revert_tper(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int internal_activate_user(struct opal_dev *dev)
+static int internal_activate_user(struct opal_dev *dev, void *data)
{
- struct opal_session_info *session = dev->func_data[dev->state];
+ struct opal_session_info *session = data;
u8 uid[OPAL_UID_LENGTH];
int err = 0;
@@ -1436,15 +1433,14 @@ static int internal_activate_user(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int erase_locking_range(struct opal_dev *dev)
+static int erase_locking_range(struct opal_dev *dev, void *data)
{
- struct opal_session_info *session;
+ struct opal_session_info *session = data;
u8 uid[OPAL_UID_LENGTH];
int err = 0;
clear_opal_cmd(dev);
set_comid(dev, dev->comid);
- session = dev->func_data[dev->state];
if (build_locking_range(uid, sizeof(uid), session->opal_key.lr) < 0)
return -ERANGE;
@@ -1463,9 +1459,9 @@ static int erase_locking_range(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int set_mbr_done(struct opal_dev *dev)
+static int set_mbr_done(struct opal_dev *dev, void *data)
{
- u8 mbr_done_tf = *(u8 *)dev->func_data[dev->state];
+ u8 mbr_done_tf = *(u8 *)data;
int err = 0;
clear_opal_cmd(dev);
@@ -1495,9 +1491,9 @@ static int set_mbr_done(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int set_mbr_enable_disable(struct opal_dev *dev)
+static int set_mbr_enable_disable(struct opal_dev *dev, void *data)
{
- u8 mbr_en_dis = *(u8 *)dev->func_data[dev->state];
+ u8 mbr_en_dis = *(u8 *)data;
int err = 0;
clear_opal_cmd(dev);
@@ -1554,11 +1550,10 @@ static int generic_pw_cmd(u8 *key, size_t key_len, u8 *cpin_uid,
return err;
}
-static int set_new_pw(struct opal_dev *dev)
+static int set_new_pw(struct opal_dev *dev, void *data)
{
u8 cpin_uid[OPAL_UID_LENGTH];
- struct opal_session_info *usr = dev->func_data[dev->state];
-
+ struct opal_session_info *usr = data;
memcpy(cpin_uid, opaluid[OPAL_C_PIN_ADMIN1], OPAL_UID_LENGTH);
@@ -1579,10 +1574,10 @@ static int set_new_pw(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int set_sid_cpin_pin(struct opal_dev *dev)
+static int set_sid_cpin_pin(struct opal_dev *dev, void *data)
{
u8 cpin_uid[OPAL_UID_LENGTH];
- struct opal_key *key = dev->func_data[dev->state];
+ struct opal_key *key = data;
memcpy(cpin_uid, opaluid[OPAL_C_PIN_SID], OPAL_UID_LENGTH);
@@ -1593,18 +1588,16 @@ static int set_sid_cpin_pin(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int add_user_to_lr(struct opal_dev *dev)
+static int add_user_to_lr(struct opal_dev *dev, void *data)
{
u8 lr_buffer[OPAL_UID_LENGTH];
u8 user_uid[OPAL_UID_LENGTH];
- struct opal_lock_unlock *lkul;
+ struct opal_lock_unlock *lkul = data;
int err = 0;
clear_opal_cmd(dev);
set_comid(dev, dev->comid);
- lkul = dev->func_data[dev->state];
-
memcpy(lr_buffer, opaluid[OPAL_LOCKINGRANGE_ACE_RDLOCKED],
OPAL_UID_LENGTH);
@@ -1671,11 +1664,11 @@ static int add_user_to_lr(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int lock_unlock_locking_range(struct opal_dev *dev)
+static int lock_unlock_locking_range(struct opal_dev *dev, void *data)
{
u8 lr_buffer[OPAL_UID_LENGTH];
const u8 *method;
- struct opal_lock_unlock *lkul;
+ struct opal_lock_unlock *lkul = data;
u8 read_locked = 1, write_locked = 1;
int err = 0;
@@ -1683,7 +1676,6 @@ static int lock_unlock_locking_range(struct opal_dev *dev)
set_comid(dev, dev->comid);
method = opalmethod[OPAL_SET];
- lkul = dev->func_data[dev->state];
if (build_locking_range(lr_buffer, sizeof(lr_buffer),
lkul->session.opal_key.lr) < 0)
return -ERANGE;
@@ -1735,19 +1727,18 @@ static int lock_unlock_locking_range(struct opal_dev *dev)
}
-static int lock_unlock_locking_range_sum(struct opal_dev *dev)
+static int lock_unlock_locking_range_sum(struct opal_dev *dev, void *data)
{
u8 lr_buffer[OPAL_UID_LENGTH];
u8 read_locked = 1, write_locked = 1;
const u8 *method;
- struct opal_lock_unlock *lkul;
+ struct opal_lock_unlock *lkul = data;
int ret;
clear_opal_cmd(dev);
set_comid(dev, dev->comid);
method = opalmethod[OPAL_SET];
- lkul = dev->func_data[dev->state];
if (build_locking_range(lr_buffer, sizeof(lr_buffer),
lkul->session.opal_key.lr) < 0)
return -ERANGE;
@@ -1778,9 +1769,9 @@ static int lock_unlock_locking_range_sum(struct opal_dev *dev)
return finalize_and_send(dev, parse_and_check_status);
}
-static int activate_lsp(struct opal_dev *dev)
+static int activate_lsp(struct opal_dev *dev, void *data)
{
- struct opal_lr_act *opal_act;
+ struct opal_lr_act *opal_act = data;
u8 user_lr[OPAL_UID_LENGTH];
u8 uint_3 = 0x83;
int err = 0, i;
@@ -1788,8 +1779,6 @@ static int activate_lsp(struct opal_dev *dev)
clear_opal_cmd(dev);
set_comid(dev, dev->comid);
- opal_act = dev->func_data[dev->state];
-
add_token_u8(&err, dev, OPAL_CALL);
add_token_bytestring(&err, dev, opaluid[OPAL_LOCKINGSP_UID],
OPAL_UID_LENGTH);
@@ -1854,7 +1843,7 @@ static int get_lsp_lifecycle_cont(struct opal_dev *dev)
}
/* Determine if we're in the Manufactured Inactive or Active state */
-static int get_lsp_lifecycle(struct opal_dev *dev)
+static int get_lsp_lifecycle(struct opal_dev *dev, void *data)
{
int err = 0;
@@ -1915,14 +1904,13 @@ static int get_msid_cpin_pin_cont(struct opal_dev *dev)
return 0;
}
-static int get_msid_cpin_pin(struct opal_dev *dev)
+static int get_msid_cpin_pin(struct opal_dev *dev, void *data)
{
int err = 0;
clear_opal_cmd(dev);
set_comid(dev, dev->comid);
-
add_token_u8(&err, dev, OPAL_CALL);
add_token_bytestring(&err, dev, opaluid[OPAL_C_PIN_MSID],
OPAL_UID_LENGTH);
@@ -1963,7 +1951,7 @@ static int build_end_opal_session(struct opal_dev *dev)
return err;
}
-static int end_opal_session(struct opal_dev *dev)
+static int end_opal_session(struct opal_dev *dev, void *data)
{
int ret = build_end_opal_session(dev);
@@ -1974,9 +1962,9 @@ static int end_opal_session(struct opal_dev *dev)
static int end_opal_session_error(struct opal_dev *dev)
{
- const opal_step error_end_session[] = {
- end_opal_session,
- NULL,
+ opal_step error_end_session[] = {
+ { end_opal_session, },
+ { NULL, }
};
dev->funcs = error_end_session;
dev->state = 0;
@@ -1984,21 +1972,20 @@ static int end_opal_session_error(struct opal_dev *dev)
}
static inline void setup_opal_dev(struct opal_dev *dev,
- const opal_step *funcs)
+ opal_step *funcs)
{
dev->state = 0;
dev->funcs = funcs;
dev->tsn = 0;
dev->hsn = 0;
- dev->func_data = NULL;
dev->prev_data = NULL;
}
static int check_opal_support(struct opal_dev *dev)
{
- static const opal_step funcs[] = {
- opal_discovery0,
- NULL
+ opal_step funcs[] = {
+ { opal_discovery0, },
+ { NULL, }
};
int ret;
@@ -2034,24 +2021,18 @@ struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv)
static int opal_secure_erase_locking_range(struct opal_dev *dev,
struct opal_session_info *opal_session)
{
- void *data[3] = { NULL };
- static const opal_step erase_funcs[] = {
- opal_discovery0,
- start_auth_opal_session,
- get_active_key,
- gen_key,
- end_opal_session,
- NULL,
+ opal_step erase_funcs[] = {
+ { opal_discovery0, },
+ { start_auth_opal_session, opal_session },
+ { get_active_key, &opal_session->opal_key.lr },
+ { gen_key, },
+ { end_opal_session, },
+ { NULL, }
};
int ret;
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, erase_funcs);
-
- dev->func_data = data;
- dev->func_data[1] = opal_session;
- dev->func_data[2] = &opal_session->opal_key.lr;
-
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2060,23 +2041,17 @@ static int opal_secure_erase_locking_range(struct opal_dev *dev,
static int opal_erase_locking_range(struct opal_dev *dev,
struct opal_session_info *opal_session)
{
- void *data[3] = { NULL };
- static const opal_step erase_funcs[] = {
- opal_discovery0,
- start_auth_opal_session,
- erase_locking_range,
- end_opal_session,
- NULL,
+ opal_step erase_funcs[] = {
+ { opal_discovery0, },
+ { start_auth_opal_session, opal_session },
+ { erase_locking_range, opal_session },
+ { end_opal_session, },
+ { NULL, }
};
int ret;
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, erase_funcs);
-
- dev->func_data = data;
- dev->func_data[1] = opal_session;
- dev->func_data[2] = opal_session;
-
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2085,16 +2060,15 @@ static int opal_erase_locking_range(struct opal_dev *dev,
static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
struct opal_mbr_data *opal_mbr)
{
- void *func_data[6] = { NULL };
- static const opal_step mbr_funcs[] = {
- opal_discovery0,
- start_admin1LSP_opal_session,
- set_mbr_done,
- end_opal_session,
- start_admin1LSP_opal_session,
- set_mbr_enable_disable,
- end_opal_session,
- NULL,
+ opal_step mbr_funcs[] = {
+ { opal_discovery0, },
+ { start_admin1LSP_opal_session, &opal_mbr->key },
+ { set_mbr_done, &opal_mbr->enable_disable },
+ { end_opal_session, },
+ { start_admin1LSP_opal_session, &opal_mbr->key },
+ { set_mbr_enable_disable, &opal_mbr->enable_disable },
+ { end_opal_session, },
+ { NULL, }
};
int ret;
@@ -2104,11 +2078,6 @@ static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, mbr_funcs);
- dev->func_data = func_data;
- dev->func_data[1] = &opal_mbr->key;
- dev->func_data[2] = &opal_mbr->enable_disable;
- dev->func_data[4] = &opal_mbr->key;
- dev->func_data[5] = &opal_mbr->enable_disable;
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2135,13 +2104,12 @@ static int opal_save(struct opal_dev *dev, struct opal_lock_unlock *lk_unlk)
static int opal_add_user_to_lr(struct opal_dev *dev,
struct opal_lock_unlock *lk_unlk)
{
- void *func_data[3] = { NULL };
- static const opal_step funcs[] = {
- opal_discovery0,
- start_admin1LSP_opal_session,
- add_user_to_lr,
- end_opal_session,
- NULL
+ opal_step funcs[] = {
+ { opal_discovery0, },
+ { start_admin1LSP_opal_session, &lk_unlk->session.opal_key },
+ { add_user_to_lr, lk_unlk },
+ { end_opal_session, },
+ { NULL, }
};
int ret;
@@ -2164,9 +2132,6 @@ static int opal_add_user_to_lr(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, funcs);
- dev->func_data = func_data;
- dev->func_data[1] = &lk_unlk->session.opal_key;
- dev->func_data[2] = lk_unlk;
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2174,55 +2139,44 @@ static int opal_add_user_to_lr(struct opal_dev *dev,
static int opal_reverttper(struct opal_dev *dev, struct opal_key *opal)
{
- void *data[2] = { NULL };
- static const opal_step revert_funcs[] = {
- opal_discovery0,
- start_SIDASP_opal_session,
- revert_tper, /* controller will terminate session */
- NULL,
+ opal_step revert_funcs[] = {
+ { opal_discovery0, },
+ { start_SIDASP_opal_session, opal },
+ { revert_tper, }, /* controller will terminate session */
+ { NULL, }
};
int ret;
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, revert_funcs);
- dev->func_data = data;
- dev->func_data[1] = opal;
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
}
-static int __opal_lock_unlock_sum(struct opal_dev *dev)
+static int __opal_lock_unlock(struct opal_dev *dev,
+ struct opal_lock_unlock *lk_unlk)
{
- static const opal_step ulk_funcs_sum[] = {
- opal_discovery0,
- start_auth_opal_session,
- lock_unlock_locking_range_sum,
- end_opal_session,
- NULL
+ opal_step _unlock_funcs[] = {
+ { opal_discovery0, },
+ { start_auth_opal_session, &lk_unlk->session },
+ { NULL, lk_unlk },
+ { end_opal_session, },
+ { NULL, }
};
- dev->funcs = ulk_funcs_sum;
- return next(dev);
-}
-
-static int __opal_lock_unlock(struct opal_dev *dev)
-{
- static const opal_step _unlock_funcs[] = {
- opal_discovery0,
- start_auth_opal_session,
- lock_unlock_locking_range,
- end_opal_session,
- NULL
- };
+ if (lk_unlk->session.sum)
+ _unlock_funcs[2].fn = lock_unlock_locking_range_sum;
+ else
+ _unlock_funcs[2].fn = lock_unlock_locking_range;
dev->funcs = _unlock_funcs;
return next(dev);
}
-static int opal_lock_unlock(struct opal_dev *dev, struct opal_lock_unlock *lk_unlk)
+static int opal_lock_unlock(struct opal_dev *dev,
+ struct opal_lock_unlock *lk_unlk)
{
- void *func_data[3] = { NULL };
int ret;
if (lk_unlk->session.who < OPAL_ADMIN1 ||
@@ -2231,32 +2185,23 @@ static int opal_lock_unlock(struct opal_dev *dev, struct opal_lock_unlock *lk_un
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, NULL);
- dev->func_data = func_data;
- dev->func_data[1] = &lk_unlk->session;
- dev->func_data[2] = lk_unlk;
-
- if (lk_unlk->session.sum)
- ret = __opal_lock_unlock_sum(dev);
- else
- ret = __opal_lock_unlock(dev);
-
+ ret = __opal_lock_unlock(dev, lk_unlk);
mutex_unlock(&dev->dev_lock);
return ret;
}
static int opal_take_ownership(struct opal_dev *dev, struct opal_key *opal)
{
- static const opal_step owner_funcs[] = {
- opal_discovery0,
- start_anybodyASP_opal_session,
- get_msid_cpin_pin,
- end_opal_session,
- start_SIDASP_opal_session,
- set_sid_cpin_pin,
- end_opal_session,
- NULL
+ opal_step owner_funcs[] = {
+ { opal_discovery0, },
+ { start_anybodyASP_opal_session, },
+ { get_msid_cpin_pin, },
+ { end_opal_session, },
+ { start_SIDASP_opal_session, opal },
+ { set_sid_cpin_pin, opal },
+ { end_opal_session, },
+ { NULL, }
};
- void *data[6] = { NULL };
int ret;
if (!dev)
@@ -2264,9 +2209,6 @@ static int opal_take_ownership(struct opal_dev *dev, struct opal_key *opal)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, owner_funcs);
- dev->func_data = data;
- dev->func_data[4] = opal;
- dev->func_data[5] = opal;
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2274,14 +2216,13 @@ static int opal_take_ownership(struct opal_dev *dev, struct opal_key *opal)
static int opal_activate_lsp(struct opal_dev *dev, struct opal_lr_act *opal_lr_act)
{
- void *data[4] = { NULL };
- static const opal_step active_funcs[] = {
- opal_discovery0,
- start_SIDASP_opal_session, /* Open session as SID auth */
- get_lsp_lifecycle,
- activate_lsp,
- end_opal_session,
- NULL
+ opal_step active_funcs[] = {
+ { opal_discovery0, },
+ { start_SIDASP_opal_session, &opal_lr_act->key },
+ { get_lsp_lifecycle, },
+ { activate_lsp, opal_lr_act },
+ { end_opal_session, },
+ { NULL, }
};
int ret;
@@ -2290,9 +2231,6 @@ static int opal_activate_lsp(struct opal_dev *dev, struct opal_lr_act *opal_lr_a
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, active_funcs);
- dev->func_data = data;
- dev->func_data[1] = &opal_lr_act->key;
- dev->func_data[3] = opal_lr_act;
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2301,21 +2239,17 @@ static int opal_activate_lsp(struct opal_dev *dev, struct opal_lr_act *opal_lr_a
static int opal_setup_locking_range(struct opal_dev *dev,
struct opal_user_lr_setup *opal_lrs)
{
- void *data[3] = { NULL };
- static const opal_step lr_funcs[] = {
- opal_discovery0,
- start_auth_opal_session,
- setup_locking_range,
- end_opal_session,
- NULL,
+ opal_step lr_funcs[] = {
+ { opal_discovery0, },
+ { start_auth_opal_session, &opal_lrs->session },
+ { setup_locking_range, opal_lrs },
+ { end_opal_session, },
+ { NULL, }
};
int ret;
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, lr_funcs);
- dev->func_data = data;
- dev->func_data[1] = &opal_lrs->session;
- dev->func_data[2] = opal_lrs;
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2323,14 +2257,13 @@ static int opal_setup_locking_range(struct opal_dev *dev,
static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
{
- static const opal_step pw_funcs[] = {
- opal_discovery0,
- start_auth_opal_session,
- set_new_pw,
- end_opal_session,
- NULL
+ opal_step pw_funcs[] = {
+ { opal_discovery0, },
+ { start_auth_opal_session, &opal_pw->session },
+ { set_new_pw, &opal_pw->new_user_pw },
+ { end_opal_session, },
+ { NULL }
};
- void *data[3] = { NULL };
int ret;
if (opal_pw->session.who < OPAL_ADMIN1 ||
@@ -2341,10 +2274,6 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, pw_funcs);
- dev->func_data = data;
- dev->func_data[1] = (void *) &opal_pw->session;
- dev->func_data[2] = (void *) &opal_pw->new_user_pw;
-
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2353,14 +2282,13 @@ static int opal_set_new_pw(struct opal_dev *dev, struct opal_new_pw *opal_pw)
static int opal_activate_user(struct opal_dev *dev,
struct opal_session_info *opal_session)
{
- static const opal_step act_funcs[] = {
- opal_discovery0,
- start_admin1LSP_opal_session,
- internal_activate_user,
- end_opal_session,
- NULL
+ opal_step act_funcs[] = {
+ { opal_discovery0, },
+ { start_admin1LSP_opal_session, &opal_session->opal_key },
+ { internal_activate_user, opal_session },
+ { end_opal_session, },
+ { NULL, }
};
- void *data[3] = { NULL };
int ret;
/* We can't activate Admin1 it's active as manufactured */
@@ -2372,9 +2300,6 @@ static int opal_activate_user(struct opal_dev *dev,
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, act_funcs);
- dev->func_data = data;
- dev->func_data[1] = &opal_session->opal_key;
- dev->func_data[2] = opal_session;
ret = next(dev);
mutex_unlock(&dev->dev_lock);
return ret;
@@ -2383,7 +2308,6 @@ static int opal_activate_user(struct opal_dev *dev,
bool opal_unlock_from_suspend(struct opal_dev *dev)
{
struct opal_suspend_data *suspend;
- void *func_data[3] = { NULL };
bool was_failure = false;
int ret = 0;
@@ -2394,19 +2318,13 @@ bool opal_unlock_from_suspend(struct opal_dev *dev)
mutex_lock(&dev->dev_lock);
setup_opal_dev(dev, NULL);
- dev->func_data = func_data;
list_for_each_entry(suspend, &dev->unlk_lst, node) {
dev->state = 0;
- dev->func_data[1] = &suspend->unlk.session;
- dev->func_data[2] = &suspend->unlk;
dev->tsn = 0;
dev->hsn = 0;
- if (suspend->unlk.session.sum)
- ret = __opal_lock_unlock_sum(dev);
- else
- ret = __opal_lock_unlock(dev);
+ ret = __opal_lock_unlock(dev, &suspend->unlk);
if (ret) {
pr_warn("Failed to unlock LR %hhu with sum %d\n",
suspend->unlk.session.opal_key.lr,
--
1.8.3.1
^ permalink raw reply related
* [PATCHv2 5/5] block/sed: Eliminate state variable
From: Jon Derrick @ 2017-02-18 0:00 UTC (permalink / raw)
Cc: Jon Derrick, linux-block, linux-nvme, Scott Bauer,
Rafael Antognolli, Jens Axboe, Christoph Hellwig
In-Reply-To: <1487376029-22662-1-git-send-email-jonathan.derrick@intel.com>
Now that the function data is embedded with the function, there is no
need to carry a device state variable.
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
block/sed-opal.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/block/sed-opal.c b/block/sed-opal.c
index e2e3228..791a40a 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -85,7 +85,6 @@ struct opal_dev {
sec_send_recv *send_recv;
opal_step *funcs;
- int state;
struct mutex dev_lock;
u16 comid;
u32 hsn;
@@ -377,17 +376,17 @@ static void check_geometry(struct opal_dev *dev, const void *data)
static int next(struct opal_dev *dev)
{
opal_step *func;
- int error = 0;
+ int state = 0, error = 0;
do {
- func = &dev->funcs[dev->state];
+ func = &dev->funcs[state];
if (!func->fn)
break;
error = func->fn(dev, func->data);
if (error) {
pr_err("Error on step function: %d with error %d: %s\n",
- dev->state, error,
+ state, error,
opal_error_to_human(error));
/* For each OPAL command we do a discovery0 then we
@@ -397,10 +396,10 @@ static int next(struct opal_dev *dev)
* session. Therefore we shouldn't attempt to terminate
* a session, as one has not yet been created.
*/
- if (dev->state > 1)
+ if (state > 1)
return end_opal_session_error(dev);
}
- dev->state++;
+ state++;
} while (!error);
return error;
@@ -1967,14 +1966,12 @@ static int end_opal_session_error(struct opal_dev *dev)
{ NULL, }
};
dev->funcs = error_end_session;
- dev->state = 0;
return next(dev);
}
static inline void setup_opal_dev(struct opal_dev *dev,
opal_step *funcs)
{
- dev->state = 0;
dev->funcs = funcs;
dev->tsn = 0;
dev->hsn = 0;
@@ -2320,7 +2317,6 @@ bool opal_unlock_from_suspend(struct opal_dev *dev)
setup_opal_dev(dev, NULL);
list_for_each_entry(suspend, &dev->unlk_lst, node) {
- dev->state = 0;
dev->tsn = 0;
dev->hsn = 0;
--
1.8.3.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox