From patchwork Thu Jan 7 05:36:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 7973491 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2D8F59F1CC for ; Thu, 7 Jan 2016 05:38:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39E0920149 for ; Thu, 7 Jan 2016 05:38:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 265572012D for ; Thu, 7 Jan 2016 05:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752770AbcAGFhK (ORCPT ); Thu, 7 Jan 2016 00:37:10 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33900 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752747AbcAGFhG (ORCPT ); Thu, 7 Jan 2016 00:37:06 -0500 Received: by mail-pa0-f50.google.com with SMTP id uo6so231281451pac.1; Wed, 06 Jan 2016 21:37:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=qJOujY5iiYnQxO/h4Xoe9erBgmlBzKAKm9Q4cXNZH98=; b=cotxEozHzqMfm4sF3f6Izl+Sq7ybwCXKHv1Dtc2ketXYuzOCN6idRB0qwY0iCWihhO fsc3X8SV2SHjt9GdaZIPK2Nd3J1BUXXeBQy7zuYPNgRVJJJVdhAPLKLO+ZelXZFq0o32 RbP1mr/tRCrr9Hs1/D9EAO0Jp1qQeyc0YJU8Vl5TizHcSXQfaE5vQEBEYgwamwnACCwI /DOoKK50XId84hZQBKfDuRNFFNLcJWxUPOGY9LavuZNWAJRhZGwf19RXlcbnvsgKl3xv Zg/T6eHcvxv7yk536W5UsLYDdWlnxIkCUfG6gK3BK4Uwhhotz7bA8dQeXVOkl8btnWI7 geeA== X-Received: by 10.66.124.232 with SMTP id ml8mr10926648pab.98.1452145025676; Wed, 06 Jan 2016 21:37:05 -0800 (PST) Received: from localhost.localdomain ([106.51.24.71]) by smtp.gmail.com with ESMTPSA id kk5sm131390736pab.16.2016.01.06.21.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jan 2016 21:37:05 -0800 (PST) From: Deepa Dinamani To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org Subject: [RFC 13/15] kernel: time: change inode_timespec to timespec64 Date: Wed, 6 Jan 2016 21:36:10 -0800 Message-Id: <1452144972-15802-14-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452144972-15802-1-git-send-email-deepa.kernel@gmail.com> References: <1452144972-15802-1-git-send-email-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Substitute inode_timespec aliases with timespec64. Since CONFIG_FS_USES_64BIT_TIME is enabled, internally all inode_timespec references are using timespec64 already. Signed-off-by: Deepa Dinamani Conflicts: kernel/time/time.c Conflicts: kernel/time/time.c --- kernel/time/time.c | 130 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 54 deletions(-) diff --git a/kernel/time/time.c b/kernel/time/time.c index 24ca258..87d9a4c 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -230,6 +230,76 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p) return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret; } +<<<<<<< HEAD +======= +/** + * current_fs_time - Return FS time + * @sb: Superblock. + * + * Return the current time truncated to the time granularity supported by + * the fs. + */ +struct timespec64 current_fs_time(struct super_block *sb) +{ + struct timespec64 now = current_kernel_time64(); + + return fs_time_trunc(now, sb); +} +EXPORT_SYMBOL(current_fs_time); + +struct timespec64 current_fs_time_sec(struct super_block *sb) +{ + struct timespec64 ts = {ktime_get_real_seconds(), 0}; + + /* range check for time. */ + fs_time_range_check(sb, &ts); + + return ts; +} +EXPORT_SYMBOL(current_fs_time_sec); + +/* + * Convert jiffies to milliseconds and back. + * + * Avoid unnecessary multiplications/divisions in the + * two most common HZ cases: + */ +unsigned int jiffies_to_msecs(const unsigned long j) +{ +#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) + return (MSEC_PER_SEC / HZ) * j; +#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) + return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); +#else +# if BITS_PER_LONG == 32 + return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32; +# else + return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN; +# endif +#endif +} +EXPORT_SYMBOL(jiffies_to_msecs); + +unsigned int jiffies_to_usecs(const unsigned long j) +{ + /* + * Hz usually doesn't go much further MSEC_PER_SEC. + * jiffies_to_usecs() and usecs_to_jiffies() depend on that. + */ + BUILD_BUG_ON(HZ > USEC_PER_SEC); + +#if !(USEC_PER_SEC % HZ) + return (USEC_PER_SEC / HZ) * j; +#else +# if BITS_PER_LONG == 32 + return (HZ_TO_USEC_MUL32 * j) >> HZ_TO_USEC_SHR32; +# else + return (j * HZ_TO_USEC_NUM) / HZ_TO_USEC_DEN; +# endif +#endif +} +EXPORT_SYMBOL(jiffies_to_usecs); + /* fs_time_range_check: * Function to check if a given timestamp is in the range allowed for a * filesystem. @@ -240,7 +310,7 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p) * nsec is set to 0 if not in allowed range. */ static void -fs_time_range_check(struct super_block *sb, struct inode_timespec *ts) +fs_time_range_check(struct super_block *sb, struct timespec64 *ts) { if (unlikely(sb->s_time_max < ts->tv_sec || sb->s_time_min > ts->tv_sec)) { @@ -257,7 +327,7 @@ fs_time_range_check(struct super_block *sb, struct inode_timespec *ts) * fs_time_range_check. * returns 0 otherwise. */ -int is_fs_timestamp_bad(struct inode_timespec ts) +int is_fs_timestamp_bad(struct timespec64 ts) { if (ts.tv_nsec == FS_TIMESTAMP_NSEC_NOT_VALID) return -1; @@ -267,16 +337,16 @@ int is_fs_timestamp_bad(struct inode_timespec ts) EXPORT_SYMBOL(is_fs_timestamp_bad); /* - * fs_time_trunc - Truncate inode_timespec to a granularity - * @t: inode_timespec + * fs_time_trunc - Truncate timespec64 to a granularity + * @t: timespec64 * @sb: Super block. * * Truncate a timespec to a granularity. Always rounds down. Granularity * must * not be 0 nor greater than a second (NSEC_PER_SEC, or 10^9 ns). * Returns 1 on error, 0 otherwise. */ -struct inode_timespec -fs_time_trunc(struct inode_timespec t, struct super_block *sb) +struct timespec64 +fs_time_trunc(struct timespec64 t, struct super_block *sb) { u32 gran = sb->s_time_gran; @@ -300,34 +370,6 @@ fs_time_trunc(struct inode_timespec t, struct super_block *sb) EXPORT_SYMBOL(fs_time_trunc); /** - * timespec_trunc - Truncate timespec to a granularity - * @t: Timespec - * @gran: Granularity in ns. - * - * Truncate a timespec to a granularity. Always rounds down. gran must - * not be 0 nor greater than a second (NSEC_PER_SEC, or 10^9 ns). - * - * This function is deprecated and should no longer be used for filesystems. - * fs_time_trunc should be used instead. - */ -struct timespec timespec_trunc(struct timespec t, unsigned gran) -{ - - /* Avoid division in the common cases 1 ns and 1 s. */ - if (gran == 1) { - /* nothing */ - } else if (gran == NSEC_PER_SEC) { - t.tv_nsec = 0; - } else if (gran > 1 && gran < NSEC_PER_SEC) { - t.tv_nsec -= t.tv_nsec % gran; - } else { - WARN(1, "illegal file time granularity: %u", gran); - } - return t; -} -EXPORT_SYMBOL(timespec_trunc); - -/** * current_fs_time - Return FS time * @sb: Superblock. * @@ -353,26 +395,6 @@ struct timespec64 current_fs_time_sec(struct super_block *sb) return ts; } EXPORT_SYMBOL(current_fs_time_sec); -#else -struct timespec current_fs_time(struct super_block *sb) -{ - struct timespec now = current_kernel_time(); - - return fs_time_trunc(now, sb); -} -EXPORT_SYMBOL(current_fs_time); - -struct timespec current_fs_time_sec(struct super_block *sb) -{ - struct timespec ts = { get_seconds(), 0 }; - - /* range check for time. */ - fs_time_range_check(sb, &ts); - - return ts; -} -EXPORT_SYMBOL(current_fs_time_sec); -#endif /* * Convert jiffies to milliseconds and back.