From patchwork Sat Aug 13 22:48:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 9279201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 26FD760231 for ; Sun, 14 Aug 2016 11:36:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 171D5289B7 for ; Sun, 14 Aug 2016 11:36:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B51D28A21; Sun, 14 Aug 2016 11:36:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93F88289B7 for ; Sun, 14 Aug 2016 11:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964811AbcHNLgI (ORCPT ); Sun, 14 Aug 2016 07:36:08 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:33372 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965745AbcHNLgG (ORCPT ); Sun, 14 Aug 2016 07:36:06 -0400 Received: by mail-pa0-f66.google.com with SMTP id vy10so2075911pac.0; Sun, 14 Aug 2016 04:36:06 -0700 (PDT) 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=vwOsDqq2I6SqPunwxaJpLUpGKUM5qCsI8na4HsW5qaE=; b=PRbfNBANnak0Q0bYOhs1JrvpYJGWCGmk81ZS4J3Y7TRgV64j8DeGt9vqruvnAFT6p1 LvnnPd+otwABrgLbUnL59gawqPrAWlR692duFU9RLHvlIiWdciqsk1KYuniVHiNT2Kz5 FAkqi8DpbxEaQjH4mXNGhBJU73EYqaWfppFlZ399P5+rm7Of+6CQUY1PW2b25olzApFs 3lVqXY9kyN1VAtbwSI6Mqdjxz6KB7e5A5cKoav07wH14b9nw3VrsJGiQSBSnBFNwxVFY ikb/BTUzOrWGuPcmwkX8gTgbpMmFGqvIqx68ZiB8k/LwNVRq5rVzqHIwqfnHar6F1S4r DqUw== 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=vwOsDqq2I6SqPunwxaJpLUpGKUM5qCsI8na4HsW5qaE=; b=EgXlppUgVA/vjQv408uvfgcFMSTlD9TdYiSVYYtt2u2P5pgwnWzq5JFMnMMK8dRobm uSG/WdMuZpnz4W42ND6vMUB1WNtUY6Qzct2PAIG09CZYMwd2cxBBcVFDvuSkzCiTbmua NQNTroAU9+IR9DMlzUUiTU0fbsr5WqcEFMaFzsqvWOwuYeRRKvHuDFXv6ckMToghYjzM ISVBtTvf8kTcYHn6GId6ulxmSH5af5d0N+48TvE9YlRLMN2sV4f7k7xqEP1N9DQWgGVD 6x7U2/+YJz5Tx3A7tyKqVldNTz7OOA+6rzaU1Nrn89nws07UiBOzpLgXGHycwHWcvhLe r1Hw== X-Gm-Message-State: AEkooutgRPy7gDZ5HKDbDLEZ0nH6VftkABF2hlRlDshjTo9cOOS9AHyKGacb4l0664Zi9A== X-Received: by 10.66.228.135 with SMTP id si7mr39994722pac.124.1471128570263; Sat, 13 Aug 2016 15:49:30 -0700 (PDT) Received: from deepa-ubuntu.hsd1.ca.comcast.net (c-73-252-251-201.hsd1.ca.comcast.net. [73.252.251.201]) by smtp.gmail.com with ESMTPSA id 81sm22528007pfm.90.2016.08.13.15.49.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Aug 2016 15:49:29 -0700 (PDT) From: Deepa Dinamani To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, tglx@linutronix.de, torvalds@linux-foundation.org, tytso@mit.edu, viro@zeniv.linux.org.uk, y2038@lists.linaro.org, Steve French Subject: [PATCH v4 12/26] fs: cifs: Replace CURRENT_TIME by current_time() Date: Sat, 13 Aug 2016 15:48:24 -0700 Message-Id: <1471128518-24075-13-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471128518-24075-1-git-send-email-deepa.kernel@gmail.com> References: <1471128518-24075-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-Virus-Scanned: ClamAV using ClamSMTP CURRENT_TIME macro is not appropriate for filesystems as it doesn't use the right granularity for filesystem timestamps. Use current_time() instead. This is also in preparation for the patch that transitions vfs timestamps to use 64 bit time and hence make them y2038 safe. CURRENT_TIME macro will be deleted before merging the aforementioned change. Change signature of helper cifs_all_info_to_fattr since it now needs both super_block and cifs_sb_info. Note: The inode timestamps read from the server are assumed to have correct granularity and range. Signed-off-by: Deepa Dinamani Reviewed-by: Arnd Bergmann Cc: Steve French --- fs/cifs/inode.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index b87efd0..7df6e50 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -320,9 +320,9 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb) fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU; fattr->cf_uid = cifs_sb->mnt_uid; fattr->cf_gid = cifs_sb->mnt_gid; - fattr->cf_atime = CURRENT_TIME; - fattr->cf_ctime = CURRENT_TIME; - fattr->cf_mtime = CURRENT_TIME; + ktime_get_real_ts(&fattr->cf_mtime); + fattr->cf_mtime = timespec_trunc(fattr->cf_mtime, sb->s_time_gran); + fattr->cf_atime = fattr->cf_ctime = fattr->cf_mtime; fattr->cf_nlink = 2; fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL; } @@ -584,9 +584,10 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path, /* Fill a cifs_fattr struct with info from FILE_ALL_INFO */ static void cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, - struct cifs_sb_info *cifs_sb, bool adjust_tz, + struct super_block *sb, bool adjust_tz, bool symlink) { + struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); memset(fattr, 0, sizeof(*fattr)); @@ -596,8 +597,10 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, if (info->LastAccessTime) fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); - else - fattr->cf_atime = CURRENT_TIME; + else { + ktime_get_real_ts(&fattr->cf_atime); + fattr->cf_atime = timespec_trunc(fattr->cf_atime, sb->s_time_gran); + } fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime); fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); @@ -657,7 +660,6 @@ cifs_get_file_info(struct file *filp) FILE_ALL_INFO find_data; struct cifs_fattr fattr; struct inode *inode = file_inode(filp); - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifsFileInfo *cfile = filp->private_data; struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); struct TCP_Server_Info *server = tcon->ses->server; @@ -669,7 +671,7 @@ cifs_get_file_info(struct file *filp) rc = server->ops->query_file_info(xid, tcon, &cfile->fid, &find_data); switch (rc) { case 0: - cifs_all_info_to_fattr(&fattr, &find_data, cifs_sb, false, + cifs_all_info_to_fattr(&fattr, &find_data, inode->i_sb, false, false); break; case -EREMOTE: @@ -751,7 +753,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, } if (!rc) { - cifs_all_info_to_fattr(&fattr, data, cifs_sb, adjust_tz, + cifs_all_info_to_fattr(&fattr, data, sb, adjust_tz, symlink); } else if (rc == -EREMOTE) { cifs_create_dfs_fattr(&fattr, sb); @@ -1361,9 +1363,9 @@ out_reval: cifs_inode = CIFS_I(inode); cifs_inode->time = 0; /* will force revalidate to get info when needed */ - inode->i_ctime = current_fs_time(sb); + inode->i_ctime = current_time(inode); } - dir->i_ctime = dir->i_mtime = current_fs_time(sb); + dir->i_ctime = dir->i_mtime = current_time(dir); cifs_inode = CIFS_I(dir); CIFS_I(dir)->time = 0; /* force revalidate of dir as well */ unlink_out: @@ -1631,7 +1633,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry) cifsInode->time = 0; d_inode(direntry)->i_ctime = inode->i_ctime = inode->i_mtime = - current_fs_time(inode->i_sb); + current_time(inode); rmdir_exit: kfree(full_path); @@ -1804,7 +1806,7 @@ unlink_target: CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0; source_dir->i_ctime = source_dir->i_mtime = target_dir->i_ctime = - target_dir->i_mtime = current_fs_time(source_dir->i_sb); + target_dir->i_mtime = current_time(source_dir); cifs_rename_exit: kfree(info_buf_source);