Christophe JAILLET
92bbe55182
nvmet: reorder fields in 'struct nvmefc_fcp_req'
...
Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvmefc_fcp_req' from
112 to 104 bytes.
This structure is embedded in some other structures (nvme_fc_fcp_op
which itself is embedded in nvme_fcp_op_w_sgl), so it helps reducing the
size of these structures too.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:36:55 -07:00
Christophe JAILLET
0f5335e158
nvmet: reorder fields in 'struct nvme_dhchap_queue_context'
...
Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvme_dhchap_queue_context' from
416 to 400 bytes.
This structure is kvcalloc()'ed in nvme_auth_init_ctrl(), so it is likely
that the allocation can be relatively big. Saving 16 bytes per structure
may might a slight difference.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:36:51 -07:00
Christophe JAILLET
e64b0c807c
nvmet: reorder fields in 'struct nvmf_ctrl_options'
...
Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvmf_ctrl_options' from 136 to
128 bytes.
When such a structure is allocated in nvmf_create_ctrl(), because of the
way memory allocation works, when 136 bytes were requested, 192 bytes were
allocated.
So this saves 64 bytes per allocation, 1 cache line to hold the whole
structure and a few cycles when zeroing the memory in nvmf_create_ctrl().
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:36:47 -07:00
Christophe JAILLET
9d217fb0e7
nvme: reorder fields in 'struct nvme_ctrl'
...
Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvme_ctrl' from 5368 to 5344
bytes when all CONFIG_* are defined.
This structure is embedded into some other structures, so it helps reducing
their size as well.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:36:42 -07:00
Christophe JAILLET
c60651e32f
nvmet: reorder fields in 'struct nvmet_sq'
...
Group some variables based on their sizes to reduce holes.
On x86_64, this shrinks the size of 'struct nvmet_sq' from 472 to 464
bytes when CONFIG_NVME_TARGET_AUTH is defined.
This structure is embedded into some other structures, so it helps reducing
their sizes as well.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:36:37 -07:00
Keith Busch
a249d3066d
nvme-fabrics: add queue setup helpers
...
tcp and rdma transports have lots of duplicate code setting up the
different queue mappings. Add common helpers.
Cc: Chaitanya Kulkarni <kch@nvidia.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:33:03 -07:00
Irvin Cote
4a4d9bc0c8
nvme-pci: cleaning up nvme_pci_init_request
...
Erase the superfluous line that retrieves the nvme_dev.
Signed-off-by: Irvin Cote <irvincoteg@gmail.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:33:03 -07:00
Max Gurtovoy
f3f2837315
nvme-rdma: fix typo in comment
...
There is no ib_stop_cq API and the need for the +1 is for ib_drain_qp.
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Reviewed-by: Israel Rukshin <israelr@nvidia.com >
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:33:02 -07:00
Chaitanya Kulkarni
7ed5cf8e6d
nvme-core: fix dev_pm_qos memleak
...
Call dev_pm_qos_hide_latency_tolerance() in the error unwind patch to
avoid following kmemleak:-
blktests (master) # kmemleak-clear; ./check nvme/044;
blktests (master) # kmemleak-scan ; kmemleak-show
nvme/044 (Test bi-directional authentication) [passed]
runtime 2.111s ... 2.124s
unreferenced object 0xffff888110c46240 (size 96):
comm "nvme", pid 33461, jiffies 4345365353 (age 75.586s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<0000000069ac2cec>] kmalloc_trace+0x25/0x90
[<000000006acc66d5>] dev_pm_qos_update_user_latency_tolerance+0x6f/0x100
[<00000000cc376ea7>] nvme_init_ctrl+0x38e/0x410 [nvme_core]
[<000000007df61b4b>] 0xffffffffc05e88b3
[<00000000d152b985>] 0xffffffffc05744cb
[<00000000f04a4041>] vfs_write+0xc5/0x3c0
[<00000000f9491baf>] ksys_write+0x5f/0xe0
[<000000001c46513d>] do_syscall_64+0x3b/0x90
[<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
Link: https://lore.kernel.org/linux-nvme/CAHj4cs-nDaKzMx2txO4dbE+Mz9ePwLtU0e3egz+StmzOUgWUrA@mail.gmail.com/
Fixes: f50fff73d6 ("nvme: implement In-Band authentication")
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com >
Tested-by: Yi Zhang <yi.zhang@redhat.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:33:02 -07:00
Chaitanya Kulkarni
3a12a0b868
nvme-core: add missing fault-injection cleanup
...
Add missing fault-injection cleanup in nvme_init_ctrl() in the error
unwind path that also fixes following message for blktests:-
linux-block (for-next) # grep debugfs debugfs-err.log
[ 147.853464] debugfs: Directory 'nvme1' with parent '/' already present!
[ 147.853973] nvme1: failed to create debugfs attr
[ 148.802490] debugfs: Directory 'nvme1' with parent '/' already present!
[ 148.803244] nvme1: failed to create debugfs attr
[ 148.877304] debugfs: Directory 'nvme1' with parent '/' already present!
[ 148.877775] nvme1: failed to create debugfs attr
[ 149.816652] debugfs: Directory 'nvme1' with parent '/' already present!
[ 149.818011] nvme1: failed to create debugfs attr
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com >
Tested-by: Yi Zhang <yi.zhang@redhat.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:33:02 -07:00
Chaitanya Kulkarni
99c2dcc8ff
nvme-core: fix memory leak in dhchap_ctrl_secret
...
Free dhchap_secret in nvme_ctrl_dhchap_ctrl_secret_store() before we
return when nvme_auth_generate_key() returns error.
Fixes: f50fff73d6 ("nvme: implement In-Band authentication")
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:33:02 -07:00
Chaitanya Kulkarni
a836ca33c5
nvme-core: fix memory leak in dhchap_secret_store
...
Free dhchap_secret in nvme_ctrl_dhchap_secret_store() before we return
fix following kmemleack:-
unreferenced object 0xffff8886376ea800 (size 64):
comm "check", pid 22048, jiffies 4344316705 (age 92.199s)
hex dump (first 32 bytes):
44 48 48 43 2d 31 3a 30 30 3a 6e 78 72 35 4b 67 DHHC-1:00:nxr5Kg
75 58 34 75 6f 41 78 73 4a 61 34 63 2f 68 75 4c uX4uoAxsJa4c/huL
backtrace:
[<0000000030ce5d4b>] __kmalloc+0x4b/0x130
[<000000009be1cdc1>] nvme_ctrl_dhchap_secret_store+0x8f/0x160 [nvme_core]
[<00000000ac06c96a>] kernfs_fop_write_iter+0x12b/0x1c0
[<00000000437e7ced>] vfs_write+0x2ba/0x3c0
[<00000000f9491baf>] ksys_write+0x5f/0xe0
[<000000001c46513d>] do_syscall_64+0x3b/0x90
[<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
unreferenced object 0xffff8886376eaf00 (size 64):
comm "check", pid 22048, jiffies 4344316736 (age 92.168s)
hex dump (first 32 bytes):
44 48 48 43 2d 31 3a 30 30 3a 6e 78 72 35 4b 67 DHHC-1:00:nxr5Kg
75 58 34 75 6f 41 78 73 4a 61 34 63 2f 68 75 4c uX4uoAxsJa4c/huL
backtrace:
[<0000000030ce5d4b>] __kmalloc+0x4b/0x130
[<000000009be1cdc1>] nvme_ctrl_dhchap_secret_store+0x8f/0x160 [nvme_core]
[<00000000ac06c96a>] kernfs_fop_write_iter+0x12b/0x1c0
[<00000000437e7ced>] vfs_write+0x2ba/0x3c0
[<00000000f9491baf>] ksys_write+0x5f/0xe0
[<000000001c46513d>] do_syscall_64+0x3b/0x90
[<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
Fixes: f50fff73d6 ("nvme: implement In-Band authentication")
Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com >
Tested-by: Yi Zhang <yi.zhang@redhat.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Sagi Grimberg <sagi@grimberg.me >
Signed-off-by: Keith Busch <kbusch@kernel.org >
2023-06-12 10:33:02 -07:00
Yu Kuai
4f1731df60
blk-mq: fix potential io hang by wrong 'wake_batch'
...
In __blk_mq_tag_busy/idle(), updating 'active_queues' and calculating
'wake_batch' is not atomic:
t1: t2:
_blk_mq_tag_busy blk_mq_tag_busy
inc active_queues
// assume 1->2
inc active_queues
// 2 -> 3
blk_mq_update_wake_batch
// calculate based on 3
blk_mq_update_wake_batch
/* calculate based on 2, while active_queues is actually 3. */
Fix this problem by protecting them wih 'tags->lock', this is not a hot
path, so performance should not be concerned. And now that all writers
are inside the lock, switch 'actives_queues' from atomic to unsigned
int.
Fixes: 180dccb0db ("blk-mq: fix tag_get wait task can't be awakened")
Signed-off-by: Yu Kuai <yukuai3@huawei.com >
Reviewed-by: Jan Kara <jack@suse.cz >
Link: https://lore.kernel.org/r/20230610023043.2559121-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 09:55:53 -06:00
Christoph Hellwig
0733ad8002
fs: remove the now unused FMODE_* flags
...
FMODE_NDELAY, FMODE_EXCL and FMODE_WRITE_IOCTL were only used for
block internal purposed and are now entirely unused, so remove them.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Reviewed-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-31-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:05 -06:00
Christoph Hellwig
ee3249a8ce
block: store the holder in file->private_data
...
Store the file struct used as the holder in file->private_data as an
indicator that this file descriptor was opened exclusively to remove
the last use of FMODE_EXCL.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Link: https://lore.kernel.org/r/20230608110258.189493-30-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:05 -06:00
Christoph Hellwig
4e762d8623
block: always use I_BDEV on file->f_mapping->host to find the bdev
...
Always use I_BDEV(file->f_mapping->host) to find the bdev for a file to
free up file->private_data for other uses.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-29-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:05 -06:00
Christoph Hellwig
05bdb99653
block: replace fmode_t with a block-specific type for block open flags
...
The only overlap between the block open flags mapped into the fmode_t and
other uses of fmode_t are FMODE_READ and FMODE_WRITE. Define a new
blk_mode_t instead for use in blkdev_get_by_{dev,path}, ->open and
->ioctl and stop abusing fmode_t.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Acked-by: Jack Wang <jinpu.wang@ionos.com > [rnbd]
Reviewed-by: Hannes Reinecke <hare@suse.de >
Reviewed-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-28-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:05 -06:00
Christoph Hellwig
5e4ea83467
block: remove unused fmode_t arguments from ioctl handlers
...
A few ioctl handlers have fmode_t arguments that are entirely unused,
remove them.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Link: https://lore.kernel.org/r/20230608110258.189493-27-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
cfb425761c
block: move a few internal definitions out of blkdev.h
...
All these helpers are only used in core block code, so move them out of
the public header.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-26-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
bd6abfc8e7
ubd: remove commented out code in ubd_open
...
This code has been dead forever, make sure it doesn't show up in code
searches.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: Richard Weinberger <richard@nod.at >
Link: https://lore.kernel.org/r/20230608110258.189493-25-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
99b0778081
rnbd-srv: replace sess->open_flags with a "bool readonly"
...
Stop passing the fmode_t around and just use a simple bool to track if
an export is read-only.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Link: https://lore.kernel.org/r/20230608110258.189493-24-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
658afed19c
mtd: block: use a simple bool to track open for write
...
Instead of propagating the fmode_t, just use a bool to track if a mtd
block device was opened for writing.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: Richard Weinberger <richard@nod.at >
Link: https://lore.kernel.org/r/20230608110258.189493-23-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
7d9d7d59d4
nvme: replace the fmode_t argument to the nvme ioctl handlers with a simple bool
...
Instead of passing a fmode_t and only checking it fo0r FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Reviewed-by: Keith Busch <kbusch@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-22-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
1991299e49
scsi: replace the fmode_t argument to ->sg_io_fn with a simple bool
...
Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-21-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
2e80089c18
scsi: replace the fmode_t argument to scsi_ioctl with a simple bool
...
Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-20-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
5f4eb9d541
scsi: replace the fmode_t argument to scsi_cmd_allowed with a simple bool
...
Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-19-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
81b1fb7d17
fs: remove sb->s_mode
...
There is no real need to store the open mode in the super_block now.
It is only used by f2fs, which can easily recalculate it.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-18-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
3f0b3e785e
block: add a sb_open_mode helper
...
Add a helper to return the open flags for blkdev_get_by* for passed in
super block flags instead of open coding the logic in many places.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-17-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
2736e8eeb0
block: use the holder as indication for exclusive opens
...
The current interface for exclusive opens is rather confusing as it
requires both the FMODE_EXCL flag and a holder. Remove the need to pass
FMODE_EXCL and just key off the exclusive open off a non-NULL holder.
For blkdev_put this requires adding the holder argument, which provides
better debug checking that only the holder actually releases the hold,
but at the same time allows removing the now superfluous mode argument.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: David Sterba <dsterba@suse.com > [btrfs]
Acked-by: Jack Wang <jinpu.wang@ionos.com > [rnbd]
Link: https://lore.kernel.org/r/20230608110258.189493-16-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
2ef789288a
btrfs: don't pass a holder for non-exclusive blkdev_get_by_path
...
Passing a holder to blkdev_get_by_path when FMODE_EXCL isn't set doesn't
make sense, so pass NULL instead and remove the holder argument from the
call chains the only end up in non-FMODE_EXCL blkdev_get_by_path calls.
Exclusive mode for device scanning is not used since commit 50d281fc43
("btrfs: scan device in non-exclusive mode")".
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: David Sterba <dsterba@suse.com >
Link: https://lore.kernel.org/r/20230608110258.189493-15-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
5ee607675d
rnbd-srv: don't pass a holder for non-exclusive blkdev_get_by_path
...
Passing a holder to blkdev_get_by_path when FMODE_EXCL isn't set doesn't
make sense, so pass NULL instead.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Link: https://lore.kernel.org/r/20230608110258.189493-14-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
29499ab060
bcache: don't pass a stack address to blkdev_get_by_path
...
sb is just an on-stack pointer that can easily be reused by other calls.
Switch to use the bcache-wide bcache_kobj instead as there is no need to
claim per-bcache device anyway.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Link: https://lore.kernel.org/r/20230608110258.189493-13-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
c889d0793d
swsusp: don't pass a stack address to blkdev_get_by_path
...
holder is just an on-stack pointer that can easily be reused by other calls,
replace it with a static variable that doesn't change.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Rafael J. Wysocki <rafael@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-12-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
7ee34cbc29
block: rename blkdev_close to blkdev_release
...
Make the function name match the method name.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-11-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
ae220766d8
block: remove the unused mode argument to ->release
...
The mode argument to the ->release block_device_operation is never used,
so remove it.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: Jack Wang <jinpu.wang@ionos.com > [rnbd]
Link: https://lore.kernel.org/r/20230608110258.189493-10-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
d32e2bf837
block: pass a gendisk to ->open
...
->open is only called on the whole device. Make that explicit by
passing a gendisk instead of the block_device.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Acked-by: Jack Wang <jinpu.wang@ionos.com > [rnbd]
Link: https://lore.kernel.org/r/20230608110258.189493-9-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:04 -06:00
Christoph Hellwig
444aa2c58c
block: pass a gendisk on bdev_check_media_change
...
bdev_check_media_change should only ever be called for the whole device.
Pass a gendisk to make that explicit and rename the function to
disk_check_media_change.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-8-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:03 -06:00
Christoph Hellwig
7ae24fcee9
cdrom: remove the unused mode argument to cdrom_release
...
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Phillip Potter <phil@philpotter.co.uk >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:03 -06:00
Christoph Hellwig
8cdf433e2b
cdrom: track if a cdrom_device_info was opened for data
...
Set a flag when a cdrom_device_info is opened for writing, instead of
trying to figure out this at release time. This will allow to eventually
remove the mode argument to the ->release block_device_operation as
nothing but the CDROM drivers uses that argument.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Phillip Potter <phil@philpotter.co.uk >
Acked-by: Christian Brauner <brauner@kernel.org >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Link: https://lore.kernel.org/r/20230608110258.189493-6-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:03 -06:00
Christoph Hellwig
a4cec8bc14
cdrom: remove the unused cdrom_close_write release code
...
cdrom_close_write is empty, and the for_data flag it is keyed off is
never set. Remove all this clutter.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Phillip Potter <phil@philpotter.co.uk >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:03 -06:00
Christoph Hellwig
473399b50d
cdrom: remove the unused mode argument to cdrom_ioctl
...
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Phillip Potter <phil@philpotter.co.uk >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:03 -06:00
Christoph Hellwig
764b83100b
cdrom: remove the unused bdev argument to cdrom_open
...
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Phillip Potter <phil@philpotter.co.uk >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:03 -06:00
Christoph Hellwig
9d1c92872e
block: also call ->open for incremental partition opens
...
For whole devices ->open is called for each open, but for partitions it
is only called on the first open of a partition, e.g.:
open("/dev/vdb", ...)
open("/dev/vdb", ...)
- 2 call to ->open
open("/dev/vdb1", ...)
open("/dev/vdb", ...)
- 2 call to ->open
open("/dev/vdb", ...)
open("/dev/vdb", ...)
- just open call to ->open
This is problematic as various block drivers look at open flags and
might not do all the required setup if the earlier open was with an
odd flag like O_NDELAY or the magic 3 ioctl-only open mode.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Phillip Potter <phil@philpotter.co.uk >
Reviewed-by: Hannes Reinecke <hare@suse.de >
Acked-by: Christian Brauner <brauner@kernel.org >
Link: https://lore.kernel.org/r/20230608110258.189493-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-12 08:04:03 -06:00
Guoqing Jiang
fece685cc7
block/rnbd-srv: make process_msg_sess_info returns void
...
Change the return type to void given it always returns 0.
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev >
Link: https://lore.kernel.org/r/20230524070026.2932-9-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-11 19:48:42 -06:00
Guoqing Jiang
d3fc0b4664
block/rnbd-srv: init err earlier in rnbd_srv_init_module
...
With this, we can remove several lines of code.
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev >
Link: https://lore.kernel.org/r/20230524070026.2932-8-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-11 19:48:42 -06:00
Guoqing Jiang
6a12d53795
block/rnbd-srv: init ret with 0 instead of -EPERM
...
Let's always set errno after pr_err which is consistent with
default case.
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev >
Link: https://lore.kernel.org/r/20230524070026.2932-7-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-11 19:48:42 -06:00
Guoqing Jiang
3ecdbf9151
block/rnbd-srv: rename one member in rnbd_srv_dev
...
It actually represents the name of rnbd_srv_dev.
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev >
Link: https://lore.kernel.org/r/20230524070026.2932-6-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-11 19:48:42 -06:00
Guoqing Jiang
ba2eed1cf8
block/rnbd-srv: no need to check sess_dev
...
Check ret is enough since if sess_dev is NULL which also
implies ret should be 0.
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev >
Link: https://lore.kernel.org/r/20230524070026.2932-5-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-11 19:48:42 -06:00
Guoqing Jiang
d6e94913cb
block/rnbd: introduce rnbd_access_modes
...
Add one new array (marked with __maybe_unused to prevent gcc warning about
"defined but not used" with W=1), then we can remove rnbd_access_mode_str
and rnbd-common.c accordingly.
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev >
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Link: https://lore.kernel.org/r/20230524070026.2932-4-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-11 19:48:42 -06:00
Guoqing Jiang
5783153ac6
block/rnbd-srv: remove unused header
...
No need to include it since none of macros in limits.h are
used by rnbd-srv.
Acked-by: Jack Wang <jinpu.wang@ionos.com >
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev >
Link: https://lore.kernel.org/r/20230524070026.2932-3-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2023-06-11 19:48:42 -06:00