aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ceph
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2015-05-15 05:02:17 -0400
committerIlya Dryomov <idryomov@gmail.com>2015-06-25 04:49:29 -0400
commita319bf56a617354e62cf5f774d2ca4e1a8a3bff3 (patch)
treecf54ed20b02c8488a342f54fd573eb57df964a3c /include/linux/ceph
parentd50c97b566c5bbf990eff472e9feaa58fdebdd33 (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 'include/linux/ceph')
-rw-r--r--include/linux/ceph/libceph.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index 85ae9a889a3f..d73a569f9bf5 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -43,9 +43,9 @@ struct ceph_options {
43 int flags; 43 int flags;
44 struct ceph_fsid fsid; 44 struct ceph_fsid fsid;
45 struct ceph_entity_addr my_addr; 45 struct ceph_entity_addr my_addr;
46 int mount_timeout; 46 unsigned long mount_timeout; /* jiffies */
47 int osd_idle_ttl; 47 unsigned long osd_idle_ttl; /* jiffies */
48 int osd_keepalive_timeout; 48 unsigned long osd_keepalive_timeout; /* jiffies */
49 49
50 /* 50 /*
51 * any type that can't be simply compared or doesn't need need 51 * any type that can't be simply compared or doesn't need need
@@ -63,9 +63,9 @@ struct ceph_options {
63/* 63/*
64 * defaults 64 * defaults
65 */ 65 */
66#define CEPH_MOUNT_TIMEOUT_DEFAULT 60 66#define CEPH_MOUNT_TIMEOUT_DEFAULT msecs_to_jiffies(60 * 1000)
67#define CEPH_OSD_KEEPALIVE_DEFAULT 5 67#define CEPH_OSD_KEEPALIVE_DEFAULT msecs_to_jiffies(5 * 1000)
68#define CEPH_OSD_IDLE_TTL_DEFAULT 60 68#define CEPH_OSD_IDLE_TTL_DEFAULT msecs_to_jiffies(60 * 1000)
69 69
70#define CEPH_MSG_MAX_FRONT_LEN (16*1024*1024) 70#define CEPH_MSG_MAX_FRONT_LEN (16*1024*1024)
71#define CEPH_MSG_MAX_MIDDLE_LEN (16*1024*1024) 71#define CEPH_MSG_MAX_MIDDLE_LEN (16*1024*1024)
@@ -93,6 +93,11 @@ enum {
93 CEPH_MOUNT_SHUTDOWN, 93 CEPH_MOUNT_SHUTDOWN,
94}; 94};
95 95
96static inline unsigned long ceph_timeout_jiffies(unsigned long timeout)
97{
98 return timeout ?: MAX_SCHEDULE_TIMEOUT;
99}
100
96struct ceph_mds_client; 101struct ceph_mds_client;
97 102
98/* 103/*