Message ID | 20220620034923.35633-4-guoqing.jiang@linux.dev (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | reduce the size of rnbd_clt_dev | expand |
On Mon, Jun 20, 2022 at 5:50 AM Guoqing Jiang <guoqing.jiang@linux.dev> wrote: > > The member is not needed since we can call get_disk_ro to achieve the > same goal. > > Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev> lgtm Acked-by: Jack Wang <jinpu.wang@ionos.com> > --- > drivers/block/rnbd/rnbd-clt.c | 8 ++------ > drivers/block/rnbd/rnbd-clt.h | 1 - > 2 files changed, 2 insertions(+), 7 deletions(-) > > diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c > index 6c4970878d23..0bade2680eb9 100644 > --- a/drivers/block/rnbd/rnbd-clt.c > +++ b/drivers/block/rnbd/rnbd-clt.c > @@ -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 || > @@ -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 > diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h > index 2e2e8c4a85c1..26fb91d800e3 100644 > --- a/drivers/block/rnbd/rnbd-clt.h > +++ b/drivers/block/rnbd/rnbd-clt.h > @@ -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; > -- > 2.34.1 >
diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 6c4970878d23..0bade2680eb9 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -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 || @@ -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 diff --git a/drivers/block/rnbd/rnbd-clt.h b/drivers/block/rnbd/rnbd-clt.h index 2e2e8c4a85c1..26fb91d800e3 100644 --- a/drivers/block/rnbd/rnbd-clt.h +++ b/drivers/block/rnbd/rnbd-clt.h @@ -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;
The member is not needed since we can call get_disk_ro to achieve the same goal. Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev> --- drivers/block/rnbd/rnbd-clt.c | 8 ++------ drivers/block/rnbd/rnbd-clt.h | 1 - 2 files changed, 2 insertions(+), 7 deletions(-)