Commit graph

1148808 commits

Author SHA1 Message Date
Keith Busch
e917a849c3 nvme-pci: refresh visible attrs for cmb attributes
The sysfs group containing the cmb attributes is registered before the
driver knows if they need to be visible or not. Update the group when
cmb attributes are known to exist so the visibility setting is correct.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=217037
Fixes: 86adbf0cdb ("nvme: simplify transport specific device attribute handling")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-17 08:31:05 +01:00
Jens Axboe
9a28b92cc2 nvme fixes for Linux 6.2
- always return an ERR_PTR from nvme_pci_alloc_dev (Irvin Cote)
  - add bogus ID quirk for ADATA SX6000PNP (Daniel Wagner)
  - set the DMA mask earlier (Christoph Hellwig)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmPtILgLHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYM0gA//d2RFIIdhmFFu5iBp7S05D5CjLyQxP9jdVFQIJTjO
 UTx6YIb18v9VEgxhWA8EwDQuLcW9Uj7s59Wxkt+Y6s/8PAVQxyzKyEyxTXJWG9kh
 qQeTyymqOBHOScu3aWSIa7TpOlg8/Pxkn0MgmmYm3Wx+NA7+7xzxeVxs8hcoN4Hc
 2mTPmfJY+DiOopyKV/awiwAG1g39gziPODh2VT1kJWn1Q7OxRMbZ9CN047b1yII8
 54hYI0z8MF2T83SdVS+MADcqtWCNKrEVVrEVJS/kQ5fNKV4ojFOTf5hMR6xmo+bg
 bXyxnu0HSM/Ij76Umw7xqlcF5L+Rn/MnJNebcJ+iNfsi6g+AaVwekbMBC4NVWTtp
 iGI4uxH9EbWS654CikTdXPxtbQuODpYL1x/16vZqBQvmv5WJH07uVsrwG3Zoo9R+
 krKNMiI7PkTUbH6IACmk/RNPfuxK0qYpTDZcvKIj6C0PBNd/0RpVi8mjeQzgFlHd
 w+AZ7iu0/8HOTNpoI8Qi0NxlHBOAHFqILrNRf78YN1I8Hisa4JYILrhU1UL9wnDg
 aCLUS56SGCFAjgVlYlakFq2iR8htbFh1fPhWz3Q6BV8k84LjaaHoZvVV3A0DYhdj
 4+rOvI7k5r4sKIIp7jUe2xXwEyacOziY/KrI8kzBIxeio8+CykPNlbDTgIJHW79y
 U5M=
 =xRhD
 -----END PGP SIGNATURE-----

Merge tag 'nvme-6.2-2023-02-15' of git://git.infradead.org/nvme into block-6.2

Pull NVMe fixes from Christoph:

"nvme fixes for Linux 6.2

 - always return an ERR_PTR from nvme_pci_alloc_dev (Irvin Cote)
 - add bogus ID quirk for ADATA SX6000PNP (Daniel Wagner)
 - set the DMA mask earlier (Christoph Hellwig)"

* tag 'nvme-6.2-2023-02-15' of git://git.infradead.org/nvme:
  nvme-pci: always return an ERR_PTR from nvme_pci_alloc_dev
  nvme-pci: set the DMA mask earlier
  nvme-pci: add bogus ID quirk for ADATA SX6000PNP
2023-02-15 13:47:27 -07:00
Irvin Cote
dc785d69d7 nvme-pci: always return an ERR_PTR from nvme_pci_alloc_dev
Don't mix NULL and ERR_PTR returns.

Fixes: 2e87570be9 ("nvme-pci: factor out a nvme_pci_alloc_dev helper")
Signed-off-by: Irvin Cote <irvin.cote@insa-lyon.fr>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-14 06:39:02 +01:00
Christoph Hellwig
924bd96ea2 nvme-pci: set the DMA mask earlier
Set the DMA mask before calling dma_addressing_limited, which depends on it.

Note that this stop checking the return value of dma_set_mask_and_coherent
as this function can only fail for masks < 32-bit.

Fixes: 3f30a79c2e ("nvme-pci: set constant paramters in nvme_pci_alloc_ctrl")
Reported-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Tested-by: Michael Kelley <mikelley@microsoft.com>
2023-02-14 06:36:40 +01:00
Daniel Wagner
5f69f009b7 nvme-pci: add bogus ID quirk for ADATA SX6000PNP
Yet another device which needs a quirk:

 nvme nvme1: globally duplicate IDs for nsid 1
 nvme nvme1: VID:DID 10ec:5763 model:ADATA SX6000PNP firmware:V9002s94

