Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp931653imm; Wed, 20 Jun 2018 08:52:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIFLi6HULtTd78E1IOr2j0m7FGUqc5tOQRbCVk+N2VcN6TBZeVxPi0ayRJviRrTbz/heKiP X-Received: by 2002:a17:902:8306:: with SMTP id bd6-v6mr24592443plb.120.1529509938890; Wed, 20 Jun 2018 08:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529509938; cv=none; d=google.com; s=arc-20160816; b=f/7PmxmcwFlui7E+JSSF7hyioAZXWdwDsYmeZIzjw7lB5SeiNIRALxRa8P0+zDMzPp Qf7yoaPNu7Wruv/F0ADspZkkjGHLUo1UfZV883pcHgSUce9XFPhh1pmXS43kzDzL32Wp aaKHaDqpCkb3yO30ME5PtcxCuAcoiZR2+/XiE80rR1NlvWZ0Ndpwy/vFvKIUZudc3uNF CcqGwr8wf3PvXjJJG2XMB7NzGnA1EsaCu4yLi6fc1xJPwIrdAjNN/SQY7+dHR1dXrypJ LUCuCEl43E16E5n0TLQNpLICWeq6v2Cgf5pPEyY3pmg1IUS1n4Qg2iWiD/jh3cFuVLlB IyIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mZNDb/6UoCOxaSMRv00L6iIHeM/60ujxNSXj0x+7/CE=; b=Lvq3JNzAKtyYdTWmmUpygxYR+0Uk+FJpLLGYhNHsUgEIkBfaBG/DtUyLDbV/bSx63C CME+ycqhd3c+FbQKcP4br04grn2JhYSRRSIkmtS9lDJ9XnfAVHPVQZdhd5JFjkZMYatk lZ4m7z8w26UqogBSA9HWGEEZ65Sb0+nKz1VhnKyYWN1DXLrIAVMIWCvoawpaamuKFO++ NI2AZONx/Bde04UI/kpeXYjbKOWxlu/cR3F2M5NXiKC6xIRKeavzgXVQoiAliCnGKdz5 zGdF+TgzUU8SUJfPLkHBdLXjIwt31FlYufnvy3MA4+ID2EbbX1UU/BE+BLCbrd5jOXh2 nK3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18-v6si1485543pge.645.2018.06.20.08.52.04; Wed, 20 Jun 2018 08:52:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754235AbeFTPvR (ORCPT + 99 others); Wed, 20 Jun 2018 11:51:17 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:52657 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754075AbeFTPvP (ORCPT ); Wed, 20 Jun 2018 11:51:15 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0LeQLR-1fzjCp1pjJ-00qE7t; Wed, 20 Jun 2018 17:51:06 +0200 From: Arnd Bergmann To: Yan Zheng , Sage Weil , Ilya Dryomov , "David S. Miller" Cc: y2038@lists.linaro.org, ceph-devel@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 1/5] ceph: use timespec64 in for keepalive Date: Wed, 20 Jun 2018 17:50:33 +0200 Message-Id: <20180620155101.57685-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:IXxtwoyfOjqEec1ci5QikIqlcOi6zuelAWWomp6rIIzSnGHZ8u8 TEt4h4BPXmaUyQv0S98yr1BELM0eUHPShq+7gXGyOw/MiLZdmMzK0wZzC/wJMq6H3mQnL/H KpYuweb64RS/o2yk5teKAcYQp69Hp15DjOVfTIFa73BRj+dNe+e4iIX+i5UlKwvvi4Nxe3c hU6Q5Mqom7JxoR59x0Sgg== X-UI-Out-Filterresults: notjunk:1;V01:K0:yX0lsX+IaPI=:KhBeJpbjvujwjthBFdEXB1 P1TLUHeONapMjJaT0CdFz7sZw0tR7d8Xf/gK/XFi5QZQzIgJ0lQwazY/gsx2Ko9Ipa6GSRu9t 2306vtpgBno5SdLofBcsFg3+PjKKmXlsMLMzZIzYQXUlldmCVtNOp/k1+r8X6c+o2szAyOAW6 FBwJrcumbqBbU1V5mFYB7KTtR90YKZodS8HdWZD9MeqxvUQ3+ZPhaPPxL+MOQsb2KdwnCIYq9 NjOAyP5Npv4BrXau68VGUVA66iHXUKrwoJhqUE4iP9MSUTuTuG1AOmxAXA497GAtFmCg3zOM+ aB3j1I+uQV7nXfhbEPRl4m36zjkccYcloZRyG8lhwJeq83SVS44n2+XQtTlAli4DClk0H0/CS yHQ/9LPHQDT6HRs9DL8hMJDEBqRiVmN2uNIY0Wct4TbJLDcZNQejQ0VAfG00/qYKHLJ6ap+hz GRX+jvkXvOBNO2QbBBmkbMSuLK+agGGO5FOOfKazDogy4F4WWTiFjBwKyQ67xx842M1evDcvH Q8pn4CpCsBO1nYpZPLIp3oyS1/0YhcLYeQHt08MeQJKwrWbWg6M+KE6rjTv2RusWP5J/nnnW/ RYm1sINs5VCjm+bbWy8ZeQnauKFhw+Kkh6ery0gd052GyCdEr7BIXaCtpivdMlILhwDQJUxWW gi/0/rg5RFPqC4YBuey7jk++o1gbSgEZBamBBlzPq+XkNoeDHHmNYuCmWYqai37UDmvQ= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ceph_con_keepalive_expired() is the last user of timespec_add() and some of the last uses of ktime_get_real_ts(). Replacing this with timespec64 based interfaces lets us remove that deprecated API. I'm introducing new ceph_encode_timespec64()/ceph_decode_timespec64() here that take timespec64 structures and convert to/from ceph_timespec, which is defined to have an unsigned 32-bit tv_sec member. This extends the range of valid times to year 2106, avoiding the year 2038 overflow. The ceph file system portion still uses the old functions for inode timestamps, this will be done separately after the VFS layer is converted. Signed-off-by: Arnd Bergmann --- include/linux/ceph/decode.h | 20 +++++++++++++++++++- include/linux/ceph/messenger.h | 2 +- net/ceph/auth_x.c | 14 +++++++------- net/ceph/auth_x.h | 2 +- net/ceph/cls_lock_client.c | 4 ++-- net/ceph/messenger.c | 20 ++++++++++---------- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h index d143ac8879c6..45efe09fb7b4 100644 --- a/include/linux/ceph/decode.h +++ b/include/linux/ceph/decode.h @@ -194,8 +194,26 @@ ceph_decode_skip_n(p, end, sizeof(u8), bad) } while (0) /* - * struct ceph_timespec <-> struct timespec + * struct ceph_timespec <-> struct timespec64 */ +static inline void ceph_decode_timespec64(struct timespec64 *ts, + const struct ceph_timespec *tv) +{ + /* + * this will still overflow in year 2106. We could extend + * the protocol to steal two more bits from tv_nsec to + * add three more 136 year epochs after that the way ext4 + * does if necessary. + */ + ts->tv_sec = (time64_t)le32_to_cpu(tv->tv_sec); + ts->tv_nsec = (long)le32_to_cpu(tv->tv_nsec); +} +static inline void ceph_encode_timespec64(struct ceph_timespec *tv, + const struct timespec64 *ts) +{ + tv->tv_sec = cpu_to_le32((u32)ts->tv_sec); + tv->tv_nsec = cpu_to_le32((u32)ts->tv_nsec); +} static inline void ceph_decode_timespec(struct timespec *ts, const struct ceph_timespec *tv) { diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h index c7dfcb8a1fb2..a718b877c597 100644 --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h @@ -330,7 +330,7 @@ struct ceph_connection { int in_base_pos; /* bytes read */ __le64 in_temp_ack; /* for reading an ack */ - struct timespec last_keepalive_ack; /* keepalive2 ack stamp */ + struct timespec64 last_keepalive_ack; /* keepalive2 ack stamp */ struct delayed_work work; /* send|recv work */ unsigned long delay; /* current delay interval */ diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c index 2f4a1baf5f52..b05c3a540a5a 100644 --- a/net/ceph/auth_x.c +++ b/net/ceph/auth_x.c @@ -149,12 +149,12 @@ static int process_one_ticket(struct ceph_auth_client *ac, void *dp, *dend; int dlen; char is_enc; - struct timespec validity; + struct timespec64 validity; void *tp, *tpend; void **ptp; struct ceph_crypto_key new_session_key = { 0 }; struct ceph_buffer *new_ticket_blob; - unsigned long new_expires, new_renew_after; + time64_t new_expires, new_renew_after; u64 new_secret_id; int ret; @@ -189,11 +189,11 @@ static int process_one_ticket(struct ceph_auth_client *ac, if (ret) goto out; - ceph_decode_timespec(&validity, dp); + ceph_decode_timespec64(&validity, dp); dp += sizeof(struct ceph_timespec); - new_expires = get_seconds() + validity.tv_sec; + new_expires = ktime_get_real_seconds() + validity.tv_sec; new_renew_after = new_expires - (validity.tv_sec / 4); - dout(" expires=%lu renew_after=%lu\n", new_expires, + dout(" expires=%llu renew_after=%llu\n", new_expires, new_renew_after); /* ticket blob for service */ @@ -385,13 +385,13 @@ static bool need_key(struct ceph_x_ticket_handler *th) if (!th->have_key) return true; - return get_seconds() >= th->renew_after; + return ktime_get_real_seconds() >= th->renew_after; } static bool have_key(struct ceph_x_ticket_handler *th) { if (th->have_key) { - if (get_seconds() >= th->expires) + if (ktime_get_real_seconds() >= th->expires) th->have_key = false; } diff --git a/net/ceph/auth_x.h b/net/ceph/auth_x.h index 454cb54568af..57ba99f7736f 100644 --- a/net/ceph/auth_x.h +++ b/net/ceph/auth_x.h @@ -22,7 +22,7 @@ struct ceph_x_ticket_handler { u64 secret_id; struct ceph_buffer *ticket_blob; - unsigned long renew_after, expires; + time64_t renew_after, expires; }; #define CEPHX_AU_ENC_BUF_LEN 128 /* big enough for encrypted blob */ diff --git a/net/ceph/cls_lock_client.c b/net/ceph/cls_lock_client.c index 8d2032b2f225..2105a6eaa66c 100644 --- a/net/ceph/cls_lock_client.c +++ b/net/ceph/cls_lock_client.c @@ -32,7 +32,7 @@ int ceph_cls_lock(struct ceph_osd_client *osdc, int desc_len = strlen(desc); void *p, *end; struct page *lock_op_page; - struct timespec mtime; + struct timespec64 mtime; int ret; lock_op_buf_size = name_len + sizeof(__le32) + @@ -63,7 +63,7 @@ int ceph_cls_lock(struct ceph_osd_client *osdc, ceph_encode_string(&p, end, desc, desc_len); /* only support infinite duration */ memset(&mtime, 0, sizeof(mtime)); - ceph_encode_timespec(p, &mtime); + ceph_encode_timespec64(p, &mtime); p += sizeof(struct ceph_timespec); ceph_encode_8(&p, flags); diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index c6413c360771..3f6336248509 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1417,11 +1417,11 @@ static void prepare_write_keepalive(struct ceph_connection *con) dout("prepare_write_keepalive %p\n", con); con_out_kvec_reset(con); if (con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2) { - struct timespec now; + struct timespec64 now; - ktime_get_real_ts(&now); + ktime_get_real_ts64(&now); con_out_kvec_add(con, sizeof(tag_keepalive2), &tag_keepalive2); - ceph_encode_timespec(&con->out_temp_keepalive2, &now); + ceph_encode_timespec64(&con->out_temp_keepalive2, &now); con_out_kvec_add(con, sizeof(con->out_temp_keepalive2), &con->out_temp_keepalive2); } else { @@ -2555,7 +2555,7 @@ static int read_keepalive_ack(struct ceph_connection *con) int ret = read_partial(con, size, size, &ceph_ts); if (ret <= 0) return ret; - ceph_decode_timespec(&con->last_keepalive_ack, &ceph_ts); + ceph_decode_timespec64(&con->last_keepalive_ack, &ceph_ts); prepare_read_tag(con); return 1; } @@ -3223,12 +3223,12 @@ bool ceph_con_keepalive_expired(struct ceph_connection *con, { if (interval > 0 && (con->peer_features & CEPH_FEATURE_MSGR_KEEPALIVE2)) { - struct timespec now; - struct timespec ts; - ktime_get_real_ts(&now); - jiffies_to_timespec(interval, &ts); - ts = timespec_add(con->last_keepalive_ack, ts); - return timespec_compare(&now, &ts) >= 0; + struct timespec64 now; + struct timespec64 ts; + ktime_get_real_ts64(&now); + jiffies_to_timespec64(interval, &ts); + ts = timespec64_add(con->last_keepalive_ack, ts); + return timespec64_compare(&now, &ts) >= 0; } return false; } -- 2.9.0