Colin Ian King
af22fef3e7
block: Remove redundant initialization of variable ret
...
The variable ret is being initialized with a value that is never
read, it is being updated later on. The assignment is redundant and
can be removed.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com >
Link: https://lore.kernel.org/r/20211126230652.1175636-1-colin.i.king@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-11-29 06:41:29 -07:00
Christoph Hellwig
140862805a
block: remove the GENHD_FL_HIDDEN check in blkdev_get_no_open
...
Hidden gendisks never hash the block device inode, so this can't happen.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20211122130625.1136848-8-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-11-29 06:38:04 -07:00
Christoph Hellwig
1545e0b419
block: move GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE to disk->event_flags
...
GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE is all about the event reporting
mechanism, so move it to the event_flags field.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20211122130625.1136848-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-11-29 06:35:21 -07:00
Ming Lei
efcf593223
block: avoid to touch unloaded module instance when opening bdev
...
disk->fops->owner is grabbed in blkdev_get_no_open() after the disk
kobject refcount is increased. This way can't make sure that
disk->fops->owner is still alive since del_gendisk() still can move
on if the kobject refcount of disk is grabbed by open() and
disk->fops->open() isn't called yet.
Fixes the issue by moving try_module_get() into blkdev_get_by_dev()
with ->open_mutex() held, then we can drain the in-progress open()
in del_gendisk(). Meantime new open() won't succeed because disk
becomes not alive.
This way is reasonable because blkdev_get_no_open() needn't to touch
disk->fops or defined callbacks.
Cc: Christoph Hellwig <hch@lst.de >
Cc: czhong@redhat.com
Signed-off-by: Ming Lei <ming.lei@redhat.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20211111020343.316126-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-11-22 18:35:37 -07:00
Christoph Hellwig
1e03a36bdf
block: simplify the block device syncing code
...
Get rid of the indirections and just provide a sync_bdevs
helper for the generic sync code.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20211019062530.2174626-8-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-10-22 08:36:55 -06:00
Christoph Hellwig
70164eb6cc
block: remove __sync_blockdev
...
Instead offer a new sync_blockdev_nowait helper for the !wait case.
This new helper is exported as it will grow modular callers in a bit.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20211019062530.2174626-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-10-22 08:36:55 -06:00
Jackie Liu
057178cf51
fs: bdev: fix conflicting comment from lookup_bdev
...
We switched to directly use dev_t to get block device, lookup changed the
meaning of use, now we fix this conflicting comment.
Fixes: 4e7b5671c6 ("block: remove i_bdev")
Cc: Jens Axboe <axboe@kernel.dk >
Cc: Christoph Hellwig <hch@lst.de >
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20211021071344.1600362-1-liu.yun@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-10-21 08:24:14 -06:00
Pavel Begunkov
025a38651b
block: use bdev_get_queue() in bdev.c
...
Convert bdev->bd_disk->queue to bdev_get_queue(), it's uses a cached
queue pointer and so is faster.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com >
Link: https://lore.kernel.org/r/a352936ce5d9ac719645b1e29b173d931ebcdc02.1634219547.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-10-18 06:17:36 -06:00
Pavel Begunkov
17220ca5ce
block: cache request queue in bdev
...
There are tons of places where we need to get a request_queue only
having bdev, which turns into bdev->bd_disk->queue. There are probably a
hundred of such places considering inline helpers, and enough of them
are in hot paths.
Cache queue pointer in struct block_device and make use of it in
bdev_get_queue().
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com >
Link: https://lore.kernel.org/r/a3bfaecdd28956f03629d0ca5c63ebc096e1c809.1634219547.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-10-18 06:17:36 -06:00
Christoph Hellwig
fe45e630a1
block: move integrity handling out of <linux/blkdev.h>
...
Split the integrity/metadata handling definitions out into a new header.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com >
Link: https://lore.kernel.org/r/20210920123328.1399408-17-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-10-18 06:17:02 -06:00
Tetsuo Handa
06cc978d3f
block: genhd: fix double kfree() in __alloc_disk_node()
...
syzbot is reporting use-after-free read at bdev_free_inode() [1], for
kfree() from __alloc_disk_node() is called before bdev_free_inode()
(which is called after RCU grace period) reads bdev->bd_disk and calls
kfree(bdev->bd_disk).
Fix use-after-free read followed by double kfree() problem
by making sure that bdev->bd_disk is NULL when calling iput().
Link: https://syzkaller.appspot.com/bug?extid=8281086e8a6fbfbd952a [1]
Reported-by: syzbot <syzbot+8281086e8a6fbfbd952a@syzkaller.appspotmail.com >
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/e6dd13c5-8db0-4392-6e78-a42ee5d2a1c4@i-love.sakura.ne.jp
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-10-02 07:29:20 -06:00
Christoph Hellwig
0dca4462ed
block: move fs/block_dev.c to block/bdev.c
...
Move it together with the rest of the block layer.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Link: https://lore.kernel.org/r/20210907141303.1371844-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk >
2021-09-07 08:39:40 -06:00