Link: http://bugzilla.opensuse.org/show_bug.cgi?id=1207827
Reported-by: Gustavo Freitas <freitasmgustavo@gmail.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-13 07:04:53 +01:00
Jens Axboe
38c33ece23 nvme fixes for Linux 6.2
- fix a static checker warning for a variable introduces in the last
    pull request (Tom Rix)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmPkf+4LHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYM1aw//f4GhGobFKf/zjD+14rwNr2yc93xWWB6MkXUAD3Jq
 51rfRyDCMdmoxtUZtnhrUjnf8VrircqNH7mEq4tyKl5kj3LI+lfUi7exe7TujJak
 askh4ZHgRO2HGZiKkSLydmN3fO2IkIw9FtvkISICSLyRHbhu9g6VXca17OnpITzc
 FI/8BhiW7kmJDZ8JQnC2X+Tt2AWrelt1WHYwNcgPqPPwRNlxVGxAovWkXT1ryup4
 nrlyBq9Pttjtl7B7yti65YBwZse53KTTdELLeFpWZD8MH0KtdA5UooXRVO3tLmye
 hQNR9pEvfx4J/gGH84m6jWs0whN1c2GNaP3yD3wIHFCICMcbWKWn9vsgVSkWyF3s
 BGip2kdP6bVFxM3NrPkuF6UFvO9a/hvTWu0u5iJT531eUlumaBjOU/MoBfRIajDL
 EtrKwpT2m59/eGcQWoPKpXd/Z+bRwHAYF9DC/VNHtOufI+nALP+NZJrMVtD+d72s
 0mtIeTiyYWIbV0phoyWolw3D4HhzYL9jM6jmQFibhy8wpBTYavmjZh6mM3XNvdtF
 Gl9W9r68u1MSjzbGCPSJnEnIhHf00e5lHI9NlzbRgx8BpjhEpP5213BH1vp3lyCT
 0DQdJ1reg1yCBqdLECw9hHI17v9jwMGopy/4r8bGBVn5JNn+a435w7nlmkC2/COf
 XDM=
 =FRW7
 -----END PGP SIGNATURE-----

Merge tag 'nvme-6.2-2023-02-09' of git://git.infradead.org/nvme into block-6.2

Pull NVMe fix from Christoph:

"nvme fixes for Linux 6.2

 - fix a static checker warning for a variable introduces in the last
   pull request (Tom Rix)"

* tag 'nvme-6.2-2023-02-09' of git://git.infradead.org/nvme:
  nvme-auth: mark nvme_auth_wq static
