summaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-09-09 16:15:08 +0300
committerJens Axboe <axboe@kernel.dk>2022-09-21 17:35:23 +0300
commit6856b194b29f066b2d6d9e10b91ca1a4c9d8fbb2 (patch)
treea7f242c4871bba4162a6056b37d8b919b0993b4f /drivers/block
parent2ecaa58104c7f9d58a818ddab7e14ee021e66553 (diff)
downloadlinux-6856b194b29f066b2d6d9e10b91ca1a4c9d8fbb2.tar.xz
rnbd-srv: remove rnbd_dev_{open,close}
These can be trivially open coded in the callers. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Acked-by: Jack Wang <jinpu.wang@ionos.com> Link: https://lore.kernel.org/r/20220909131509.3263924-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rnbd/Makefile1
-rw-r--r--drivers/block/rnbd/rnbd-srv-dev.c42
-rw-r--r--drivers/block/rnbd/rnbd-srv-dev.h12
-rw-r--r--drivers/block/rnbd/rnbd-srv.c25
4 files changed, 18 insertions, 62 deletions
diff --git a/drivers/block/rnbd/Makefile b/drivers/block/rnbd/Makefile
index 5fc05e667950..40b31630822c 100644
--- a/drivers/block/rnbd/Makefile
+++ b/drivers/block/rnbd/Makefile
@@ -10,7 +10,6 @@ CFLAGS_rnbd-srv-trace.o = -I$(src)
rnbd-server-y := rnbd-common.o \
rnbd-srv.o \
- rnbd-srv-dev.o \
rnbd-srv-sysfs.o \
rnbd-srv-trace.o
diff --git a/drivers/block/rnbd/rnbd-srv-dev.c b/drivers/block/rnbd/rnbd-srv-dev.c
deleted file mode 100644
index 38131fa5718d..000000000000
--- a/drivers/block/rnbd/rnbd-srv-dev.c
+++ /dev/null
@@ -1,42 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * RDMA Network Block Driver
- *
- * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
- * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
- * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
- */
-#undef pr_fmt
-#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
-
-#include "rnbd-srv-dev.h"
-#include "rnbd-log.h"
-
-struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags)
-{
- struct rnbd_dev *dev;
- int ret;
-
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (!dev)
- return ERR_PTR(-ENOMEM);
-
- dev->bdev = blkdev_get_by_path(path, flags, THIS_MODULE);
- ret = PTR_ERR_OR_ZERO(dev->bdev);
- if (ret)
- goto err;
-
- dev->blk_open_flags = flags;
-
- return dev;
-
-err:
- kfree(dev);
- return ERR_PTR(ret);
-}
-
-void rnbd_dev_close(struct rnbd_dev *dev)
-{
- blkdev_put(dev->bdev, dev->blk_open_flags);
- kfree(dev);
-}
diff --git a/drivers/block/rnbd/rnbd-srv-dev.h b/drivers/block/rnbd/rnbd-srv-dev.h
index 328dc915832c..abaf77d68e5b 100644
--- a/drivers/block/rnbd/rnbd-srv-dev.h
+++ b/drivers/block/rnbd/rnbd-srv-dev.h
@@ -17,16 +17,4 @@ struct rnbd_dev {
fmode_t blk_open_flags;
};
-/**
- * rnbd_dev_open() - Open a device
- * @path: path to open
- * @flags: open flags
- */
-struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags);
-
-/**
- * rnbd_dev_close() - Close a device
- */
-void rnbd_dev_close(struct rnbd_dev *dev);
-
#endif /* RNBD_SRV_DEV_H */
diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index d487281a37f8..e9c8a722d9c5 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -220,7 +220,9 @@ void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev *sess_dev, bool keep_id)
rnbd_put_sess_dev(sess_dev);
wait_for_completion(&dc); /* wait for inflights to drop to zero */
- rnbd_dev_close(sess_dev->rnbd_dev);
+ blkdev_put(sess_dev->rnbd_dev->bdev,
+ sess_dev->rnbd_dev->blk_open_flags);
+ kfree(sess_dev->rnbd_dev);
mutex_lock(&sess_dev->dev->lock);
list_del(&sess_dev->dev_list);
if (sess_dev->open_flags & FMODE_WRITE)
@@ -721,11 +723,19 @@ static int process_msg_open(struct rnbd_srv_session *srv_sess,
goto reject;
}
- rnbd_dev = rnbd_dev_open(full_path, open_flags);
- if (IS_ERR(rnbd_dev)) {
- pr_err("Opening device '%s' on session %s failed, failed to open the block device, err: %ld\n",
- full_path, srv_sess->sessname, PTR_ERR(rnbd_dev));
- ret = PTR_ERR(rnbd_dev);
+ rnbd_dev = kzalloc(sizeof(*rnbd_dev), GFP_KERNEL);
+ if (!rnbd_dev) {
+ ret = -ENOMEM;
+ goto free_path;
+ }
+
+ rnbd_dev->blk_open_flags = open_flags;
+ rnbd_dev->bdev = blkdev_get_by_path(full_path, open_flags, THIS_MODULE);
+ if (IS_ERR(rnbd_dev->bdev)) {
+ ret = PTR_ERR(rnbd_dev->bdev);
+ pr_err("Opening device '%s' on session %s failed, failed to open the block device, err: %d\n",
+ full_path, srv_sess->sessname, ret);
+ kfree(rnbd_dev);
goto free_path;
}
@@ -797,7 +807,8 @@ srv_dev_put:
}
rnbd_put_srv_dev(srv_dev);
rnbd_dev_close:
- rnbd_dev_close(rnbd_dev);
+ blkdev_put(rnbd_dev->bdev, rnbd_dev->blk_open_flags);
+ kfree(rnbd_dev);
free_path:
kfree(full_path);
reject: