Message ID | 20230523075331.32250-8-guoqing.jiang@linux.dev (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | misc patches for rnbd | expand |
On Tue, May 23, 2023 at 9:53 AM Guoqing Jiang <guoqing.jiang@linux.dev> wrote: > > Let's always set errno after pr_err which is consistent with > default case. > > Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev> Acked-by: Jack Wang <jinpu.wang@ionos.com> > --- > drivers/block/rnbd/rnbd-srv.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c > index e51eb4b7f6e6..102831c302fc 100644 > --- a/drivers/block/rnbd/rnbd-srv.c > +++ b/drivers/block/rnbd/rnbd-srv.c > @@ -463,34 +463,33 @@ static int rnbd_srv_check_update_open_perm(struct rnbd_srv_dev *srv_dev, > struct rnbd_srv_session *srv_sess, > enum rnbd_access_mode access_mode) > { > - int ret = -EPERM; > + int ret = 0; > > mutex_lock(&srv_dev->lock); > > switch (access_mode) { > case RNBD_ACCESS_RO: > - ret = 0; > break; > case RNBD_ACCESS_RW: > if (srv_dev->open_write_cnt == 0) { > srv_dev->open_write_cnt++; > - ret = 0; > } else { > pr_err("Mapping device '%s' for session %s with RW permissions failed. Device already opened as 'RW' by %d client(s), access mode %s.\n", > srv_dev->name, srv_sess->sessname, > srv_dev->open_write_cnt, > rnbd_access_modes[access_mode].str); > + ret = -EPERM; > } > break; > case RNBD_ACCESS_MIGRATION: > if (srv_dev->open_write_cnt < 2) { > srv_dev->open_write_cnt++; > - ret = 0; > } else { > pr_err("Mapping device '%s' for session %s with migration permissions failed. Device already opened as 'RW' by %d client(s), access mode %s.\n", > srv_dev->name, srv_sess->sessname, > srv_dev->open_write_cnt, > rnbd_access_modes[access_mode].str); > + ret = -EPERM; > } > break; > default: > -- > 2.35.3 >
diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index e51eb4b7f6e6..102831c302fc 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -463,34 +463,33 @@ static int rnbd_srv_check_update_open_perm(struct rnbd_srv_dev *srv_dev, struct rnbd_srv_session *srv_sess, enum rnbd_access_mode access_mode) { - int ret = -EPERM; + int ret = 0; mutex_lock(&srv_dev->lock); switch (access_mode) { case RNBD_ACCESS_RO: - ret = 0; break; case RNBD_ACCESS_RW: if (srv_dev->open_write_cnt == 0) { srv_dev->open_write_cnt++; - ret = 0; } else { pr_err("Mapping device '%s' for session %s with RW permissions failed. Device already opened as 'RW' by %d client(s), access mode %s.\n", srv_dev->name, srv_sess->sessname, srv_dev->open_write_cnt, rnbd_access_modes[access_mode].str); + ret = -EPERM; } break; case RNBD_ACCESS_MIGRATION: if (srv_dev->open_write_cnt < 2) { srv_dev->open_write_cnt++; - ret = 0; } else { pr_err("Mapping device '%s' for session %s with migration permissions failed. Device already opened as 'RW' by %d client(s), access mode %s.\n", srv_dev->name, srv_sess->sessname, srv_dev->open_write_cnt, rnbd_access_modes[access_mode].str); + ret = -EPERM; } break; default:
Let's always set errno after pr_err which is consistent with default case. Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev> --- drivers/block/rnbd/rnbd-srv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)