2023-02-09 08:12:06 -07:00
Tom Rix
70daa5c8f0 nvme-auth: mark nvme_auth_wq static
Fix a smatch report for the newly added nvme_auth_wq.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-08 07:28:16 +01:00
Jens Axboe
e02bbac74c nvme fixes for Linux 6.2
- fix a missing queue put in nvmet_fc_ls_create_association (Amit Engel)
  - clear queue pointers on tag_set initialization failure
    (Maurizio Lombardi)
  - use workqueue dedicated to authentication (Shin'ichiro Kawasaki)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmPb1JwLHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYOc7hAAuOfC5ePaZt6oMBqaEOCgw99A69afrJ45PqaWtfwr
 BNwoMwIBvO/qkAEVm/EQOacV8VlbVnPMk03axvultxfqT3mUw+/EvbhAPrNiLD2K
 dQe8WwSdKICMC8gKBztpMA1367lLTDxGnyqeTgy/p2zw/hBjkIhbLEkgbY4gnujp
 TiYWunSLuKF0RasDIO1sb+8k4Ed76pBwKRRjMw450ReiyIp9nryx+IantPlohHmh
 LuOut/vAMPmuKKseHNUjV8u71jHQi/cqAm8OVhm6FC4MHC+m8SHc70V3YrsitEZ8
 p7Fvd40A3Pn0AGkNYmRfANUt6+5mHPV06VXfLHoGGlv1muGfSMnzPD8cc3IvUdxK
 hNHcXUEQoHgs2MkcTctd4ERvwxZSDGIGyXTCyZLEn9+yrsk22zfS4KT2PZhu10ED
 eYkzrIOkOfVEVEoxTFGANxCkSI4tfyLCaFcrnRC3CgrNPZ8R5Eumdu/U5mEn9jgH
 +BEja4UucaJcZ2Itf2DCaxeqMN4JNtVhOTkGOOnzPuvCfbFiNlBHt7xwtCQkQIzf
 60IdL/H5ednS9zJxmbkQv6+631G1+Rn0zYs7G8N3xo7hqbTgVoRtDwEJus1D4ccu
 8iAzj8fFS5vEnnC/pvdH0cTsnfpz/say5v1YR3WwBeJqu3A0v6FF41TbtnSxXIKC
 AlQ=
 =Eivm
 -----END PGP SIGNATURE-----

Merge tag 'nvme-6.2-2023-02-02' of git://git.infradead.org/nvme into block-6.2

Pul NVMe fixes from Christoph:

"nvme fixes for Linux 6.2

 - fix a missing queue put in nvmet_fc_ls_create_association (Amit Engel)
 - clear queue pointers on tag_set initialization failure
   (Maurizio Lombardi)
 - use workqueue dedicated to authentication (Shin'ichiro Kawasaki)"

* tag 'nvme-6.2-2023-02-02' of git://git.infradead.org/nvme:
  nvme-auth: use workqueue dedicated to authentication
  nvme: clear the request_queue pointers on failure in nvme_alloc_io_tag_set
  nvme: clear the request_queue pointers on failure in nvme_alloc_admin_tag_set
  nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association
2023-02-02 11:02:12 -07:00
Ming Lei
0416f3be58 blk-cgroup: don't update io stat for root cgroup
We source root cgroup stats from the system-wide stats, see blkcg_print_stat
and blkcg_rstat_flush, so don't update io state for root cgroup.

Fixes blkg leak issue introduced in commit 3b8cc62987 ("blk-cgroup: Optimize blkcg_rstat_flush()")
which starts to grab blkg's reference when adding iostat_cpu into percpu
blkcg list, but this state won't be consumed by blkcg_rstat_flush() where
the blkg reference is dropped.

Tested-by: Bart van Assche <bvanassche@acm.org>
Reported-by: Bart van Assche <bvanassche@acm.org>
Fixes: 3b8cc62987 ("blk-cgroup: Optimize blkcg_rstat_flush()")
Cc: Tejun Heo <tj@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230202021804.278582-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-02-01 19:26:41 -07:00
Shin'ichiro Kawasaki
bd97a59da6 nvme-auth: use workqueue dedicated to authentication
NVMe In-Band authentication uses two kinds of works: chap->auth_work and
ctrl->dhchap_auth_work. The latter work flushes or cancels the former
work. However, the both works are queued to the same workqueue nvme-wq.
It results in the lockdep WARNING as follows:

 WARNING: possible recursive locking detected
 6.2.0-rc4+ #1 Not tainted
 --------------------------------------------
 kworker/u16:7/69 is trying to acquire lock:
 ffff902d52e65548 ((wq_completion)nvme-wq){+.+.}-{0:0}, at: start_flush_work+0x2c5/0x380

 but task is already holding lock:
 ffff902d52e65548 ((wq_completion)nvme-wq){+.+.}-{0:0}, at: process_one_work+0x210/0x410

To avoid the WARNING, introduce a new workqueue nvme-auth-wq dedicated
to chap->auth_work.

Reported-by: Daniel Wagner <dwagner@suse.de>
Link: https://lore.kernel.org/linux-nvme/20230130110802.paafkiipmitwtnwr@carbon.lan/
Fixes: f50fff73d6 ("nvme: implement In-Band authentication")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tested-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-01 16:11:20 +01:00
Maurizio Lombardi
6fbf13c0e2 nvme: clear the request_queue pointers on failure in nvme_alloc_io_tag_set
In nvme_alloc_io_tag_set(), the connect_q pointer should be set to NULL
in case of error to avoid potential invalid pointer dereferences.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-01 14:18:46 +01:00
Maurizio Lombardi
fd62678ab5 nvme: clear the request_queue pointers on failure in nvme_alloc_admin_tag_set
If nvme_alloc_admin_tag_set() fails, the admin_q and fabrics_q pointers
are left with an invalid, non-NULL value. Other functions may then check
the pointers and dereference them, e.g. in

  nvme_probe() -> out_disable: -> nvme_dev_remove_admin().

Fix the bug by setting admin_q and fabrics_q to NULL in case of error.

Also use the set variable to free the tag_set as ctrl->admin_tagset isn't
initialized yet.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-01 14:18:46 +01:00
Amit Engel
0cab440487 nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association
As part of nvmet_fc_ls_create_association there is a case where
nvmet_fc_alloc_target_queue fails right after a new association with an
admin queue is created. In this case, no one releases the get taken in
nvmet_fc_alloc_target_assoc.  This fix is adding the missing put.

Signed-off-by: Amit Engel <Amit.Engel@dell.com>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-02-01 14:18:46 +01:00
Bart Van Assche
81ea42b9c3 block: Fix the blk_mq_destroy_queue() documentation
Commit 2b3f056f72 moved a blk_put_queue() call from
blk_mq_destroy_queue() into its callers. Reflect this change in the
documentation block above blk_mq_destroy_queue().

Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Chaitanya Kulkarni <kch@nvidia.com>
Cc: Keith Busch <kbusch@kernel.org>
Fixes: 2b3f056f72 ("blk-mq: move the call to blk_put_queue out of blk_mq_destroy_queue")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230130211233.831613-1-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-31 11:46:15 -07:00
Liu Xiaodong
29baef789c block: ublk: extending queue_size to fix overflow
When validating drafted SPDK ublk target, in a case that
assigning large queue depth to multiqueue ublk device,
ublk target would run into a weird incorrect state. During
rounds of review and debug, An overflow bug was found
in ublk driver.

In ublk_cmd.h, UBLK_MAX_QUEUE_DEPTH is 4096 which means
each ublk queue depth can be set as large as 4096. But
when setting qd for a ublk device,
sizeof(struct ublk_queue) + depth * sizeof(struct ublk_io)
will be larger than 65535 if qd is larger than 2728.
Then queue_size is overflowed, and ublk_get_queue()
references a wrong pointer position. The wrong content of
ublk_queue elements will lead to out-of-bounds memory
access.

Extend queue_size in ublk_device as "unsigned int".

Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com>
Fixes: 71f28f3136 ("ublk_drv: add io_uring based userspace block driver")
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230131070552.115067-1-xiaodong.liu@intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-31 07:58:53 -07:00
Yu Kuai
b600de2d7d block, bfq: fix uaf for bfqq in bic_set_bfqq()
After commit 64dc8c732f ("block, bfq: fix possible uaf for 'bfqq->bic'"),
bic->bfqq will be accessed in bic_set_bfqq(), however, in some context
bic->bfqq will be freed, and bic_set_bfqq() is called with the freed
bic->bfqq.

Fix the problem by always freeing bfqq after bic_set_bfqq().

Fixes: 64dc8c732f ("block, bfq: fix possible uaf for 'bfqq->bic'")
Reported-and-tested-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230130014136.591038-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-29 18:57:01 -07:00
Jens Axboe
db3ba974c2 nvme fixes for Linux 6.2
- flush initial scan_work for async probe (Keith Busch)
  - fix passthrough csi check (Keith Busch)
  - fix nvme-fc initialization order (Ross Lagerwall)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmPSuhULHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYOw5xAApcohbAaJHrGLNIjYexxc87/EHe/kLKhB1nD+FwKQ
 HroQ1tMAExeWnb6/+/xpMy5qh467lplLEB7c2gtx63EyEPyp0m+gsaldDTyneZkO
 cUyb/pl+du+hCz6ADOOM/4ynx1BRTf3c6xcnoNaPuoWHqtgDPjXB3/5ixpj69TuO
 NHliDON4JyllgxQq6glhAMuD1a5QM1hYOqfp/npXQVF8in2/1gIGb7li0eUh1IfQ
 LZe4NT8D+Ms0chThiAo8JgqW9E+pKyK8opgzsyLQ+v3WvH4QiVfYHTOcndDZ2wzP
 OY5BAJg1pLoYopMRrF5fiMuphF/G1krMePV6i98jzWwR0Tm9T8+fc0ZYKZzpwE3w
 22xQgQI6EDNNZkp0cm2MEDYch6DdfmRA8MemHiTKaGPwuZzm9oKAsWnHHdcDyZ+Z
 bDlFdoU0OcaWuIekia8kfzqHWVwlZohiKgLR8KTxnrMsSC+ZK69t4+WbdWlvC+4H
 wEj1ga6gqX0Y/uyR0Rix2wS3fK2ZkLmeYy93PnN3Uw0SYow78Ge6W4+YNzLx4Ugr
 Uiaf0gLXtjIzEMo5+I49i1dfglnhH9/zuxCeB2AejBBiEdaxOk4lsj0eoQchwm8m
 gak0CcANuKN9SJ57GaZZ5iTrFfYNrHBE3cF775zCteK1EsuPF0lruqZm4Z2Yi4Im
 D2U=
 =WTvM
 -----END PGP SIGNATURE-----

Merge tag 'nvme-6.2-2023-01-26' of git://git.infradead.org/nvme into block-6.2

Pull NVMe fixes from Christoph:

"nvme fixes for Linux 6.2

 - flush initial scan_work for async probe (Keith Busch)
 - fix passthrough csi check (Keith Busch)
 - fix nvme-fc initialization order (Ross Lagerwall)"

* tag 'nvme-6.2-2023-01-26' of git://git.infradead.org/nvme:
  nvme: fix passthrough csi check
  nvme-pci: flush initial scan_work for async probe
  nvme-fc: fix initialization order
2023-01-26 11:43:33 -07:00
Ming Lei
8e4ff68476 block: ublk: move ublk_chr_class destroying after devices are removed
The 'ublk_chr_class' is needed when deleting ublk char devices in
ublk_exit(), so move it after devices(idle) are removed.

Fixes the following warning reported by Harris, James R:

[  859.178950] sysfs group 'power' not found for kobject 'ublkc0'
[  859.178962] WARNING: CPU: 3 PID: 1109 at fs/sysfs/group.c:278 sysfs_remove_group+0x9c/0xb0

Reported-by: "Harris, James R" <james.r.harris@intel.com>
Fixes: 71f28f3136 ("ublk_drv: add io_uring based userspace block driver")
Link: https://lore.kernel.org/linux-block/Y9JlFmSgDl3+zy3N@T590/T/#t
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Tested-by: Jim Harris <james.r.harris@intel.com>
Link: https://lore.kernel.org/r/20230126115346.263344-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-26 07:55:21 -07:00
Keith Busch
85eee6341a nvme: fix passthrough csi check
The namespace head saves the Command Set Indicator enum, so use that
instead of the Command Set Selected. The two values are not the same.

Fixes: 831ed60c2a ("nvme: also return I/O command effects from nvme_command_effects")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-25 07:09:38 +01:00
Keith Busch
5a5754a499 nvme-pci: flush initial scan_work for async probe
The nvme device may have a namespace with the root partition, so make
sure we've completed scanning before returning from the async probe.

Fixes: eac3ef2629 ("nvme-pci: split the initial probe from the rest path")
Reported-by: Klaus Jensen <its@irrelevant.dk>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Klaus Jensen <k.jensen@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-24 20:16:09 +01:00
Ross Lagerwall
98e3528012 nvme-fc: fix initialization order
ctrl->ops is used by nvme_alloc_admin_tag_set() but set by
nvme_init_ctrl() so reorder the calls to avoid a NULL pointer
dereference.

Fixes: 6dfba1c09c ("nvme-fc: use the tagset alloc/free helpers")
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-23 17:42:11 +01:00
Jens Axboe
955bc12299 nvme fixes for Linux 6.2
- fix  controller shutdown regression in nvme-apple (Janne Grunau)
  - fix a polling on timeout regression in nvme-pci (Keith Busch)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmPKK8kLHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYNwmg/9EUFeQ5KaJIVrJ5jtcO6oajcKW3B7vjYBS+lXR40w
 30HXg2/qDcm8d/5UqGNu8OaPP6urHY6VKISBe55SMKDn7NFMqvFd3zEqN3ip95Sq
 VgqcIykPFN69NNRI7bwD5YjP3KeEMBJ4SwNLBjSzdJB4aE+s3tdQAtvqM1RCVpGC
 Y/jLai+b2eCHfoP9DDCqLKVEyxsCKCAH1Rc3xh6AJ7oZlYbgdmMGKiYPrrWEshFn
 yGaruEeMOWBCGRY1KlyIpuXzmQCv2I1dOIeQqm4nDxwa0o8n/xVa1zSWHIWCWK9n
 wOYHO5CODeL2aXwEzQNH9yQnohcIZ1jVzyntie475yZxCZIYIhVvjzU3YSdn16Wa
 oXHBcDITbHFXRPdKbLBq7hlBHrVNGBsU8gcLMHJ3/NHvwv5fPDLvndqSj+P3QcC0
 +XCkb24ye6lxAdjD78q7DfHsMf5EFq/TjWSoGfqYuL/7/xJtf+zP2lAd0kKc/GTa
 YMd44TlOcwvGIYMLahu35ZhfoQp0V/QhL1Lf/lCgL6W+M4o9lXShZVZqVqjpHyw7
 XFnO++rizokvY4ewiUPUQPgh0Oa/EmTgZsy/BhP1f3fo2b7BHf4qhaU39N1ptq7C
 lJyM+yyNavA1yHg3yjJD4qcbaNW3Yobl3aGa4b1dfyhYfvEMw1y3s58BftG95p/g
 5gg=
 =u9Pc
 -----END PGP SIGNATURE-----

Merge tag 'nvme-6.2-2023-01-20' of git://git.infradead.org/nvme into block-6.2

Pull NVMe fixes from Christoph:

"nvme fixes for Linux 6.2

 - fix  controller shutdown regression in nvme-apple (Janne Grunau)
 - fix a polling on timeout regression in nvme-pci (Keith Busch)"

* tag 'nvme-6.2-2023-01-20' of git://git.infradead.org/nvme:
  nvme-pci: fix timeout request state check
  nvme-apple: only reset the controller when RTKit is running
  nvme-apple: reset controller during shutdown
2023-01-20 08:08:29 -07:00
Keith Busch
1c58420858 nvme-pci: fix timeout request state check
Polling the completion can progress the request state to IDLE, either
inline with the completion, or through softirq. Either way, the state
may not be COMPLETED, so don't check for that. We only care if the state
isn't IN_FLIGHT.

This is fixing an issue where the driver aborts an IO that we just
completed. Seeing the "aborting" message instead of "polled" is very
misleading as to where the timeout problem resides.

Fixes: bf392a5dc0 ("nvme-pci: Remove tag from process cq")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-19 09:08:01 +01:00
Janne Grunau
c0a4a1eafb nvme-apple: only reset the controller when RTKit is running
NVMe controller register access hangs indefinitely when the co-processor
is not running. A missed reset is preferable over a hanging thread since
it could be recoverable.

Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-19 09:08:01 +01:00
Janne Grunau
c06ba7b892 nvme-apple: reset controller during shutdown
This is a functional revert of c76b8308e4 ("nvme-apple: fix controller
shutdown in apple_nvme_disable").

The commit broke suspend/resume since apple_nvme_reset_work() tries to
disable the controller on resume. This does not work for the apple NVMe
controller since register access only works while the co-processor
firmware is running.

Disabling the NVMe controller in the shutdown path is also required
for shutting the co-processor down. The original code was appropriate
for this hardware. Add a comment to prevent a similar breaking changes
in the future.

Fixes: c76b8308e4 ("nvme-apple: fix controller shutdown in apple_nvme_disable")
Reported-by: Janne Grunau <j@jannau.net>
Link: https://lore.kernel.org/all/20230110174745.GA3576@jannau.net/
Signed-off-by: Janne Grunau <j@jannau.net>
[hch: updated with a more descriptive comment from Hector Martin]
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-19 09:07:35 +01:00
Pavel Begunkov
7746564793 block: fix hctx checks for batch allocation
When there are no read queues read requests will be assigned a
default queue on allocation. However, blk_mq_get_cached_request() is not
prepared for that and will fail all attempts to grab read requests from
the cache. Worst case it doubles the number of requests allocated,
roughly half of which will be returned by blk_mq_free_plug_rqs().

It only affects batched allocations and so is io_uring specific.
For reference, QD8 t/io_uring benchmark improves by 20-35%.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/80d4511011d7d4751b4cf6375c4e38f237d935e3.1673955390.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-17 09:56:52 -07:00
Guoqing Jiang
9d6033e350 block/rnbd-clt: fix wrong max ID in ida_alloc_max
We need to pass 'end - 1' to ida_alloc_max after switch from
ida_simple_get to ida_alloc_max.

Otherwise smatch warns.

drivers/block/rnbd/rnbd-clt.c:1460 init_dev() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?

Fixes: 24afc15dbe ("block/rnbd: Remove a useless mutex")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Link: https://lore.kernel.org/r/20221230010926.32243-1-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-17 08:33:36 -07:00
Yu Kuai
e3ff8887e7 blk-cgroup: fix missing pd_online_fn() while activating policy
If the policy defines pd_online_fn(), it should be called after
pd_init_fn(), like blkg_create().

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20230103112833.2013432-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-16 19:04:07 -07:00
Jens Axboe
3e9900f3bd pktcdvd: check for NULL returna fter calling bio_split_to_limits()
The revert of the removal of this driver happened after we fixed up
the split limits for NOWAIT issue, hence it got missed. Ensure that
we check for a NULL bio after splitting, in case it should be retried.

Marking this as fixing both commits, so that stable backport will do
this correctly.

Cc: stable@vger.kernel.org
Fixes: 9cea62b2cb ("block: don't allow splitting of a REQ_NOWAIT bio")
Fixes: 4b83e99ee7 ("Revert "pktcdvd: remove driver."")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-16 08:51:05 -07:00
Yu Kuai
216f764716 block, bfq: switch 'bfqg->ref' to use atomic refcount apis
The updating of 'bfqg->ref' should be protected by 'bfqd->lock', however,
during code review, we found that bfq_pd_free() update 'bfqg->ref'
without holding the lock, which is problematic:

1) bfq_pd_free() triggered by removing cgroup is called asynchronously;
2) bfqq will grab bfqg reference, and exit bfqq will drop the reference,
which can concurrent with 1).

