Skip to contentSkip to conversation

rbd: Remove VLA usage

PATCH Applied Kyle Spiers 2 participants 2 messages Mar 17, 2018 – Mar 20, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 rbd: Remove VLA usage

As part of the effort to remove VLAs from the kernel[1], this moves the literal values into the stack array calculation instead of using a variable for the sizing. The resulting size can be found from sizeof(buf).

[1] https://lkml.org/lkml/2018/3/7/621

---
 drivers/block/rbd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/rbd.c +4 -4
index 8e40da0..46893e0 100644
@@ -3100,8 +3100,8 @@ static int __rbd_notify_op_lock(struct rbd_device *rbd_dev,
 {
 	struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
 	struct rbd_client_id cid = rbd_get_cid(rbd_dev);
-	int buf_size = 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN;
-	char buf[buf_size];
+	char buf[4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN];
+	int buf_size = sizeof(buf);
 	void *p = buf;
 
 	dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op);
@@ -3619,8 +3619,8 @@ static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev,
 				     u64 notify_id, u64 cookie, s32 *result)
 {
 	struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
-	int buf_size = 4 + CEPH_ENCODING_START_BLK_LEN;
-	char buf[buf_size];
+	char buf[4 + CEPH_ENCODING_START_BLK_LEN];
+	int buf_size = sizeof(buf);
 	int ret;
 
 	if (result) {
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 29 lines · Kyle Spiers

As part of the effort to remove VLAs from the kernel[1], this moves the literal values into the stack array calculation instead of using a variable for the sizing. The resulting size can be found from sizeof(buf).

[1] https://lkml.org/lkml/2018/3/7/621

---
 drivers/block/rbd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/rbd.c +2 -2
index 8e40da0..46893e0 100644
@@ -3100,8 +3100,8 @@ static int __rbd_notify_op_lock(struct rbd_device *rbd_dev,
 {
        struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
        struct rbd_client_id cid = rbd_get_cid(rbd_dev);
-       int buf_size = 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN;
-       char buf[buf_size];
+       char buf[4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN];
+       int buf_size = sizeof(buf);
        void *p = buf;
 
        dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op);

drivers/block/rbd.c static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev, · line 3626

Quoted 10 lines
drivers/block/rbd.c +2 -2
@@ -3619,8 +3619,8 @@ static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev,
                                     u64 notify_id, u64 cookie, s32 *result)
 {
        struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
-       int buf_size = 4 + CEPH_ENCODING_START_BLK_LEN;
-       char buf[buf_size];
+       char buf[4 + CEPH_ENCODING_START_BLK_LEN];
+       int buf_size = sizeof(buf);
        int ret;
 
        if (result) {

Applied.

Thanks,

Ilya