diff options
| author | Ilya Dryomov <idryomov@gmail.com> | 2015-05-15 05:02:17 -0400 |
|---|---|---|
| committer | Ilya Dryomov <idryomov@gmail.com> | 2015-06-25 04:49:29 -0400 |
| commit | a319bf56a617354e62cf5f774d2ca4e1a8a3bff3 (patch) | |
| tree | cf54ed20b02c8488a342f54fd573eb57df964a3c /drivers/block | |
| parent | d50c97b566c5bbf990eff472e9feaa58fdebdd33 (diff) | |
libceph: store timeouts in jiffies, verify user input
There are currently three libceph-level timeouts that the user can
specify on mount: mount_timeout, osd_idle_ttl and osdkeepalive. All of
these are in seconds and no checking is done on user input: negative
values are accepted, we multiply them all by HZ which may or may not
overflow, arbitrarily large jiffies then get added together, etc.
There is also a bug in the way mount_timeout=0 is handled. It's
supposed to mean "infinite timeout", but that's not how wait.h APIs
treat it and so __ceph_open_session() for example will busy loop
without much chance of being interrupted if none of ceph-mons are
there.
Fix all this by verifying user input, storing timeouts capped by
msecs_to_jiffies() in jiffies and using the new ceph_timeout_jiffies()
helper for all user-specified waits to handle infinite timeouts
correctly.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'drivers/block')
| -rw-r--r-- | drivers/block/rbd.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 349115ae3bc2..992683b6b299 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
| @@ -4963,8 +4963,8 @@ out_err: | |||
| 4963 | */ | 4963 | */ |
| 4964 | static int rbd_add_get_pool_id(struct rbd_client *rbdc, const char *pool_name) | 4964 | static int rbd_add_get_pool_id(struct rbd_client *rbdc, const char *pool_name) |
| 4965 | { | 4965 | { |
| 4966 | struct ceph_options *opts = rbdc->client->options; | ||
| 4966 | u64 newest_epoch; | 4967 | u64 newest_epoch; |
| 4967 | unsigned long timeout = rbdc->client->options->mount_timeout * HZ; | ||
| 4968 | int tries = 0; | 4968 | int tries = 0; |
| 4969 | int ret; | 4969 | int ret; |
| 4970 | 4970 | ||
| @@ -4979,7 +4979,8 @@ again: | |||
| 4979 | if (rbdc->client->osdc.osdmap->epoch < newest_epoch) { | 4979 | if (rbdc->client->osdc.osdmap->epoch < newest_epoch) { |
| 4980 | ceph_monc_request_next_osdmap(&rbdc->client->monc); | 4980 | ceph_monc_request_next_osdmap(&rbdc->client->monc); |
| 4981 | (void) ceph_monc_wait_osdmap(&rbdc->client->monc, | 4981 | (void) ceph_monc_wait_osdmap(&rbdc->client->monc, |
| 4982 | newest_epoch, timeout); | 4982 | newest_epoch, |
| 4983 | opts->mount_timeout); | ||
| 4983 | goto again; | 4984 | goto again; |
| 4984 | } else { | 4985 | } else { |
| 4985 | /* the osdmap we have is new enough */ | 4986 | /* the osdmap we have is new enough */ |
