From owner-freebsd-fs@FreeBSD.ORG Mon Jan 14 19:45:30 2013 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D0481C00; Mon, 14 Jan 2013 19:45:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id A4AB765E; Mon, 14 Jan 2013 19:45:30 +0000 (UTC) Received: from pakbsde14.localnet (unknown [38.105.238.108]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 1E09DB95E; Mon, 14 Jan 2013 14:45:30 -0500 (EST) From: John Baldwin To: fs@freebsd.org Subject: [PATCH] Better handle NULL utimes() in the NFS client Date: Mon, 14 Jan 2013 14:45:29 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p22; KDE/4.5.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201301141445.29260.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 14 Jan 2013 14:45:30 -0500 (EST) Cc: Rick Macklem X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jan 2013 19:45:30 -0000 The NFS client tries to infer when an application has passed NULL to utimes() so that it can let the server set the timestamp rather than using a client- supplied timestamp. It does this by checking to see if the desired timestamp's second matches the current second. However, this breaks applications that are intentionally trying to set a specific timestamp within the current second. In addition, utimes() sets a flag to indicate if NULL was passed to utimes(). The patch below changes the NFS client to check this flag and only use the server-supplied time in that case: Index: fs/nfsclient/nfs_clport.c =================================================================== --- fs/nfsclient/nfs_clport.c (revision 225511) +++ fs/nfsclient/nfs_clport.c (working copy) @@ -762,7 +762,7 @@ *tl = newnfs_false; } if (vap->va_atime.tv_sec != VNOVAL) { - if (vap->va_atime.tv_sec != curtime.tv_sec) { + if (!(vap->va_vaflags & VA_UTIMES_NULL)) { NFSM_BUILD(tl, u_int32_t *, 3 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); txdr_nfsv3time(&vap->va_atime, tl); @@ -775,7 +775,7 @@ *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); } if (vap->va_mtime.tv_sec != VNOVAL) { - if (vap->va_mtime.tv_sec != curtime.tv_sec) { + if (!(vap->va_vaflags & VA_UTIMES_NULL)) { NFSM_BUILD(tl, u_int32_t *, 3 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); txdr_nfsv3time(&vap->va_mtime, tl); Index: nfsclient/nfs_subs.c =================================================================== --- nfsclient/nfs_subs.c (revision 225511) +++ nfsclient/nfs_subs.c (working copy) @@ -1119,7 +1119,7 @@ *tl = nfs_false; } if (va->va_atime.tv_sec != VNOVAL) { - if (va->va_atime.tv_sec != time_second) { + if (!(vattr.va_vaflags & VA_UTIMES_NULL)) { tl = nfsm_build_xx(3 * NFSX_UNSIGNED, mb, bpos); *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); txdr_nfsv3time(&va->va_atime, tl); @@ -1132,7 +1132,7 @@ *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); } if (va->va_mtime.tv_sec != VNOVAL) { - if (va->va_mtime.tv_sec != time_second) { + if (!(vattr.va_vaflags & VA_UTIMES_NULL)) { tl = nfsm_build_xx(3 * NFSX_UNSIGNED, mb, bpos); *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); txdr_nfsv3time(&va->va_mtime, tl); -- John Baldwin