summaryrefslogtreecommitdiff
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-23 13:44:44 +0100
committerJens Axboe <axboe@kernel.dk>2020-12-01 14:53:39 -0700
commit7918f0f6fdafa1e52c2d77c537cb55ef25fb69a3 (patch)
tree34d1be96485377aab10698ba07ab5c0b06b2889e /fs/block_dev.c
parent63d9932caecee8b0a295c608d083280b45885d10 (diff)
block: opencode devcgroup_inode_permission
Just call devcgroup_check_permission to avoid various superflous checks and a double conversion of the access flags. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Tejun Heo <tj@kernel.org> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index a2d5050c97ee..2b8c0586314f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1520,15 +1520,13 @@ static int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
struct block_device *claiming;
bool unblock_events = true;
struct gendisk *disk;
- int perm = 0;
int partno;
int ret;
- if (mode & FMODE_READ)
- perm |= MAY_READ;
- if (mode & FMODE_WRITE)
- perm |= MAY_WRITE;
- ret = devcgroup_inode_permission(bdev->bd_inode, perm);
+ ret = devcgroup_check_permission(DEVCG_DEV_BLOCK,
+ imajor(bdev->bd_inode), iminor(bdev->bd_inode),
+ ((mode & FMODE_READ) ? DEVCG_ACC_READ : 0) |
+ ((mode & FMODE_WRITE) ? DEVCG_ACC_WRITE : 0));
if (ret)
goto bdput;