From patchwork Tue Dec 3 05:19:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11270517 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C29B4139A for ; Tue, 3 Dec 2019 05:20:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0518207DD for ; Tue, 3 Dec 2019 05:20:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bTGnRtqz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbfLCFUK (ORCPT ); Tue, 3 Dec 2019 00:20:10 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:45560 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbfLCFUK (ORCPT ); Tue, 3 Dec 2019 00:20:10 -0500 Received: by mail-pj1-f65.google.com with SMTP id r11so1009306pjp.12; Mon, 02 Dec 2019 21:20:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lm28kIqQgsof6QYEq9ODpPVkMAPFDe+UtXuv02kmoQo=; b=bTGnRtqzuSSyN0ILyisTMm70f092tROs471IMDfXRZJSETR5NGutvOJIR21JwSskj3 Vcscla9/oYopY1R3iCjxR7pxlH5NCTktVZEaZEvMFIYBGOHw+fr+aNU7aPYer6zMmiI8 P8IyMwdeMRFOB6WVs3FlzD7GpdZ8W6yeENgA0UTlM5liBz3J9Gx7O8Igeaf75dNiSltM pMaFP+2scVZa+Gn1xImvyWntdY3Rj7NJ3hoNDAeywDr4JChhcT44XNHHTfGUcJCV4+ck WPNMfJz+q5oNEgQHsZqRdaW1LRvnDBuePmEIioQIXTAGhLEZxmvAyRP8wa78oPNUaQqt y8Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lm28kIqQgsof6QYEq9ODpPVkMAPFDe+UtXuv02kmoQo=; b=ILJg++ER35TpyBEQcrRqcz616oZqmj3A7AuK61m336L1vMmYnAZ7aGHwVzCRlImGRr KDF039gVeI6VAWPF2sxR242VINIfqcixtE0FYN/7FjHbFJj1hXLmQYNlsiLqUoqjdGnu ZWM/mbaeP92ED50nUEaC5wlXQ1N4Osn+j+t83uIOliEsMAqftfWwQU/Oe/VWpXy7fuAb xrf5CjvSjsHILyJ5YJs87mxJPqmYIs9rUAJw++mtwW/csjzacSRwV6uHmnVk4JpH9F/I qU54gZ4tf6TUeGeGNf1O+eSqjpprw33zkiPB2VQ0zuVBpYA5bS6oJDewIa1UtPLI6Je8 q/Yg== X-Gm-Message-State: APjAAAXZ2AL2032svPOAhS9gYzcMWdirXXPUDT23Ut/5tFbln9mWLlMd k6JPpQ8WJP7PgAPGYzXw5JGXTUh+ X-Google-Smtp-Source: APXvYqxkiGhrOqHplGU/yi/toEvuCwb9wti9pi8U7pb6IT8DmC1ylbpwhzfqZMrP/lg4eUF/FB7pcA== X-Received: by 2002:a17:902:d915:: with SMTP id c21mr3124474plz.177.1575350409312; Mon, 02 Dec 2019 21:20:09 -0800 (PST) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id h9sm1451915pgk.84.2019.12.02.21.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 21:20:08 -0800 (PST) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de, hirofumi@mail.parknet.co.jp Subject: [PATCH v2 1/6] fs: fat: Eliminate timespec64_trunc() usage Date: Mon, 2 Dec 2019 21:19:40 -0800 Message-Id: <20191203051945.9440-2-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203051945.9440-1-deepa.kernel@gmail.com> References: <20191203051945.9440-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org timespec64_trunc() is being deleted. timestamp_truncate() is the replacement api for timespec64_trunc. timestamp_truncate() additionally clamps timestamps to make sure the timestamps lie within the permitted range for the filesystem. But, fat always truncates the times locally after it obtains the timestamps from current_time(). Implement a local version here along the lines of existing truncate functions. Suggested-by: Al Viro Signed-off-by: Deepa Dinamani Cc: hirofumi@mail.parknet.co.jp --- fs/fat/misc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/fat/misc.c b/fs/fat/misc.c index 1e08bd54c5fb..f1b2a1fc2a6a 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c @@ -271,6 +271,14 @@ static inline struct timespec64 fat_timespec64_trunc_2secs(struct timespec64 ts) { return (struct timespec64){ ts.tv_sec & ~1ULL, 0 }; } + +static inline struct timespec64 fat_timespec64_trunc_10ms(struct timespec64 ts) +{ + if (ts.tv_nsec) + ts.tv_nsec -= ts.tv_nsec % 10000000UL; + return ts; +} + /* * truncate the various times with appropriate granularity: * root inode: @@ -308,7 +316,7 @@ int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags) } if (flags & S_CTIME) { if (sbi->options.isvfat) - inode->i_ctime = timespec64_trunc(*now, 10000000); + inode->i_ctime = fat_timespec64_trunc_10ms(*now); else inode->i_ctime = fat_timespec64_trunc_2secs(*now); } From patchwork Tue Dec 3 05:19:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11270503 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 970DD184E for ; Tue, 3 Dec 2019 05:20:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BAAD20803 for ; Tue, 3 Dec 2019 05:20:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tFIXbngR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbfLCFUM (ORCPT ); Tue, 3 Dec 2019 00:20:12 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39529 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbfLCFUM (ORCPT ); Tue, 3 Dec 2019 00:20:12 -0500 Received: by mail-pl1-f193.google.com with SMTP id o9so1206938plk.6; Mon, 02 Dec 2019 21:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CmhQS/RvxHM1ZkF3nWKmxpQ+xBfLTIt05/c08FcGCIs=; b=tFIXbngRA4bGs0uS8LLLRx+A3m9DXCcFsNIgWW2kxkRU54hEbCfsAvgc/imoM22i5s lV87TdnsLHtXV0Zr5JeLF3A4+pXWRkHO3ZMtH8AzJWLSy4pH2jO5p/hB7ML+5bkylb3p tH87QBhRzlc4si01TiIqKov2fmZ4RbPHfu8M556gOBHMqjutm5SWQBcM4jT8pdbPNSs4 SGSFWgks/LU+qsIAZZp12qHRq8Jj7zUPji6w9Pz3RMfo3SGIALpwicZ5972AnkKWLkwb 56uisz8CWXbcuYmR4IHfs9xJ+1pwLaGFDQAPKKwmJAPDiBnRMRRRHso4CtBys8sSsWbq rGUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CmhQS/RvxHM1ZkF3nWKmxpQ+xBfLTIt05/c08FcGCIs=; b=IttnAAQHOMIGMUOFwfKfOzdFjh01sP9FWiGKvIdaT8evMJxK/+O5Gwwtm5EqkE+IXZ JBUQfJhwqVALjV465OD0MYwgI5uzK8LAUs3C1lW+IHVTMo+LgwhGxgSfhocc9pmj8eyE Aq8SLSvpwB3mSbG8Ea1RauHutpnxAEyPOKxCHFizbBDTmoGNZ/qgflNO5ojPjQROiMjv K8mrHwVAQzO3LNmCDFOxgPzSdybC+eRcCGd9FamxuL5NQND440TI3QnpP3Pc7jgEGNUD ESlTh9r8XFCQIGKs9/fXOqylbOcf0MszYAiUZExTaAChCiG8+T9mXwgOEFnmcVeWx8q9 FU0Q== X-Gm-Message-State: APjAAAV452GRGTHIwRi8+SAUCErZPDLxuoPd2GfvGAaqeUgjvE1zOLov nOK4LHExzgF6wlDyT5vbiKk= X-Google-Smtp-Source: APXvYqwgeQm9CquMiw2X8iXh0kvR4EbK2Pkb/9nW8nXpFjl2hMrC3Icouk50DpciJNUXFFPtA+ze9g== X-Received: by 2002:a17:90a:9bc6:: with SMTP id b6mr3527181pjw.77.1575350411171; Mon, 02 Dec 2019 21:20:11 -0800 (PST) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id h9sm1451915pgk.84.2019.12.02.21.20.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 21:20:10 -0800 (PST) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de, stfrench@microsoft.com, linux-cifs@vger.kernel.org Subject: [PATCH v2 2/6] fs: cifs: Delete usage of timespec64_trunc Date: Mon, 2 Dec 2019 21:19:41 -0800 Message-Id: <20191203051945.9440-3-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203051945.9440-1-deepa.kernel@gmail.com> References: <20191203051945.9440-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org timestamp_truncate() is the replacement api for timespec64_trunc. timestamp_truncate() additionally clamps timestamps to make sure the timestamps lie within the permitted range for the filesystem. Truncate the timestamps in the struct cifs_attr at the site of assignment to inode times. This helps us use the right fs api timestamp_trucate() to perform the truncation. Also update the ktime_get_* api to match the one used in current_time(). This allows for timestamps to be updated the same way always. Signed-off-by: Deepa Dinamani Cc: stfrench@microsoft.com Cc: linux-cifs@vger.kernel.org --- fs/cifs/inode.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index ca76a9287456..026ed49e8aa4 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -113,6 +113,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) } /* revalidate if mtime or size have changed */ + fattr->cf_mtime = timestamp_truncate(fattr->cf_mtime, inode); if (timespec64_equal(&inode->i_mtime, &fattr->cf_mtime) && cifs_i->server_eof == fattr->cf_eof) { cifs_dbg(FYI, "%s: inode %llu is unchanged\n", @@ -162,6 +163,9 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr) cifs_revalidate_cache(inode, fattr); spin_lock(&inode->i_lock); + fattr->cf_mtime = timestamp_truncate(fattr->cf_mtime, inode); + fattr->cf_atime = timestamp_truncate(fattr->cf_atime, inode); + fattr->cf_ctime = timestamp_truncate(fattr->cf_ctime, inode); /* we do not want atime to be less than mtime, it broke some apps */ if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime) < 0) inode->i_atime = fattr->cf_mtime; @@ -329,8 +333,7 @@ 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; - ktime_get_real_ts64(&fattr->cf_mtime); - fattr->cf_mtime = timespec64_trunc(fattr->cf_mtime, sb->s_time_gran); + ktime_get_coarse_real_ts64(&fattr->cf_mtime); fattr->cf_atime = fattr->cf_ctime = fattr->cf_mtime; fattr->cf_nlink = 2; fattr->cf_flags = CIFS_FATTR_DFS_REFERRAL; @@ -609,10 +612,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, if (info->LastAccessTime) fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); - else { - ktime_get_real_ts64(&fattr->cf_atime); - fattr->cf_atime = timespec64_trunc(fattr->cf_atime, sb->s_time_gran); - } + else + ktime_get_coarse_real_ts64(&fattr->cf_atime); fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime); fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); From patchwork Tue Dec 3 05:19:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11270513 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90C1E138C for ; Tue, 3 Dec 2019 05:20:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6CADB2080F for ; Tue, 3 Dec 2019 05:20:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dwv7oCgy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727009AbfLCFUO (ORCPT ); Tue, 3 Dec 2019 00:20:14 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:34988 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727007AbfLCFUN (ORCPT ); Tue, 3 Dec 2019 00:20:13 -0500 Received: by mail-pl1-f196.google.com with SMTP id s10so1215187plp.2; Mon, 02 Dec 2019 21:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uY2QG58kzGEqaCGR7UmQKvscEap1XpvW7KPcaFFGZH0=; b=Dwv7oCgyLvufvYLeLRzMwe6yJWXvwTZcsL4hY36GtT6tUoG+/ujy697/eU9HOVoVeD 61kUnWfMnw7InOz5Zx+IyK06HBrzit+48tCEBba3bnstghTMM9BteNOU2CostXaY5GB+ OHgQJ9Yayd96Vj1r8Xic4WDPeQgfxVAopDZIzhAYkCcyAf2A5ZMRWnE23CdHsV2aYsV8 S9ZrVro0inM5m8RIkdpmz7FpcwAAtMdXoKVR30kQ8o57N3N5uCg1IwTfyWUtlhdWD08p P+VhLoJ+X3adQP86EiasnJ+zwhKSLVh/3Hyz0Q25jZzqycSzZYx2BJ1kQ1L5NMjqwQQj MUQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uY2QG58kzGEqaCGR7UmQKvscEap1XpvW7KPcaFFGZH0=; b=VeW8C8i6kG0rTm8MAiyWJKTITzei1PlfKz/zqy2GMi5i5LIlYgqHeiZQzqoH40GYtD y027rKoKLEEOF+WZofXcaRn4BJdsGt8YleoMoTj8HH8ppcekTPM8gINZpE+q/WDJkuPn cFBviotIJcezvn0z3W0Etq5zcG98LC14iK3qwDN9kmHAufk8sf8kMtvEYO05V/PhoBHH IEabXvaQF0ir/leuN4o2JQmWqmgxGD5p66NxdyPXZi3MAB9HY2SY+/2KUu7UTb9OBbxI 9UdNCjW4Tzorbl/6Itm76b1udpjzeB4Sap1PPh/MBBv+3QN7ZBUDDIOyDMBPnr2r9mSe YZDA== X-Gm-Message-State: APjAAAU+P7LgnsuQsWvkBB6hjp6vLpP00ZrvaLxp0pv1XVsiTTRShNNu KXLEB57+zPKaVvd1Hwx30IslQuJR X-Google-Smtp-Source: APXvYqzDgx8INoeZxdQp1PJtJjENI+ChJSa1vX6DYbZjaNzNcWkYL193jZVNhMWOY/a0Mw1ZTEqQsw== X-Received: by 2002:a17:90a:a114:: with SMTP id s20mr3579555pjp.44.1575350413045; Mon, 02 Dec 2019 21:20:13 -0800 (PST) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id h9sm1451915pgk.84.2019.12.02.21.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 21:20:12 -0800 (PST) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de, jlayton@kernel.org, ceph-devel@vger.kernel.org Subject: [PATCH v2 3/6] fs: ceph: Delete timespec64_trunc() usage Date: Mon, 2 Dec 2019 21:19:42 -0800 Message-Id: <20191203051945.9440-4-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203051945.9440-1-deepa.kernel@gmail.com> References: <20191203051945.9440-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since ceph always uses ns granularity, skip the truncation which is a no-op. Signed-off-by: Deepa Dinamani Cc: jlayton@kernel.org Cc: ceph-devel@vger.kernel.org Acked-by: Jeff Layton --- fs/ceph/mds_client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 068b029cf073..88687ed65cff 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2069,7 +2069,6 @@ struct ceph_mds_request * ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode) { struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS); - struct timespec64 ts; if (!req) return ERR_PTR(-ENOMEM); @@ -2088,8 +2087,7 @@ ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode) init_completion(&req->r_safe_completion); INIT_LIST_HEAD(&req->r_unsafe_item); - ktime_get_coarse_real_ts64(&ts); - req->r_stamp = timespec64_trunc(ts, mdsc->fsc->sb->s_time_gran); + ktime_get_coarse_real_ts64(&req->r_stamp); req->r_op = op; req->r_direct_mode = mode; From patchwork Tue Dec 3 05:19:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11270509 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 231DD159A for ; Tue, 3 Dec 2019 05:20:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0195620803 for ; Tue, 3 Dec 2019 05:20:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mbTUHEH3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbfLCFUP (ORCPT ); Tue, 3 Dec 2019 00:20:15 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43179 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbfLCFUP (ORCPT ); Tue, 3 Dec 2019 00:20:15 -0500 Received: by mail-pl1-f193.google.com with SMTP id q16so1199645plr.10; Mon, 02 Dec 2019 21:20:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vw3rC7pffNNcciKNW8GALTh1NKcZNgUJHxJWIV46+IQ=; b=mbTUHEH3Fa7gVHQuyVM58bhc1ZNPyRBhs55wGdEUiozfLFQt7oHsIlRs6OmMbQqk9X NVUC20mjFsBXTcFFjt8zkuIz+yoaBfE5ZnDwp/Suspwc56hlLASXeWPasVlSeMabtor9 VI0kB3d552VGzroKQ5tMWSRZQPP8VpUB7CmiUzWY9w66dit4MPZitKgI1GqWNII5LjRw LHkxHknvZaO8zBaWNUHohYL5NjnAZVnL+ZWebN2e5lBttB7h2+cPmot5OKPdtbdz/1l4 tV48n55tuHqaHc9r8Q6nAAjoHSCZCC6Fe2xE5eXTqgl4e5ywCKxp/P2Ro/G38CI1MPM8 iGpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vw3rC7pffNNcciKNW8GALTh1NKcZNgUJHxJWIV46+IQ=; b=gTZ5T2DgU5GcQOm3fCwF1pGjj489sm9MrRcP0eUwfPJ6ufefAym9vAbrlnHGIlmr7T e7QE49QwwlsT+mggNVBoG1Gq9hHSEwzJb12FS/N9UibmVMJFuwiI5cePXn+mse9mCoXp WdvKnH4Oe7THySyvcXyo3o6s4qBewnCSHp63i60jucNdKF/JuubmTlSjCiQ8pnKqrjkt jUYjTgZTELqoRrNhigTbKbslsb1iKBRZRFAi5+JvgMRqLs/CPO2FNkjSyS8wyJ9/BWu0 /jCLZt8jDMVKaq/OPaQEsREcpEc7NMLD+Jj9OkTwVm0N/MF2Voexjoel5typZXcNDstv Ka7g== X-Gm-Message-State: APjAAAUuJ4CXg39HMfDwstE/vb8hQ83oVVh2Yy729bH5xJdPzNZ9j3XL MNBbFvmSHQaqeCbh9nRqrRE= X-Google-Smtp-Source: APXvYqyIirVUziL4a56vsdUKU6cH4t16OUJcrgZCUwEaSPK+fI1rSUG4qhtuG/Zzf1XKgURDz3ytrw== X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr3197997plo.300.1575350414514; Mon, 02 Dec 2019 21:20:14 -0800 (PST) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id h9sm1451915pgk.84.2019.12.02.21.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 21:20:14 -0800 (PST) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de, richard@nod.at, linux-mtd@lists.infradead.org Subject: [PATCH v2 4/6] fs: ubifs: Eliminate timespec64_trunc() usage Date: Mon, 2 Dec 2019 21:19:43 -0800 Message-Id: <20191203051945.9440-5-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203051945.9440-1-deepa.kernel@gmail.com> References: <20191203051945.9440-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org DEFAULT_TIME_GRAN is seconds granularity. We can just drop the nsec while creating the default root node. Delete the unneeded call to timespec64_trunc(). Also update the ktime_get_* api to match the one used in current_time(). This allows for the timestamps to be updated by using the same ktime_get_* api always. Signed-off-by: Deepa Dinamani Cc: richard@nod.at Cc: linux-mtd@lists.infradead.org --- fs/ubifs/sb.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index 2b7c04bf8983..93d550be4c11 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c @@ -84,7 +84,6 @@ static int create_default_filesystem(struct ubifs_info *c) int idx_node_size; long long tmp64, main_bytes; __le64 tmp_le64; - __le32 tmp_le32; struct timespec64 ts; u8 hash[UBIFS_HASH_ARR_SZ]; u8 hash_lpt[UBIFS_HASH_ARR_SZ]; @@ -291,16 +290,14 @@ static int create_default_filesystem(struct ubifs_info *c) ino->creat_sqnum = cpu_to_le64(++c->max_sqnum); ino->nlink = cpu_to_le32(2); - ktime_get_real_ts64(&ts); - ts = timespec64_trunc(ts, DEFAULT_TIME_GRAN); + ktime_get_coarse_real_ts64(&ts); tmp_le64 = cpu_to_le64(ts.tv_sec); ino->atime_sec = tmp_le64; ino->ctime_sec = tmp_le64; ino->mtime_sec = tmp_le64; - tmp_le32 = cpu_to_le32(ts.tv_nsec); - ino->atime_nsec = tmp_le32; - ino->ctime_nsec = tmp_le32; - ino->mtime_nsec = tmp_le32; + ino->atime_nsec = 0; + ino->ctime_nsec = 0; + ino->mtime_nsec = 0; ino->mode = cpu_to_le32(S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO); ino->size = cpu_to_le64(UBIFS_INO_NODE_SZ); From patchwork Tue Dec 3 05:19:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11270505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE73D1805 for ; Tue, 3 Dec 2019 05:20:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8960C2073C for ; Tue, 3 Dec 2019 05:20:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="coN/YcmI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727110AbfLCFUS (ORCPT ); Tue, 3 Dec 2019 00:20:18 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40673 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727096AbfLCFUR (ORCPT ); Tue, 3 Dec 2019 00:20:17 -0500 Received: by mail-pl1-f195.google.com with SMTP id g6so1205979plp.7; Mon, 02 Dec 2019 21:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BHTDtxvEiYFTLiebbwUbRtrN28Hzzvb20uPHKGc+/WM=; b=coN/YcmII5tOr2Q6ckP0agsPiESdW+pWZtozn/BhsYMra12t3cXbClaWLS+cfp9AnA 1iXvHDsFFcByIOacZzq6YFzRNPBPV2yb+bJjSUssmaaqmK7Xisy3DeL8lWi0f+AT7LSa yMciqWgWBiRWHfJlZ0dgBMspxHWuIQUU/dL974r1gvMm9EA2+3aWIfBAEhB+bnpuNbBl 8cvaXcuiaWOtppaVKz2E3FgdVOv2Sd6B4UA0XFFcWSxJJ9J44XD+6mEfAa3Jt/d7CxjQ qTsCg/wIPxe37WpHo75dtSK87GgAmc0xHQyZiQS0Om23rFmfLciEvqmmqP4dY0ml6xGg WoeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BHTDtxvEiYFTLiebbwUbRtrN28Hzzvb20uPHKGc+/WM=; b=o/OoZcvgHKVmAZo25DK0Yzd5oIFCIpZX5jN2QWTnWqt6YTTWDxMH1t8Wy/8iALcpA4 D8k27+h0cDiunJmAI0uc7op4uDPaqJ2wueFRHVCQTgYFVHf8go15aBzk2vFjA8zJWyCr 88KpXOem/rbX1eG2pS4zHFb+sl++TxCpJxy4T1JJiSasEDBhP2Ss719GI7SDfjJKw9yy 5/rFhY4qSZC09rtlqkGvWQFBiCUZkaPIcrjD04Juu30lpPSKXFJMRjCCZeEmlQ2ZqVgs bbz8ipxou0h3tw3xNWJlA7bRGZKf97t1wCTpLufDdduMNRkCMQrAPRhI4BXaBozjZeFz Yrdw== X-Gm-Message-State: APjAAAX0IuMDI4mPStq6e5STZRaZkX7Kkbrzne/OzATL0do1P9xzAUR0 L+CXHePHZiepBHTR0dt2tbPBlOYA X-Google-Smtp-Source: APXvYqzDUQDg8PpScRL9lZwSvsaG9MSdLQfAhziXjGNzRZ1xxpRQtar4Ed+lPQvxhnXbzn7pjW25Ww== X-Received: by 2002:a17:90a:b384:: with SMTP id e4mr3453562pjr.108.1575350416011; Mon, 02 Dec 2019 21:20:16 -0800 (PST) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id h9sm1451915pgk.84.2019.12.02.21.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 21:20:15 -0800 (PST) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de Subject: [PATCH v2 5/6] fs: Delete timespec64_trunc() Date: Mon, 2 Dec 2019 21:19:44 -0800 Message-Id: <20191203051945.9440-6-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203051945.9440-1-deepa.kernel@gmail.com> References: <20191203051945.9440-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org There are no more callers to the function remaining. Signed-off-by: Deepa Dinamani --- fs/inode.c | 24 ------------------------ include/linux/fs.h | 1 - 2 files changed, 25 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index fef457a42882..12c9e38529c9 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2145,30 +2145,6 @@ void inode_nohighmem(struct inode *inode) } EXPORT_SYMBOL(inode_nohighmem); -/** - * timespec64_trunc - Truncate timespec64 to a granularity - * @t: Timespec64 - * @gran: Granularity in ns. - * - * Truncate a timespec64 to a granularity. Always rounds down. gran must - * not be 0 nor greater than a second (NSEC_PER_SEC, or 10^9 ns). - */ -struct timespec64 timespec64_trunc(struct timespec64 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(timespec64_trunc); - /** * timestamp_truncate - Truncate timespec to a granularity * @t: Timespec diff --git a/include/linux/fs.h b/include/linux/fs.h index 98e0349adb52..46dd7e6f6d73 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1575,7 +1575,6 @@ static inline void i_gid_write(struct inode *inode, gid_t gid) inode->i_gid = make_kgid(inode->i_sb->s_user_ns, gid); } -extern struct timespec64 timespec64_trunc(struct timespec64 t, unsigned gran); extern struct timespec64 current_time(struct inode *inode); /* From patchwork Tue Dec 3 05:19:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11270507 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49A12139A for ; Tue, 3 Dec 2019 05:20:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2885520803 for ; Tue, 3 Dec 2019 05:20:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gwVAe8g4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727149AbfLCFUX (ORCPT ); Tue, 3 Dec 2019 00:20:23 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44393 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbfLCFUS (ORCPT ); Tue, 3 Dec 2019 00:20:18 -0500 Received: by mail-pf1-f194.google.com with SMTP id d199so1225540pfd.11; Mon, 02 Dec 2019 21:20:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VeU+4RS/PpYtzQGHtIekj3ninA+VVkPKJdEtPDnLRPU=; b=gwVAe8g4xi2/LueExwl9mjN4TSqcI5f+1FomCI0NfGnq505J0FsoHuq9/U1/5o1j/H LG23ptGFgJuVqAUTHTL/oTccCqJz/IiHq+xYggvMOspWdMWGm2ao8gtZ47Eemf1S7Rg4 3hKF//ApfC7jC8mFhHRXBjGlURZ9r7ZudphdqO+l4kfGCnulneRQDBEFbG7umJbqOjpS n/r07yATJ1AJhloDdhk6jYjjOoR8bAn/RcjF7jvm5ZmdB46EpoNrJqVBII0O8lsGEpfp CEfSfVCv5lhkfSr8JE54w0iynDJr7BD5wWwm6OKAT7/O62MtOR6JtYQiLMK9Vlw/9Z/w lhEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VeU+4RS/PpYtzQGHtIekj3ninA+VVkPKJdEtPDnLRPU=; b=NAhnARkxSIb37PE2T2AYaHFlxPMjyc8bV32bfkttvNgGfKdgrpND2+l8HAmG8mNVgj hj1l+cimljWTqRgnH3a3FesnFXNo41c2WPXF5lnDVGFQ/L/27RUw+1sgIiHBPR901seh 3agEDjYWLM9H3sB+4snDe7PE8FD6FBDA7Ortu/fih3r00+JkEVT9mgl6kpq+CZLC4xGC wIb0aUG6NtlDdiS8usrErBrHXtbVBzxcQQ1wc/gQHonJs+0PfH9JGXXfpsb0XU6VIOOE 3C1GuyLEdaZAAhKLX9YSJstxwJsuc4JmAKQyEEGZ/+7qri4L+KttjSy4WoY0v2mVwPBH jquw== X-Gm-Message-State: APjAAAWfahmO2OURflP8yav2WnPahtGlY2PBrOLZrJzCp8rZaGgT0kXi Pk/++AQWIAbvpkWx9jKtBUw= X-Google-Smtp-Source: APXvYqw0YvpmI6G+T2AV285iedroWKgLbw7+vCwsHcSwjyfgoD0qwqJARPSSoxAnpAwM+8cyB1bK3g== X-Received: by 2002:aa7:972a:: with SMTP id k10mr2994373pfg.140.1575350417865; Mon, 02 Dec 2019 21:20:17 -0800 (PST) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id h9sm1451915pgk.84.2019.12.02.21.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 21:20:17 -0800 (PST) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de Subject: [PATCH v2 6/6] fs: Do not overload update_time Date: Mon, 2 Dec 2019 21:19:45 -0800 Message-Id: <20191203051945.9440-7-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203051945.9440-1-deepa.kernel@gmail.com> References: <20191203051945.9440-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org update_time() also has an internal function pointer update_time. Even though this works correctly, it is confusing to the readers. Just use a regular if statement to call the generic function or the function pointer. Suggested-by: Al Viro Signed-off-by: Deepa Dinamani --- fs/inode.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 12c9e38529c9..aff2b5831168 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1675,12 +1675,9 @@ EXPORT_SYMBOL(generic_update_time); */ static int update_time(struct inode *inode, struct timespec64 *time, int flags) { - int (*update_time)(struct inode *, struct timespec64 *, int); - - update_time = inode->i_op->update_time ? inode->i_op->update_time : - generic_update_time; - - return update_time(inode, time, flags); + if (inode->i_op->update_time) + return inode->i_op->update_time(inode, time, flags); + return generic_update_time(inode, time, flags); } /**