Unfortunately, 'bfqd->lock' can't be held here because 'bfqd' might already
be freed in bfq_pd_free(). Fix the problem by using atomic refcount apis.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230103084755.1256479-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-15 20:53:27 -07:00
Jens Axboe
ee16c404f9 Merge branch 'md-fixes' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into block-6.2
Pull MD fix from Song:

"It fixes an issue introduced by recent code refactor."

* 'md-fixes' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md:
  md: fix incorrect declaration about claim_rdev in md_import_device
2023-01-13 20:47:48 -07:00
Adrian Huang
b0907cadab md: fix incorrect declaration about claim_rdev in md_import_device
Commit fb541ca4c3 ("md: remove lock_bdev / unlock_bdev") removes
wrappers for blkdev_get/blkdev_put. However, the uninitialized local
static variable of pointer type 'claim_rdev' in md_import_device()
is NULL, which leads to the following warning call trace:

  WARNING: CPU: 22 PID: 1037 at block/bdev.c:577 bd_prepare_to_claim+0x131/0x150
  CPU: 22 PID: 1037 Comm: mdadm Not tainted 6.2.0-rc3+ #69
  ..
  RIP: 0010:bd_prepare_to_claim+0x131/0x150
  ..
  Call Trace:
   <TASK>
   ? _raw_spin_unlock+0x15/0x30
   ? iput+0x6a/0x220
   blkdev_get_by_dev.part.0+0x4b/0x300
   md_import_device+0x126/0x1d0
   new_dev_store+0x184/0x240
   md_attr_store+0x80/0xf0
   kernfs_fop_write_iter+0x128/0x1c0
   vfs_write+0x2be/0x3c0
   ksys_write+0x5f/0xe0
   do_syscall_64+0x38/0x90
   entry_SYSCALL_64_after_hwframe+0x72/0xdc

