From patchwork Wed Oct 9 01:26:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11180223 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 701F915AB for ; Wed, 9 Oct 2019 01:27:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4388620859 for ; Wed, 9 Oct 2019 01:27:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rCOQ28GZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729839AbfJIB1M (ORCPT ); Tue, 8 Oct 2019 21:27:12 -0400 Received: from mail-io1-f49.google.com ([209.85.166.49]:37250 "EHLO mail-io1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729700AbfJIB1L (ORCPT ); Tue, 8 Oct 2019 21:27:11 -0400 Received: by mail-io1-f49.google.com with SMTP id b19so1328936iob.4 for ; Tue, 08 Oct 2019 18:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=bktyE/8x8rNhvrR/aL8M7kb8XhCxohgh5hkcLj3s5OQ=; b=rCOQ28GZL9yrGICbLtqVdA+Tf1j9sW2IlRg2PoFAlSxq3djb80M/VmwjbxmenM2nEs flOLDO3i0HYLuWKqchoiuM2cTMtQGAlArtK5ZqnEUtkfnyin7oz4lXZUxSR7Et3JUjQc lGRYS1ZVTwTM2zyJDtYoKVolLuHFUHCoxdsMv5iQElXkxJ8u7mH1diIT0cyzP5L6nc+a AnhMer8rRV1a1nKqk0VISrvzd9ei9EUtcIusRHBfkQB3aibagxZ5t2zVAUlQ8KWxb8SQ K7y03iWddUkjaoKkx7IednSbfUFZRJmls14VHp4BgFaPpmcC+0mqUiZ0NpWDyuFhRgQI 2wXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=bktyE/8x8rNhvrR/aL8M7kb8XhCxohgh5hkcLj3s5OQ=; b=Qj9+WzZJfJjnVwp4JsznEYjCCcGhiW6BPb59gbo4XObMTlQ/X+UHe8GPi1BZGOR7is /LYZQTvhMlrB3PjvjENarP4bIl9So5q44k3Lv5lgkjfFGkRe+8wGFEB+YKtje6TD7HEf 9uXee/SRCozKueylqp1hPDpEB5rSbvlGqJLiSr6GUOpJLEbX5qgDCcy8MzPKYCa14jNw bnxLriWP1jgG7aeIzTjPeM42RG/IndlPPSlWyOzcZuTB5eXUD7Xd8KZGIucLmw9qkqyo VvpIzUXD8HFWDnS1gx2bKbJmDw2XfhVE9D6u3LIqVAWcdUl/sqSQowRuIzcV6pLUc71b zkXQ== X-Gm-Message-State: APjAAAUVfobko3hIkmBGAmkdbg8UW/BMNA8pxZfhlM1i62i6QNwadn4p 1/fndj/A7l3yTzq2kroULS3qEAfSB6vefPu1j8ll0w== X-Google-Smtp-Source: APXvYqzH3enV5PgIH84irGVuEvYF3HRBJ4srhrF4x1wqfNtW9sXI9WtuKjSM1LNj4kldwL9Kc8mEcybt+JC0WSlH4aw= X-Received: by 2002:a6b:5c0f:: with SMTP id z15mr1242233ioh.173.1570584430681; Tue, 08 Oct 2019 18:27:10 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 8 Oct 2019 18:26:59 -0700 Message-ID: Subject: [PATCH] Fix regression in SMB3 time handling To: CIFS Cc: Jeff Layton , Deepa Dinamani Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Fixes xfstest 258 which regressed due to a recent change to add min/max time From ff93aba3e671bbde7d46a9b6e6af1136142e31e5 Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 8 Oct 2019 00:27:14 -0500 Subject: [PATCH 1/3] smb3: Fix regression in time handling Fixes: cb7a69e60590 ("cifs: Initialize filesystem timestamp ranges") Only very old servers (e.g. OS/2 and DOS) did not support DCE TIME (100 nanosecond granularity). Fix the checks used to set minimum and maximum times. CC: Deepa Dinamani Acked-by: Jeff Layton Signed-off-by: Steve French Reviewed-by: Pavel Shilovsky --- fs/cifs/cifsfs.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 2e9c7f493f99..45330b32f1bb 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -169,18 +169,26 @@ cifs_read_super(struct super_block *sb) else sb->s_maxbytes = MAX_NON_LFS; - /* BB FIXME fix time_gran to be larger for LANMAN sessions */ - sb->s_time_gran = 100; - - if (tcon->unix_ext) { - ts = cifs_NTtimeToUnix(0); + /* Some very old servers like DOS and OS/2 used 2 second granularity */ + if ((tcon->ses->server->vals->protocol_id == SMB10_PROT_ID) && + ((tcon->ses->capabilities & + tcon->ses->server->vals->cap_nt_find) == 0) && + !tcon->unix_ext) { + sb->s_time_gran = 2000000000; /* 2 seconds */ + ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MIN), 0, 0); sb->s_time_min = ts.tv_sec; - ts = cifs_NTtimeToUnix(cpu_to_le64(S64_MAX)); + ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MAX), + cpu_to_le16(SMB_TIME_MAX), 0); sb->s_time_max = ts.tv_sec; } else { - ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MIN), 0, 0); + /* + * Almost every server, including all SMB2+, uses DCE TIME + * ie 100 nanosecond units, since 1601. See MS-DTYP and MS-FSCC + */ + sb->s_time_gran = 100; + ts = cifs_NTtimeToUnix(0); sb->s_time_min = ts.tv_sec; - ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MAX), cpu_to_le16(SMB_TIME_MAX), 0); + ts = cifs_NTtimeToUnix(cpu_to_le64(S64_MAX)); sb->s_time_max = ts.tv_sec; } -- 2.20.1