libceph: preallocate message data items
authorIlya Dryomov <idryomov@gmail.com>
Mon, 15 Oct 2018 15:38:23 +0000 (17:38 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 22 Oct 2018 08:28:22 +0000 (10:28 +0200)
commit0d9c1ab3be4c0187663096a6a084421d0a1e45c6
tree06a57638913d5badd76fe695bcb4f08992f55579
parent26f887e0a3c43f67b550e2e5d8a76e86ca11d188
libceph: preallocate message data items

Currently message data items are allocated with ceph_msg_data_create()
in setup_request_data() inside send_request().  send_request() has never
been allowed to fail, so each allocation is followed by a BUG_ON:

  data = ceph_msg_data_create(...);
  BUG_ON(!data);

It's been this way since support for multiple message data items was
added in commit 6644ed7b7e04 ("libceph: make message data be a pointer")
in 3.10.

There is no reason to delay the allocation of message data items until
the last possible moment and we certainly don't need a linked list of
them as they are only ever appended to the end and never erased.  Make
ceph_msg_new2() take max_data_items and adapt the rest of the code.

Reported-by: Jerry Lee <leisurelysw24@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/mds_client.c
include/linux/ceph/messenger.h
include/linux/ceph/msgpool.h
net/ceph/messenger.c
net/ceph/msgpool.c
net/ceph/osd_client.c