From patchwork Mon Jun 20 00:27:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 9186291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D47C06075F for ; Mon, 20 Jun 2016 00:28:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D03ED2236A for ; Mon, 20 Jun 2016 00:28:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C50D4223A0; Mon, 20 Jun 2016 00:28:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ED4B2236A for ; Mon, 20 Jun 2016 00:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751963AbcFTA2O (ORCPT ); Sun, 19 Jun 2016 20:28:14 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:34681 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883AbcFTA2D (ORCPT ); Sun, 19 Jun 2016 20:28:03 -0400 Received: by mail-pa0-f68.google.com with SMTP id us13so9671315pab.1; Sun, 19 Jun 2016 17:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jJqQdpLqILQbHveJDPAeiOI1PwGnCcV0ITA1M+ffccY=; b=mXGoqMqPRkgncUhrHQL2B/e2jVfb+HrqbJrkkfXn6NrhBCqilleXJGMQuOgy2IzFjn 0wEeZqdzcefeQn5l/9klsMaUlOkUa73q48w/pgCOAUBq3oXux0bXQNoeNlpD5Zt4HZ0k +/ioY96eCzg1xjyO9TErF2E9N87mhk8LuewCuao2+BfOrs3mMyBFVreUgRBCbohWBWCY iu+TIc16roFoqdp/harnIx0nVzdySsGedl31V3lpQpGwaKAOpEIIQ+CXrwP5U/au9aFk rucvuEFn592o2V9bf9uhHWkc5GlVg1BQwAiNDp7pxxLKlD0Z5P6G/HNAJS7eDZ+lSR3M hW6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jJqQdpLqILQbHveJDPAeiOI1PwGnCcV0ITA1M+ffccY=; b=c02CGL1cID/AMVB611VEWIsgE7Tr8qyRWiPRd5X9zGLvE/HUE+B6+S8K5FdDXm6aUo /g1DP0deGN0ohCvBJA6lLOlpGWxjBnHYNMCMT81i41zDx4Lh1jTcEBCI6Ip5jnbx53mu +/pBuEzbMNuqRveG35FoutyQ794c5rvcAhU/ZpVb96l/nz0fCylEqeuMJIiY0vS2ox1k CWZGOA7rgk2cZYgm0uKSgY+5cf40eX+P406ue3oX0+tWVkx3Zt2SR8azYj7EUAAB2Mv3 ANhNrV1qVxxFGsIgMzJ6techuVlDrAJioIXfUg/CK4wt7VjuoiJ+XhvH0uIwb8j353Ft AjsA== X-Gm-Message-State: ALyK8tKid7dUXbHaOGesxIKCJgMusJfPldOF/adKFRHW2nnipy5bf8INbdetKkCIYKK0dA== X-Received: by 10.67.16.108 with SMTP id fv12mr18668531pad.8.1466382483087; Sun, 19 Jun 2016 17:28:03 -0700 (PDT) Received: from deepa-ubuntu.hsd1.ca.comcast.net (c-73-252-251-201.hsd1.ca.comcast.net. [73.252.251.201]) by smtp.gmail.com with ESMTPSA id s12sm34984980pfj.57.2016.06.19.17.28.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Jun 2016 17:28:02 -0700 (PDT) From: Deepa Dinamani To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, tglx@linutronix.de, torvalds@linux-foundation.org, tytso@mit.edu, viro@zeniv.linux.org.uk, y2038@lists.linaro.org Subject: [PATCH v2 01/24] vfs: Add current_time() api Date: Sun, 19 Jun 2016 17:27:00 -0700 Message-Id: <1466382443-11063-2-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466382443-11063-1-git-send-email-deepa.kernel@gmail.com> References: <1466382443-11063-1-git-send-email-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP current_fs_time() is used for inode timestamps. Change the signature of the function to take inode pointer instead of superblock as per Linus's suggestion. Also, move the api under vfs as per the discussion on the thread: https://lkml.org/lkml/2016/6/9/36 . As per Arnd's suggestion on the thread, changing the function name. current_fs_time() will be deleted after all the references to it are replaced by current_time(). Note that timespec_trunc() will also be moved to fs/inode.c in a separate patch when this will need to be revamped for bounds checking purposes. Signed-off-by: Deepa Dinamani --- fs/inode.c | 15 +++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 16 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 4ccbc21..75c98cc 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2041,3 +2041,18 @@ void inode_nohighmem(struct inode *inode) mapping_set_gfp_mask(inode->i_mapping, GFP_USER); } EXPORT_SYMBOL(inode_nohighmem); + +/** + * current_time - Return FS time + * @inode: inode. + * + * Return the current time truncated to the time granularity supported by + * the fs. + */ +struct timespec current_time(struct inode *inode) +{ + struct timespec now = current_kernel_time(); + + return timespec_trunc(now, inode->i_sb->s_time_gran); +} +EXPORT_SYMBOL(current_time); diff --git a/include/linux/fs.h b/include/linux/fs.h index dcd087e..21a8afe 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1461,6 +1461,7 @@ struct super_block { }; extern struct timespec current_fs_time(struct super_block *sb); +extern struct timespec current_time(struct inode *inode); static inline struct timespec current_fs_time_sec(struct super_block *sb) {