It turns out the md device cannot be used:

  md: could not open device unknown-block(259,0).
  md: md127 stopped.

Fix the issue by declaring the local static variable of struct type
and passing the pointer of the variable to blkdev_get_by_dev().

Fixes: fb541ca4c3 ("md: remove lock_bdev / unlock_bdev")
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Adrian Huang <ahuang12@lenovo.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Song Liu <song@kernel.org>
2023-01-12 10:42:16 -08:00
Jens Axboe
3d25b1e836 nvme fixes for Linux 6.2
- Identify quirks for Apple controllers (Hector Martin)
  - fix error handling in nvme_pci_enable (Tong Zhang)
  - refuse unprivileged passthrough on partitions (Christoph Hellwig)
  - fix MAINTAINERS to not match nvmem subsystem headers (Russell King)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmO/w30LHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYPS0xAAkQ9TVeEI11lc4ySdhSDibiKzIK7hWLEjUvXywshc
 0eP31QxfTS4EGqWP+YPwtzPjqDZJOvZK1kkAI6H7whT5c0dD7ASJCLNPC/nIcXkO
 Rib9WsJvxlBCqQ5daU7X2N6yzdLT/LMTpmyBNLG/mLhLAPtq7KM2SorfxLMRkjCB
 Z77cgz/XBWnPFYBBFpAHD0FLdbL5xNwUnA09wpNnzjJnsM4EzQDFr6rsNJTuEd04
 FEuiy60YErD9TV5zDNQoqu3IcBuXJcujBOKP1QPEQxda7qjQlxSLIWKXiycFH2j2
 o+7AL2Pabka2jlkZJcI57NcDbxPfyoBmDXlGW+qb1CeZhRCXDNvRibaaE0wR2ZUI
 FRV9kwtOaiJg0deUyFDgOtZtHdJOEK0JXA/J0t5gp/DBm9VfaTA/RY9O9ZqU1phY
 8PYvvUbj3g6cfxzfZAmNh7H/kBEova1ib3f7exAXXprmkZP9etvaT/GV0fx3DDhp
 V2/TGLW2FbzmTwFWXaGIu3bHsNUfAPXriHyF+6PPvUHU4fCeK7sBDNT/+k/yYS8D
 1xF6+WP6HXwYrHMVE5hjdgZ8Fo3bRsG7vW5e91esIukgvOYLYDE2l3Grd8vB8+vW
 CqTW47hKr7r1Dn9l+eCZ/J16a8WLmoEExW5ypH8ICyl3smwe/rR0iax565Fo/Wwr
 n2Y=
 =llj+
 -----END PGP SIGNATURE-----

Merge tag 'nvme-6.2-2023-01-12' of git://git.infradead.org/nvme into block-6.2

Pull NVMe fixes from Christoph:

"nvme fixes for Linux 6.2

 - Identify quirks for Apple controllers (Hector Martin)
 - fix error handling in nvme_pci_enable (Tong Zhang)
 - refuse unprivileged passthrough on partitions (Christoph Hellwig)
 - fix MAINTAINERS to not match nvmem subsystem headers (Russell King)"

* tag 'nvme-6.2-2023-01-12' of git://git.infradead.org/nvme:
  MAINTAINERS: stop nvme matching for nvmem files
  nvme: don't allow unprivileged passthrough on partitions
  nvme: replace the "bool vec" arguments with flags in the ioctl path
  nvme: remove __nvme_ioctl
  nvme-pci: fix error handling in nvme_pci_enable()
  nvme-pci: add NVME_QUIRK_IDENTIFY_CNS quirk to Apple T2 controllers
  nvme-apple: add NVME_QUIRK_IDENTIFY_CNS quirk to fix regression
2023-01-12 10:36:35 -07:00
Russell King (Oracle)
c7c0644ead MAINTAINERS: stop nvme matching for nvmem files
The nvme patterns detect all include files starting with nvme, which
also picks up the nvmem subsystem header files. Fix this by using
a more specific pattern.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
[hch: switched to a purely inclusive pattern instead of excluding nvmem*]
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-10 08:16:39 +01:00
Christoph Hellwig
313c08c72e nvme: don't allow unprivileged passthrough on partitions
Passthrough commands can always access the entire device, and thus
submitting them on partitions is an privelege escalation.

