From patchwork Sat Nov 30 05:30:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11267855 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 37E95921 for ; Sat, 30 Nov 2019 05:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 145742086A for ; Sat, 30 Nov 2019 05:31:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MzVVrKj5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbfK3FbO (ORCPT ); Sat, 30 Nov 2019 00:31:14 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:45172 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbfK3FbO (ORCPT ); Sat, 30 Nov 2019 00:31:14 -0500 Received: by mail-pj1-f68.google.com with SMTP id r11so6447816pjp.12; Fri, 29 Nov 2019 21:31: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=RG3ZZhL0E9GykGjjrk/4EJEMUcXoBYc4Ti1EdJzmX8c=; b=MzVVrKj56G3Rjx9PNwPCnF05+CWpsp9qOCWIjLhSMVP1H85Jm+kEMq01a3II/SkjeA D2on7ny2E34U4qUzAstO8zqiSbvLyF1I/+6Pgt0bF4b2/OrKnM2tt7myGi3/D4cFMIFo VhHpYU+J/+jA8MkczlPzPLFQYpf1IX1JZdbECnrenXKLVlK2MeWqWAH4YaZIOUI8Gd8z HrJ0QxI6IbWIQOebPB24cRQ7Im6US8lMaYxZo/Esqm6V4VrLcBObUcgiHOCFtNzQGluO NcxS0+A043dL67/NUVptSeAAmdjo0LJIeRQd4zXXKASEkDGZc8/VsCD0TanaTgIFQQ3l H1sw== 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=RG3ZZhL0E9GykGjjrk/4EJEMUcXoBYc4Ti1EdJzmX8c=; b=DYk1I1/GKgGIPgZofrq7+eO3VGgDY8WUhQK52DMv+ckXU/5bNlQCLiqK9rHtHCqeZJ 2CoQLWLQJJzjmoIZ2XvxcRW0Nb8VNGYiJixzaiGsldqmhxLW7/0HQ3J+UP+K6IAhYTMQ gYYfqIAjcz2EIuVdC+wUVvp6HtQ6A6ebhJgbZEf7mk03OxaSwwsagGwOhemEpSb8Oe17 Wnfrrrn8atHFXDtNI1tcwGSEDx9XziwVnTPuakQH2kmHwPB1PghZZFuGzPB+lkRPci6j tTrfKjulZwKPq8PcWGE/fMCEbUzWN540BdYmdlEWHR7AzsB0q6ItcPW3LI/CBKxIY2Ta TYiA== X-Gm-Message-State: APjAAAWvhZcz38P/8ObCVlgieDgfMdM/1qIi4+Q6DFilCsZjCDnxoLMq pEfen9l5s2nol7u2jM+8wWk= X-Google-Smtp-Source: APXvYqyGNzC6Z7/nQnWlPRGSKMBzHzH4LiHA8ULIljDDy4dGNrtzcc0t//GYYPmR1cVantfjMqmdvA== X-Received: by 2002:a17:902:be02:: with SMTP id r2mr16885299pls.76.1575091873307; Fri, 29 Nov 2019 21:31: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 a13sm26131734pfi.187.2019.11.29.21.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2019 21:31: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, stfrench@microsoft.com, linux-cifs@vger.kernel.org Subject: [PATCH 2/7] fs: cifs: Fix atime update check vs mtime Date: Fri, 29 Nov 2019 21:30:25 -0800 Message-Id: <20191130053030.7868-3-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191130053030.7868-1-deepa.kernel@gmail.com> References: <20191130053030.7868-1-deepa.kernel@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org According to the comment in the code and commit log, some apps expect atime >= mtime; but the introduced code results in atime==mtime. Fix the comparison to guard against atime Cc: stfrench@microsoft.com Cc: linux-cifs@vger.kernel.org --- fs/cifs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 8a76195e8a69..ca76a9287456 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -163,7 +163,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr) spin_lock(&inode->i_lock); /* we do not want atime to be less than mtime, it broke some apps */ - if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime)) + if (timespec64_compare(&fattr->cf_atime, &fattr->cf_mtime) < 0) inode->i_atime = fattr->cf_mtime; else inode->i_atime = fattr->cf_atime; From patchwork Sat Nov 30 05:30:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11267853 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 07028139A for ; Sat, 30 Nov 2019 05:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D723B2086A for ; Sat, 30 Nov 2019 05:31:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hp4AIL/U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726936AbfK3FbR (ORCPT ); Sat, 30 Nov 2019 00:31:17 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36244 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbfK3FbQ (ORCPT ); Sat, 30 Nov 2019 00:31:16 -0500 Received: by mail-pg1-f193.google.com with SMTP id k13so15503922pgh.3; Fri, 29 Nov 2019 21:31: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=CmhQS/RvxHM1ZkF3nWKmxpQ+xBfLTIt05/c08FcGCIs=; b=hp4AIL/UwGtuzngGMTZYaxAlp9v/JGnzfyYa/plbFcAmNur5KkDnWK3HMa+z5yG+QZ Q5LxWgOtJXfAmlhcN0aFpuVfsa0evlcQxxe4lAzGeJWQmunAaZliLQ8kLX01VfmL+CnP pBre+WkAYg2CuUGA5ujfw9014QCVR96BCcPDEyeYyCB6OczBOee0gUs3jwC9Bp2hRBsO MaPBbWltKWMECRYznYlWa0xsAn0jKiSwY1F16Ksg8YxZQBDMN2VJA6dxFAwGoqayddJ8 WKcM2vahApMvlhVohv0kXTPCmnT/nb73fP0CwGfWLgwDMCsq51/CGC69YtH39slcCM/2 QSiA== 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=V/PEF6F68oSK0OmBCxjUEsfjEF1W1YjTc4HIHW+6NHdLlUtoAaXzDxsPYnwy7Pu0jA V8ZCIxspSuoJYfG3axIJ9Q2vh5bfHc5G0sulmldmmwKF/CdktxwPpaovt/TKLrLF7I3t IOivHfkrgwm6ccVkMCIMjW5gAXca6LWnGyDvm81NxxG4wsNRHfNElTfj2tshzOv+1Evh p8K9BNBnq7JxG6GJvqWy+VuyLzHuGwknT71vnhc8U6cBS/s5KO8Fi3q9zxLq0D0s/KF0 Q2E6o3o0LYk+U3bMRkDuAXyGX89KGp5y1pWiO87SwSIn27VPq/Z/r/o/RG5xcoQq8Vsl Rekg== X-Gm-Message-State: APjAAAXfXEu1x63Y02eRs8Pg5eLqNq5Fm0VgaR4BYP4rqhdariwpc03z KOANkrFSLnQl7zDifNeC3ogfP35R X-Google-Smtp-Source: APXvYqzeGM2sPKH5IIE/oT9bZrPKO3zy52iiEg+grtcMiCeaPDDZKlj2ye7F1vCWVAMIZiWVhHR+aA== X-Received: by 2002:a63:4b52:: with SMTP id k18mr20132223pgl.394.1575091875879; Fri, 29 Nov 2019 21:31:15 -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 a13sm26131734pfi.187.2019.11.29.21.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2019 21:31: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, stfrench@microsoft.com, linux-cifs@vger.kernel.org Subject: [PATCH 3/7] fs: cifs: Delete usage of timespec64_trunc Date: Fri, 29 Nov 2019 21:30:26 -0800 Message-Id: <20191130053030.7868-4-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191130053030.7868-1-deepa.kernel@gmail.com> References: <20191130053030.7868-1-deepa.kernel@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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);