From patchwork Mon Feb 22 15:17:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 8378871 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 77B2E9F314 for ; Mon, 22 Feb 2016 15:24:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 628342041F for ; Mon, 22 Feb 2016 15:24:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AE582037C for ; Mon, 22 Feb 2016 15:24:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753837AbcBVPXx (ORCPT ); Mon, 22 Feb 2016 10:23:53 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33394 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753831AbcBVPXv (ORCPT ); Mon, 22 Feb 2016 10:23:51 -0500 Received: by mail-pa0-f41.google.com with SMTP id fl4so92784012pad.0; Mon, 22 Feb 2016 07:23:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xD5PjbjQBRMLwgenRpl0b25vMBTF43dfIFEDoRD3hQ8=; b=rf0iLxt/DEhgaC6vWWzMt2I0ylf7JIfbjahphhm79uW3vMrE/zH3yBxd0MLdquQ7Fw 5yiSnbHzHygcy+sjRPzFvoUXaIc13e6gulDudo5hAFSVLMZ8YGXU1+fdd4af8a8ZxEHh scLwSWQX7EtrYXarCYpEI/UYhZYdbyuYdFvjjNBK3O+30hVNujxhMHPpQX9KVZxuC4X7 TA0EsuwuBFgmmDudnsE01VWYJ3yaOoLul4s+I/eZMd1aw5Obhw302BKpbEAkX/n96SdX cVTlYtla/3r753xf5I2BrGgi6mj/B1w4zd9Ej96zvdJZJx0mFhetlLtFqo7Py6V5a1So pVeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xD5PjbjQBRMLwgenRpl0b25vMBTF43dfIFEDoRD3hQ8=; b=lD4BLvzmtnH9QUGYPNwfeCMtcVSkhppEu5OGCnerC/VktzRQQnnd4cl3WuJX9CNF/R cRW904a9sINex4zg2A/N0D6nndi/IMIHUN5cob9eeh/HHXu4EGLqbBv9oFyQ75v7kvDe R9WtilcWm/J4PIqoQFzq32QB4UJcnuRgtzQEFNfKb1dkpkuOmkF78QPodcdZ00j3bl4T JZj8CdZWNqDHgqKyv2hz5+pa2mXBiGIQaO4XpEQIg7HK6lyFqqDtPFO979N5YL+3Yq+9 iHpkzgsHjwbFoAUn0ML22Hkvp5e4sicB7VSRyaW4DB2dqe6sC/FE5gBboEE5hU2tvEI9 RVyg== X-Gm-Message-State: AG10YOTHIDXRjoVaJ9IAqYjgGgwDz2bfsXqfPyDBQSoHFt8HF6hsACE8J9CzKW3Z2jkxaQ== X-Received: by 10.66.220.162 with SMTP id px2mr38880132pac.15.1456154630845; Mon, 22 Feb 2016 07:23:50 -0800 (PST) Received: from localhost.localdomain ([106.51.225.115]) by smtp.gmail.com with ESMTPSA id z3sm37888603par.17.2016.02.22.07.23.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 07:23:50 -0800 (PST) From: Deepa Dinamani To: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH 7/8] fs: kernfs: Replace CURRENT_TIME by current_fs_time() Date: Mon, 22 Feb 2016 07:17:53 -0800 Message-Id: <1456154274-30487-8-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456154274-30487-1-git-send-email-deepa.kernel@gmail.com> References: <1456154274-30487-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=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 This is in preparation for the series that transitions filesystem timestamps to use 64 bit time and hence make them y2038 safe. CURRENT_TIME macro will be deleted before merging the aforementioned series. Use current_fs_time() instead of CURRENT_TIME for inode timestamps. struct kernfs_node is associated with a sysfs file/ directory. Truncate the values to appropriate time granularity when writing to inode timestamps of the files. ktime_get_real_ts() is used to obtain times for struct kernfs_iattrs. Since these times are later assigned to inode times using timespec_truncate() for all filesystem based operations, we can save the supers list traversal time here by using ktime_get_real_ts() directly. Signed-off-by: Deepa Dinamani Cc: Greg Kroah-Hartman --- fs/kernfs/dir.c | 8 +++++--- fs/kernfs/inode.c | 15 ++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 118d033..939bd11 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -624,7 +624,8 @@ int kernfs_add_one(struct kernfs_node *kn) ps_iattr = parent->iattr; if (ps_iattr) { struct iattr *ps_iattrs = &ps_iattr->ia_iattr; - ps_iattrs->ia_ctime = ps_iattrs->ia_mtime = CURRENT_TIME; + ktime_get_real_ts(&ps_iattrs->ia_ctime); + ps_iattrs->ia_mtime = ps_iattrs->ia_ctime; } mutex_unlock(&kernfs_mutex); @@ -1150,8 +1151,9 @@ static void __kernfs_remove(struct kernfs_node *kn) /* update timestamps on the parent */ if (ps_iattr) { - ps_iattr->ia_iattr.ia_ctime = CURRENT_TIME; - ps_iattr->ia_iattr.ia_mtime = CURRENT_TIME; + ktime_get_real_ts(&ps_iattr->ia_iattr.ia_ctime); + ps_iattr->ia_iattr.ia_mtime = + ps_iattr->ia_iattr.ia_ctime; } kernfs_put(pos); diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c index 16405ae..1ac1dba 100644 --- a/fs/kernfs/inode.c +++ b/fs/kernfs/inode.c @@ -54,7 +54,10 @@ static struct kernfs_iattrs *kernfs_iattrs(struct kernfs_node *kn) iattrs->ia_mode = kn->mode; iattrs->ia_uid = GLOBAL_ROOT_UID; iattrs->ia_gid = GLOBAL_ROOT_GID; - iattrs->ia_atime = iattrs->ia_mtime = iattrs->ia_ctime = CURRENT_TIME; + + ktime_get_real_ts(&iattrs->ia_atime); + iattrs->ia_mtime = iattrs->ia_atime; + iattrs->ia_ctime = iattrs->ia_atime; simple_xattrs_init(&kn->iattr->xattrs); out_unlock: @@ -236,16 +239,18 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size) static inline void set_default_inode_attr(struct inode *inode, umode_t mode) { inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_atime = inode->i_mtime = + inode->i_ctime = current_fs_time(inode->i_sb); } static inline void set_inode_attr(struct inode *inode, struct iattr *iattr) { + struct super_block *sb = inode->i_sb; inode->i_uid = iattr->ia_uid; inode->i_gid = iattr->ia_gid; - inode->i_atime = iattr->ia_atime; - inode->i_mtime = iattr->ia_mtime; - inode->i_ctime = iattr->ia_ctime; + inode->i_atime = timespec_trunc(iattr->ia_atime, sb->s_time_gran); + inode->i_mtime = timespec_trunc(iattr->ia_mtime, sb->s_time_gran); + inode->i_ctime = timespec_trunc(iattr->ia_ctime, sb->s_time_gran); } static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)