In hindsight we should have never allowed any passthrough commands on
partitions, but it's probably too late to change that decision now.

Fixes: e4fbcf32c8 ("nvme: identify-namespace without CAP_SYS_ADMIN")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
2023-01-10 08:15:57 +01:00
Christoph Hellwig
7b7fdb8e2d nvme: replace the "bool vec" arguments with flags in the ioctl path
To prepare for passing down more information, replace the boolean
vec argument with a more extensible flags one.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
2023-01-10 08:15:51 +01:00
Christoph Hellwig
2fa1dc8637 nvme: remove __nvme_ioctl
Open code __nvme_ioctl in the two callers to make future changes that
pass down additional paramters in the ioctl path easier.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
2023-01-10 08:15:27 +01:00
Tong Zhang
09113abfb6 nvme-pci: fix error handling in nvme_pci_enable()
There are two issues in nvme_pci_enable():

 1) If pci_alloc_irq_vectors() fails, device is left enabled. Fix this by
    adding a goto disable statement.
 2) nvme_pci_configure_admin_queue could return -ENODEV, in this case,
    we will need to free IRQ properly.  Otherwise the following warning
    could be triggered:

[    5.286752] WARNING: CPU: 0 PID: 33 at kernel/irq/irqdomain.c:253 irq_domain_remove+0x12d/0x140
[    5.290547] Call Trace:
[    5.290626]  <TASK>
[    5.290695]  msi_remove_device_irq_domain+0xc9/0xf0
[    5.290843]  msi_device_data_release+0x15/0x80
[    5.290978]  release_nodes+0x58/0x90
[    5.293788] WARNING: CPU: 0 PID: 33 at kernel/irq/msi.c:276 msi_device_data_release+0x76/0x80
[    5.297573] Call Trace:
[    5.297651]  <TASK>
[    5.297719]  release_nodes+0x58/0x90
[    5.297831]  devres_release_all+0xef/0x140
[    5.298339]  device_unbind_cleanup+0x11/0xc0
[    5.298479]  really_probe+0x296/0x320

Fixes: a6ee7f19eb ("nvme-pci: call nvme_pci_configure_admin_queue from nvme_pci_enable")
Co-developed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-10 08:15:03 +01:00
Hector Martin
453116a441 nvme-pci: add NVME_QUIRK_IDENTIFY_CNS quirk to Apple T2 controllers
This mirrors the quirk added to Apple Silicon controllers in apple.c.
These controllers do not support the Active NS ID List command and
behave identically to the SoC version judging by existing user
reports/syslogs, so will need the same fix. This quirk reverts
back to NVMe 1.0 behavior and disables the broken commands.

