From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by kanga.kvack.org (Postfix) with ESMTP id 08D22828E1 for ; Thu, 9 Jun 2016 15:08:06 -0400 (EDT) Received: by mail-ig0-f197.google.com with SMTP id i11so65984131igh.0 for ; Thu, 09 Jun 2016 12:08:06 -0700 (PDT) Received: from mail-oi0-x242.google.com (mail-oi0-x242.google.com. [2607:f8b0:4003:c06::242]) by mx.google.com with ESMTPS id a50si3616468otc.61.2016.06.09.12.08.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jun 2016 12:08:05 -0700 (PDT) Received: by mail-oi0-x242.google.com with SMTP id k63so9213471oib.2 for ; Thu, 09 Jun 2016 12:08:04 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1465448705-25055-5-git-send-email-deepa.kernel@gmail.com> References: <1465448705-25055-1-git-send-email-deepa.kernel@gmail.com> <1465448705-25055-5-git-send-email-deepa.kernel@gmail.com> From: Linus Torvalds Date: Thu, 9 Jun 2016 12:08:04 -0700 Message-ID: Subject: Re: [PATCH 04/21] fs: Replace CURRENT_TIME with current_fs_time() for inode timestamps Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Deepa Dinamani Cc: linux-fsdevel , Linux Kernel Mailing List , Arnd Bergmann , Thomas Gleixner , Al Viro , y2038@lists.linaro.org, Steve French , "linux-cifs@vger.kernel.org" , samba-technical@lists.samba.org, Joern Engel , Prasad Joshi , logfs@logfs.org, Andrew Morton , Julia Lawall , David Howells , Firo Yang , Jaegeuk Kim , Changman Lee , Chao Yu , "Linux F2FS DEV, Mailing List" , Michal Hocko , Konstantin Khlebnikov , Naoya Horiguchi , "J. Bruce Fields" , Jeff Layton , Trond Myklebust , Anna Schumaker , "David S. Miller" , Linux NFS Mailing List , Network Development , Steven Whitehouse , Bob Peterson , cluster-devel , Mark Fasheh , Joel Becker , ocfs2-devel@oss.oracle.com, Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck , Chris Mason , Josef Bacik , David Sterba , linux-btrfs , Miklos Szeredi , "open list:FUSE: FILESYSTEM..." , Felipe Balbi , Greg Kroah-Hartman , USB list , Doug Ledford , Sean Hefty , Hal Rosenstock , "linux-rdma@vger.kernel.org" , Robert Richter , "oprofile-list@lists.sf.net" , Alexei Starovoitov , Hugh Dickins , linux-mm , Paul Moore , Stephen Smalley , Eric Paris , selinux@tycho.nsa.gov, James Morris , "Serge E. Hallyn" , LSM List , Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , V9FS Developers , Ian Kent , autofs mailing list , Matthew Garrett , Jeremy Kerr , Matt Fleming , "linux-efi@vger.kernel.org" , Peter Hurley , Josh Triplett , Boaz Harrosh , Benny Halevy , open-osd , Mike Marshall , pvfs2-developers@beowulf-underground.org, Nadia Yvette Chambers , Dave Kleikamp , jfs-discussion@lists.sourceforge.net, Ryusuke Konishi , linux-nilfs@vger.kernel.org On Wed, Jun 8, 2016 at 10:04 PM, Deepa Dinamani wrote: > CURRENT_TIME macro is not appropriate for filesystems as it > doesn't use the right granularity for filesystem timestamps. > Use current_fs_time() instead. Again - using the inode instead fo the syuperblock in tghis patch would have made the patch much more obvious (it could have been 99% generated with the sed-script I sent out a week or two ago), and it would have made it unnecessary to add these kinds of things: > diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c > index e9f5043..85c12f0 100644 > --- a/drivers/usb/core/devio.c > +++ b/drivers/usb/core/devio.c > @@ -2359,6 +2359,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd, > { > struct usb_dev_state *ps = file->private_data; > struct inode *inode = file_inode(file); > + struct super_block *sb = inode->i_sb; > struct usb_device *dev = ps->dev; > int ret = -ENOTTY; where we add a new variable just because the calling convention was wrong. It's not even 100% obvious that a filesystem has to have one single time representation, so making the time function about the entity whose time is set is also conceptually a much better model, never mind that it is just what every single user seems to want anyway. So I'd *much* rather see + inode->i_atime = inode->i_mtime = inode->i_ctime = current_fs_time(inode); over seeing either of these two variants:: + inode->i_atime = inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); + ret->i_atime = ret->i_mtime = ret->i_ctime = current_fs_time(sb); because the first of those variants (grep for current_fs_time() in the current git tree, and notice that it's the common one) we have the pointless "let's chase a pointer in every caller" And while it's true that the second variant is natural for *some* situations, I've yet to find one where it wasn't equally sane to just pass in the inode instead. Linus -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org