Skip to content

Commit

Permalink
rnbd-clt: kill read_only from struct rnbd_clt_dev
Browse files Browse the repository at this point in the history
The member is not needed since we can call get_disk_ro to achieve the
same goal.

Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Link: https://lore.kernel.org/r/20220706133152.12058-4-guoqing.jiang@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Guoqing Jiang authored and Jens Axboe committed Aug 2, 2022
1 parent 52334f4 commit 017d76f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
8 changes: 2 additions & 6 deletions drivers/block/rnbd/rnbd-clt.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ static int rnbd_client_open(struct block_device *block_device, fmode_t mode)
{
struct rnbd_clt_dev *dev = block_device->bd_disk->private_data;

if (dev->read_only && (mode & FMODE_WRITE))
if (get_disk_ro(dev->gd) && (mode & FMODE_WRITE))
return -EPERM;

if (dev->dev_state == DEV_STATE_UNMAPPED ||
Expand Down Expand Up @@ -1402,12 +1402,8 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx)

set_capacity(dev->gd, dev->nsectors);

if (dev->access_mode == RNBD_ACCESS_RO) {
dev->read_only = true;
if (dev->access_mode == RNBD_ACCESS_RO)
set_disk_ro(dev->gd, true);
} else {
dev->read_only = false;
}

/*
* Network device does not need rotational
Expand Down
1 change: 0 additions & 1 deletion drivers/block/rnbd/rnbd-clt.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ struct rnbd_clt_dev {
char *pathname;
enum rnbd_access_mode access_mode;
u32 nr_poll_queues;
bool read_only;
bool wc;
bool fua;
u32 max_hw_sectors;
Expand Down

0 comments on commit 017d76f

Please sign in to comment.