Fixes: 811f4de034 ("nvme: avoid fallback to sequential scan due to transient issues")
Signed-off-by: Hector Martin <marcan@marcan.st>
Tested-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-10 08:15:03 +01:00
Hector Martin
aa96d6aa75 nvme-apple: add NVME_QUIRK_IDENTIFY_CNS quirk to fix regression
From the get-go, this driver and the ANS syslog have been complaining
about namespace identification. In 6.2-rc1, commit 811f4de034 ("nvme:
avoid fallback to sequential scan due to transient issues") regressed
the driver by no longer allowing fallback to sequential namespace scans,
leaving us with no namespaces.

It turns out that the real problem is that this controller claiming
NVMe 1.1 compat is treating the CNS field as a binary field, as in NVMe
1.0. This already has a quirk, NVME_QUIRK_IDENTIFY_CNS, so set it for
the controller to fix all this nonsense (including other errors
triggered by other CNS commands).

Fixes: 811f4de034 ("nvme: avoid fallback to sequential scan due to transient issues")
Fixes: 5bd2927ace ("nvme-apple: Add initial Apple SoC NVMe driver")
Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2023-01-10 08:15:03 +01:00
Tejun Heo
49e4d04f04 block: Drop spurious might_sleep() from blk_put_queue()
Dan reports the following smatch detected the following:

  block/blk-cgroup.c:1863 blkcg_schedule_throttle() warn: sleeping in atomic context

caused by blkcg_schedule_throttle() calling blk_put_queue() in an
non-sleepable context.

blk_put_queue() acquired might_sleep() in 63f93fd6fa ("block: mark
blk_put_queue as potentially blocking") which transferred the might_sleep()
from blk_free_queue().

blk_free_queue() acquired might_sleep() in e8c7d14ac6 ("block: revert back
to synchronous request_queue removal") while turning request_queue removal
synchronous. However, this isn't necessary as nothing in the free path
actually requires sleeping.

It's pretty unusual to require a sleeping context in a put operation and
it's not needed in the first place. Let's drop it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lkml.kernel.org/r/Y7g3L6fntnTtOm63@kili
Cc: Christoph Hellwig <hch@lst.de>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Fixes: e8c7d14ac6 ("block: revert back to synchronous request_queue removal") # v5.9+
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/Y7iFwjN+XzWvLv3y@slm.duckdns.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-08 20:29:28 -07:00
Paul E. McKenney
b2b50d5721 block: Remove "select SRCU"
Now that the SRCU Kconfig option is unconditionally selected, there is
no longer any point in selecting it.  Therefore, remove the "select SRCU"
Kconfig statements.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-05 08:50:10 -07:00
Jens Axboe
4b83e99ee7 Revert "pktcdvd: remove driver."
This reverts commit f40eb99897.

There are apparently still users out there of this driver. While we'd
love to remove it to ease the maintenance burden, let's reinstate it
for now until better (userspace) solutions can be developed.

Link: https://lore.kernel.org/lkml/20230104190115.ceglfefco475ev6c@pali/
Reported-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-04 14:44:13 -07:00
Jens Axboe
050a4f341f Revert "block: remove devnode callback from struct block_device_operations"
This reverts commit 85d6ce58e4.

We're reinstating the pktcdvd driver, which needs this API.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-04 14:44:02 -07:00
Jens Axboe
ee4b4e2248 Revert "block: bio_copy_data_iter"
This reverts commit db1c7d7797.

We're reinstating the pktcdvd driver, which needs this API.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-04 14:43:27 -07:00
Ming Lei
fa8e442e83 ublk: honor IO_URING_F_NONBLOCK for handling control command
Most of control command handlers may sleep, so return -EAGAIN in case
of IO_URING_F_NONBLOCK to defer the handling into io wq context.

Fixes: 71f28f3136 ("ublk_drv: add io_uring based userspace block driver")
Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230104133235.836536-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-04 13:24:53 -07:00
Jens Axboe
9cea62b2cb block: don't allow splitting of a REQ_NOWAIT bio
If we split a bio marked with REQ_NOWAIT, then we can trigger spurious
EAGAIN if constituent parts of that split bio end up failing request
allocations. Parts will complete just fine, but just a single failure
in one of the chained bios will yield an EAGAIN final result for the
parent bio.

Return EAGAIN early if we end up needing to split such a bio, which
allows for saner recovery handling.

Cc: stable@vger.kernel.org # 5.15+
Link: https://github.com/axboe/liburing/issues/766
Reported-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-04 13:24:44 -07:00
Jens Axboe
613b14884b block: handle bio_split_to_limits() NULL return
This can't happen right now, but in preparation for allowing
bio_split_to_limits() returning NULL if it ended the bio, check for it
in all the callers.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-01-04 09:05:23 -07:00
Jens Axboe
1551ed5a17 nvme fixes for Linux 6.2
- fix various problems in handling the Command Supported and Effects log
    (Christoph Hellwig)
  - don't allow unprivileged passthrough of commands that don't transfer
    data but modify logical block content (Christoph Hellwig)
  - add a features and quirks policy document (Christoph Hellwig)
  - fix some really nasty code that was correct but made smatch complain
    (Sagi Grimberg)
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmOtwsoLHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYOgrA//Tj7LXIaVwmo5TiPWnOnyrnZ40SoNpggGFSisF5XX
 A6AgLQVelKBr+HrNwZNXLNDffoGbMAfUTfE0yDBu+gckQAtrmOZCbA2oBOvTpdKB
 RJuisEMGGWy+VzVh/ddylSxvG0qQf8hwJI8eYgGNelIfa3qvICkDD4CfrKIEXJHj
 zn5qUqYcvurg3p1R386h8SoQF6+NdyudmpayJ848rE5qbJ+7yLtGUhZnGmrFB4vZ
 dSH6ccDWsp4mO4sOUGxUnGYRVQSCXp6mGLWyqBZN73PuYMn2c9h/onqCxq8Tp/tT
 VopaymCkVdXIaSGvvwv6lwbOEjeVL2zD9tDYf64xsWtENiQBiAJmON+zrzTy5ETe
 AQ8Pzbu1FlkUaZomJ57/ekgXvvt2EdUS92KgSwLm5o/M1zguC/96YeP32n6c84yS
 ciNNkcYqCihlB4VAjRNLckJOvfTd5Ejc/NPDn3rLR7u55YBPW9x5wk3eCuY7PRji
 H+B4hasGKWOioQL8OtYUnH7NcUaDIsxglvUsSbxkJ0WnaDFhixqMUGIVng8MPdhD
 wPUEauCU5ue3HnD3YfNbalNAVfP8phuTI752OMBiCj+nYU40gb+S72huTAkpxzA2
 nE4Htz68bcV35EuWgiOXQ+gAZgYQeWfAdcpNdZisClOK5N2hQ9uXW88pTCWyUbAX
 NkE=
 =RX6Q
 -----END PGP SIGNATURE-----

Merge tag 'nvme-6.2-2022-12-29' of git://git.infradead.org/nvme into block-6.2

Pull NVMe fixes from Christoph:

"nvme fixes for Linux 6.2

 - fix various problems in handling the Command Supported and Effects log
   (Christoph Hellwig)
 - don't allow unprivileged passthrough of commands that don't transfer
   data but modify logical block content (Christoph Hellwig)
 - add a features and quirks policy document (Christoph Hellwig)
 - fix some really nasty code that was correct but made smatch complain
   (Sagi Grimberg)"

* tag 'nvme-6.2-2022-12-29' of git://git.infradead.org/nvme:
  nvme-auth: fix smatch warning complaints
  nvme: consult the CSE log page for unprivileged passthrough
  nvme: also return I/O command effects from nvme_command_effects
  nvmet: don't defer passthrough commands with trivial effects to the workqueue
  nvmet: set the LBCC bit for commands that modify data
  nvmet: use NVME_CMD_EFFECTS_CSUPP instead of open coding it
  nvme: fix the NVME_CMD_EFFECTS_CSE_MASK definition
  docs, nvme: add a feature and quirk policy document
2022-12-29 11:31:45 -07:00
Sagi Grimberg
76807fcd73 nvme-auth: fix smatch warning complaints
When initializing auth context, there may be no secrets passed
by the user. Make return code explicit when returning successfully.

smatch warnings:
drivers/nvme/host/auth.c:950 nvme_auth_init_ctrl() warn: missing error code? 'ret'

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2022-12-28 06:26:35 -10:00