diff options
author | David Howells <dhowells@redhat.com> | 2014-07-18 13:56:35 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2014-07-22 16:46:23 -0400 |
commit | efa64c0978a1fb3de8bca6f931b9858c3e371f1f (patch) | |
tree | 1d89d5c247eff51025fe9f31bb7c8273693b8964 /net | |
parent | f9167789df53f22af771fb6690a3d36aa21d74c5 (diff) |
KEYS: Ceph: Use key preparsing
Make use of key preparsing in Ceph so that quota size determination can take
place prior to keyring locking when a key is being added.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Steve Dickson <steved@redhat.com>
Reviewed-by: Sage Weil <sage@redhat.com>
cc: Tommi Virtanen <tommi.virtanen@dreamhost.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/crypto.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c index 6e7a236525b6..2c8078d990ee 100644 --- a/net/ceph/crypto.c +++ b/net/ceph/crypto.c | |||
@@ -423,8 +423,7 @@ int ceph_encrypt2(struct ceph_crypto_key *secret, void *dst, size_t *dst_len, | |||
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | static int ceph_key_instantiate(struct key *key, | 426 | static int ceph_key_preparse(struct key_preparsed_payload *prep) |
427 | struct key_preparsed_payload *prep) | ||
428 | { | 427 | { |
429 | struct ceph_crypto_key *ckey; | 428 | struct ceph_crypto_key *ckey; |
430 | size_t datalen = prep->datalen; | 429 | size_t datalen = prep->datalen; |
@@ -435,10 +434,6 @@ static int ceph_key_instantiate(struct key *key, | |||
435 | if (datalen <= 0 || datalen > 32767 || !prep->data) | 434 | if (datalen <= 0 || datalen > 32767 || !prep->data) |
436 | goto err; | 435 | goto err; |
437 | 436 | ||
438 | ret = key_payload_reserve(key, datalen); | ||
439 | if (ret < 0) | ||
440 | goto err; | ||
441 | |||
442 | ret = -ENOMEM; | 437 | ret = -ENOMEM; |
443 | ckey = kmalloc(sizeof(*ckey), GFP_KERNEL); | 438 | ckey = kmalloc(sizeof(*ckey), GFP_KERNEL); |
444 | if (!ckey) | 439 | if (!ckey) |
@@ -450,7 +445,8 @@ static int ceph_key_instantiate(struct key *key, | |||
450 | if (ret < 0) | 445 | if (ret < 0) |
451 | goto err_ckey; | 446 | goto err_ckey; |
452 | 447 | ||
453 | key->payload.data = ckey; | 448 | prep->payload[0] = ckey; |
449 | prep->quotalen = datalen; | ||
454 | return 0; | 450 | return 0; |
455 | 451 | ||
456 | err_ckey: | 452 | err_ckey: |
@@ -459,12 +455,20 @@ err: | |||
459 | return ret; | 455 | return ret; |
460 | } | 456 | } |
461 | 457 | ||
458 | static void ceph_key_free_preparse(struct key_preparsed_payload *prep) | ||
459 | { | ||
460 | struct ceph_crypto_key *ckey = prep->payload[0]; | ||
461 | ceph_crypto_key_destroy(ckey); | ||
462 | kfree(ckey); | ||
463 | } | ||
464 | |||
462 | static int ceph_key_match(const struct key *key, const void *description) | 465 | static int ceph_key_match(const struct key *key, const void *description) |
463 | { | 466 | { |
464 | return strcmp(key->description, description) == 0; | 467 | return strcmp(key->description, description) == 0; |
465 | } | 468 | } |
466 | 469 | ||
467 | static void ceph_key_destroy(struct key *key) { | 470 | static void ceph_key_destroy(struct key *key) |
471 | { | ||
468 | struct ceph_crypto_key *ckey = key->payload.data; | 472 | struct ceph_crypto_key *ckey = key->payload.data; |
469 | 473 | ||
470 | ceph_crypto_key_destroy(ckey); | 474 | ceph_crypto_key_destroy(ckey); |
@@ -473,7 +477,9 @@ static void ceph_key_destroy(struct key *key) { | |||
473 | 477 | ||
474 | struct key_type key_type_ceph = { | 478 | struct key_type key_type_ceph = { |
475 | .name = "ceph", | 479 | .name = "ceph", |
476 | .instantiate = ceph_key_instantiate, | 480 | .preparse = ceph_key_preparse, |
481 | .free_preparse = ceph_key_free_preparse, | ||
482 | .instantiate = generic_key_instantiate, | ||
477 | .match = ceph_key_match, | 483 | .match = ceph_key_match, |
478 | .destroy = ceph_key_destroy, | 484 | .destroy = ceph_key_destroy, |
479 | }; | 485 | }; |