From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 768E7C55184 for ; Tue, 21 Apr 2020 13:58:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 573852071C for ; Tue, 21 Apr 2020 13:58:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gCEtc98v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbgDUN6k (ORCPT ); Tue, 21 Apr 2020 09:58:40 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:48374 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728337AbgDUN5w (ORCPT ); Tue, 21 Apr 2020 09:57:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587477470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2wRD9FPTWKMzxCyWJGhqpm27rg8NjVNjjKx55UL7gOU=; b=gCEtc98vsx50GOhI5DnLX6ZTk8IPbS5r4KhGWk7yEDyJJRl05nN/liIboutEnSdeSDpOEJ Ja1jLnCF/bPPsYuFH8G8ZiFE3goc9omA4BjWqiF10KhJtW+wEgO7Rl4nros0uqji7U1bxa Zjq4jVxdgG3U8UfiEdJR/SJkbslNvVg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-179-O4vvojiBOGOsnWjA26QRhA-1; Tue, 21 Apr 2020 09:57:47 -0400 X-MC-Unique: O4vvojiBOGOsnWjA26QRhA-1 Received: by mail-wr1-f70.google.com with SMTP id p2so6772011wrx.12 for ; Tue, 21 Apr 2020 06:57:47 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=2wRD9FPTWKMzxCyWJGhqpm27rg8NjVNjjKx55UL7gOU=; b=FId5+pjktXLwznbCO9cQKM4a23Eww38baTxxUSlvkTTjMS5pbep+y5uFYVjd5dPPnn smKdBz8xnWw7YfmIbUw5CAKD4n/AO60NIS1Y7KE1V8hD5E8tkX4UTng0w2B4TRDTvM0O dplHfG1fqPzKgFhK0eM88K33b+1AnQRBDbRp4uhHklQJsONccrxLeHHY39SPLmi7nE/S e5O3pwt3dV5abXx2T9jmaS4QboAVuLGmBovVEuanBcBjomCAMP85ktPMem6QqP2B6BY0 wULw4vr9Msa5iikSWQEabA0eAYmdtHRO0QXig2Bg8a8upV8IPDZ61QBDc2/zXq8lyoNF kUhQ== X-Gm-Message-State: AGi0PuYhmoZpfYvgtnCe61nRovofGw7qPsuUQ92bnt1E61fZr7WSx4QI YZks6HofT9uBiwfru503KB651JP4Ts/3trXV2NY6UO9BE86PYAH556BOTXZENnM17IyXIvKuKfW +1jUIEMkH06y2G1/e8mD/jcib4ox75kQvWQ9K X-Received: by 2002:a7b:cb17:: with SMTP id u23mr4993977wmj.130.1587477466574; Tue, 21 Apr 2020 06:57:46 -0700 (PDT) X-Google-Smtp-Source: APiQypIdMbj9yLvuLA4LwwjCRX8ejEQ6n8RjZ/wI7HQOlXPSbSe/l8j+NErdfsIjBeaz5nCZl4whdg== X-Received: by 2002:a7b:cb17:: with SMTP id u23mr4993944wmj.130.1587477466378; Tue, 21 Apr 2020 06:57:46 -0700 (PDT) Received: from localhost.localdomain.com ([194.230.155.194]) by smtp.gmail.com with ESMTPSA id f23sm3562989wml.4.2020.04.21.06.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:57:45 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-fsdevel@vger.kernel.org Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "James E.J. Bottomley" , "Martin K. Petersen" , Alexander Viro , Joel Becker , Christoph Hellwig , "Rafael J. Wysocki" , John Johansen , James Morris , "Serge E. Hallyn" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-scsi@vger.kernel.org, linux-security-module@vger.kernel.org, Paolo Bonzini , Emanuele Giuseppe Esposito Subject: [PATCH v2 3/7] libfs: introduce new_inode_current_time Date: Tue, 21 Apr 2020 15:57:37 +0200 Message-Id: <20200421135741.30657-1-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com> References: <20200421135119.30007-1-eesposit@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it. Signed-off-by: Emanuele Giuseppe Esposito --- fs/libfs.c | 20 ++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 21 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 54e07ae986ca..3fa0cd27ab06 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -594,6 +594,26 @@ int simple_write_end(struct file *file, struct address_space *mapping, } EXPORT_SYMBOL(simple_write_end); +/** + * new_inode_current_time - create new inode by initializing the + * time to the current time and the inode to get_next_ino() + * @sb: pointer to super block of the file system + * + * Returns an inode pointer on success, NULL on failure. + */ +struct inode *new_inode_current_time(struct super_block *sb) +{ + struct inode *inode = new_inode(sb); + + if (inode) { + inode->i_ino = get_next_ino(); + inode->i_atime = inode->i_mtime = + inode->i_ctime = current_time(inode); + } + return inode; +} +EXPORT_SYMBOL(new_inode_current_time); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/include/linux/fs.h b/include/linux/fs.h index a3691c132b3a..de2577df30ae 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *new_inode_current_time(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); -- 2.25.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39194C54FC9 for ; Tue, 21 Apr 2020 14:22:05 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF4C920663 for ; Tue, 21 Apr 2020 14:22:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KR66Rt/t"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KR66Rt/t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF4C920663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4965Np0HrxzDqG0 for ; Wed, 22 Apr 2020 00:22:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=207.211.31.81; helo=us-smtp-delivery-1.mimecast.com; envelope-from=eesposit@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KR66Rt/t; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KR66Rt/t; dkim-atps=neutral Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4964ry3VxQzDqBN for ; Tue, 21 Apr 2020 23:57:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587477471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OKUiLQ5ZuIL+bTIy/EMQv4vQmlAvPOSAZZePSFtw9GI=; b=KR66Rt/t7U6yoA7tkgtD9q54H5bh4pGjE+hd/Yye7mRbGiEvXmnjKHtvzgB/GEt2XEnwkl qra/P3GFh6hiPBse5aX1AlzvbKskcvKq+v+A22ONWvCvFYBrBfwfKl/0KQKNbnm1nMonyH wgFk/a5gU8if61Vm1wrQ0Add1Zb11sM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587477471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OKUiLQ5ZuIL+bTIy/EMQv4vQmlAvPOSAZZePSFtw9GI=; b=KR66Rt/t7U6yoA7tkgtD9q54H5bh4pGjE+hd/Yye7mRbGiEvXmnjKHtvzgB/GEt2XEnwkl qra/P3GFh6hiPBse5aX1AlzvbKskcvKq+v+A22ONWvCvFYBrBfwfKl/0KQKNbnm1nMonyH wgFk/a5gU8if61Vm1wrQ0Add1Zb11sM= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-IKJz4ZgEM_KlJVYkqM37cA-1; Tue, 21 Apr 2020 09:57:47 -0400 X-MC-Unique: IKJz4ZgEM_KlJVYkqM37cA-1 Received: by mail-wr1-f71.google.com with SMTP id u4so7538446wrm.13 for ; Tue, 21 Apr 2020 06:57:47 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=2wRD9FPTWKMzxCyWJGhqpm27rg8NjVNjjKx55UL7gOU=; b=evcf2IT2wGDdKf2qHxE+sPwHyc+m0HdoujE30odRtw0272P88W92HZQMYxHksUjj+G bUVa7rmWdeVzKi2oWyM2XzDisd7ZyQhQKGfpm6BeV3JNpTFfuaHRDq3kvTclpNS18OAZ YTb7jNPx3WKSGXQYTYbOAW0ENgjaKeZgN1eKhNz57Iss3lHBNPzHo57kgN6ENeccjEtb /+NTwXqb3yT8oaDgR4Yyf4ej+22sGWXceeokb2ywUDf+aSTEL2vyp2SWmZNFaO98gjwW 5De9USiyj5SA1W2d7NOCVTZGPJUD6xCPOxJcfjI0zJ0hAMgCUO6LApjNn7vvOC7+kZjB GLjA== X-Gm-Message-State: AGi0PuYvZeiBSRf3lUQB4hH9ab0esLG76JFSAhMEQqZQosLr2t6PHd5b dgi3PtUst8jq8aE0HkdrPucEMJeIYIuuM31dfrxjTUAAIwze8s8Am0FV0cX4Q3yTqhGmfIuQmeT cdWGNsR2whuhZbHyULV2Gp1E9Aw== X-Received: by 2002:a7b:cb17:: with SMTP id u23mr4993965wmj.130.1587477466572; Tue, 21 Apr 2020 06:57:46 -0700 (PDT) X-Google-Smtp-Source: APiQypIdMbj9yLvuLA4LwwjCRX8ejEQ6n8RjZ/wI7HQOlXPSbSe/l8j+NErdfsIjBeaz5nCZl4whdg== X-Received: by 2002:a7b:cb17:: with SMTP id u23mr4993944wmj.130.1587477466378; Tue, 21 Apr 2020 06:57:46 -0700 (PDT) Received: from localhost.localdomain.com ([194.230.155.194]) by smtp.gmail.com with ESMTPSA id f23sm3562989wml.4.2020.04.21.06.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:57:45 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-fsdevel@vger.kernel.org Subject: [PATCH v2 3/7] libfs: introduce new_inode_current_time Date: Tue, 21 Apr 2020 15:57:37 +0200 Message-Id: <20200421135741.30657-1-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com> References: <20200421135119.30007-1-eesposit@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , David Airlie , dri-devel@lists.freedesktop.org, Christoph Hellwig , Andrew Donnellan , Emanuele Giuseppe Esposito , linux-scsi@vger.kernel.org, James Morris , "Serge E. Hallyn" , Daniel Vetter , Arnd Bergmann , "James E.J. Bottomley" , Maarten Lankhorst , Maxime Ripard , "Manoj N. Kumar" , Alexander Viro , "Matthew R. Ochs" , Uma Krishnan , John Johansen , "Martin K. Petersen" , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Thomas Zimmermann , Frederic Barrat , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org, Joel Becker Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it. Signed-off-by: Emanuele Giuseppe Esposito --- fs/libfs.c | 20 ++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 21 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 54e07ae986ca..3fa0cd27ab06 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -594,6 +594,26 @@ int simple_write_end(struct file *file, struct address= _space *mapping, } EXPORT_SYMBOL(simple_write_end); =20 +/** + * new_inode_current_time - create new inode by initializing the + * time to the current time and the inode to get_next_ino() + * @sb: pointer to super block of the file system + * + * Returns an inode pointer on success, NULL on failure. + */ +struct inode *new_inode_current_time(struct super_block *sb) +{ +=09struct inode *inode =3D new_inode(sb); + +=09if (inode) { +=09=09inode->i_ino =3D get_next_ino(); +=09=09inode->i_atime =3D inode->i_mtime =3D +=09=09=09inode->i_ctime =3D current_time(inode); +=09} +=09return inode; +} +EXPORT_SYMBOL(new_inode_current_time); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/include/linux/fs.h b/include/linux/fs.h index a3691c132b3a..de2577df30ae 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *new_inode_current_time(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); --=20 2.25.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AD81C54FCC for ; Tue, 21 Apr 2020 13:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF81920736 for ; Tue, 21 Apr 2020 13:57:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MEoI1U4F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF81920736 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DAB16E989; Tue, 21 Apr 2020 13:57:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id D970F6E988 for ; Tue, 21 Apr 2020 13:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587477469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OKUiLQ5ZuIL+bTIy/EMQv4vQmlAvPOSAZZePSFtw9GI=; b=MEoI1U4FWZaWi7JAP7sRYwBFyAC0oLu1lXtnX3asJautGTnWuF9OnRB6IHUI3lWi/9Z5QK YgsOcY+XGBYfqQwfa/L6Z1Qn+xJu5C6U3X7ZcMcN1KeOiWj5tWWCG7+z1CrBxfDLJX/9qA njdSpaKcKkLjQwKvGVuEegBz10BVdvo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-p-ZJiexhNDmfPpvK-kIr6Q-1; Tue, 21 Apr 2020 09:57:47 -0400 X-MC-Unique: p-ZJiexhNDmfPpvK-kIr6Q-1 Received: by mail-wr1-f70.google.com with SMTP id p16so7522856wro.16 for ; Tue, 21 Apr 2020 06:57:47 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=2wRD9FPTWKMzxCyWJGhqpm27rg8NjVNjjKx55UL7gOU=; b=HE8HM11u+jBhYdk7ebooNzaOsBnn6ImLSnNOJ8ffCPzRq9qT+7rmLYI0oSZXBXuvWD ZrOcRHKRhVaSaahaBFjRt5Jf2vTwc2FlUmG57tHlXl61/Fv4gXj/99VgPgOcvPb+XeRC vddTAR4z1t77WchmRchqKkQJa7KAgRajgQwBhJ/nWkAGKStoitrk3SBbI5p9KrHhxmBr O9j4R1z0nNEa2so7rRyRwbjKn7B6jXDY5dfUvYMcy3TFw5QyHx8kzwH7sYaJFjK+Nu0J JGQzf8/T2wcrF4Vzg6caBdq/dS6gJJdYVx58Q6CKiDp5OxI/Tc8xQkTVk6513GLmEUzG d/Hw== X-Gm-Message-State: AGi0PuYHhe6bGyw7SrBu9KeqhAYWuJ/HRKEDwbvq8TNU0lgBVhuOIZCI NCl/mdvgE9TpLaVz5BIqU/N/OJk/BLfakf68ga+M1PwmkGZE35dyv28pZOAJBRin59KWty3Z3OJ bAfi966DdbW0RGmcoCL8bTWKKAIDm X-Received: by 2002:a7b:cb17:: with SMTP id u23mr4993975wmj.130.1587477466574; Tue, 21 Apr 2020 06:57:46 -0700 (PDT) X-Google-Smtp-Source: APiQypIdMbj9yLvuLA4LwwjCRX8ejEQ6n8RjZ/wI7HQOlXPSbSe/l8j+NErdfsIjBeaz5nCZl4whdg== X-Received: by 2002:a7b:cb17:: with SMTP id u23mr4993944wmj.130.1587477466378; Tue, 21 Apr 2020 06:57:46 -0700 (PDT) Received: from localhost.localdomain.com ([194.230.155.194]) by smtp.gmail.com with ESMTPSA id f23sm3562989wml.4.2020.04.21.06.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 06:57:45 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-fsdevel@vger.kernel.org Subject: [PATCH v2 3/7] libfs: introduce new_inode_current_time Date: Tue, 21 Apr 2020 15:57:37 +0200 Message-Id: <20200421135741.30657-1-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com> References: <20200421135119.30007-1-eesposit@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , David Airlie , dri-devel@lists.freedesktop.org, Christoph Hellwig , Andrew Donnellan , Emanuele Giuseppe Esposito , linux-scsi@vger.kernel.org, James Morris , "Serge E. Hallyn" , Arnd Bergmann , "James E.J. Bottomley" , "Manoj N. Kumar" , Alexander Viro , "Matthew R. Ochs" , Uma Krishnan , John Johansen , "Martin K. Petersen" , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Thomas Zimmermann , Frederic Barrat , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org, Joel Becker Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it. Signed-off-by: Emanuele Giuseppe Esposito --- fs/libfs.c | 20 ++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 21 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 54e07ae986ca..3fa0cd27ab06 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -594,6 +594,26 @@ int simple_write_end(struct file *file, struct address_space *mapping, } EXPORT_SYMBOL(simple_write_end); +/** + * new_inode_current_time - create new inode by initializing the + * time to the current time and the inode to get_next_ino() + * @sb: pointer to super block of the file system + * + * Returns an inode pointer on success, NULL on failure. + */ +struct inode *new_inode_current_time(struct super_block *sb) +{ + struct inode *inode = new_inode(sb); + + if (inode) { + inode->i_ino = get_next_ino(); + inode->i_atime = inode->i_mtime = + inode->i_ctime = current_time(inode); + } + return inode; +} +EXPORT_SYMBOL(new_inode_current_time); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/include/linux/fs.h b/include/linux/fs.h index a3691c132b3a..de2577df30ae 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *new_inode_current_time(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); -- 2.25.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel