All of lore.kernel.org
 help / color / mirror / Atom feed
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	Uma Krishnan <ukrishn@linux.ibm.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Joel Becker <jlbec@evilplan.org>, Christoph Hellwig <hch@lst.de>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	John Johansen <john.johansen@canonical.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	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 <pbonzini@redhat.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>
Subject: [PATCH v2 3/7] libfs: introduce new_inode_current_time
Date: Tue, 21 Apr 2020 15:57:37 +0200	[thread overview]
Message-ID: <20200421135741.30657-1-eesposit@redhat.com> (raw)
In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com>

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 <eesposit@redhat.com>
---
 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


WARNING: multiple messages have this Message-ID (diff)
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, Christoph Hellwig <hch@lst.de>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	linux-scsi@vger.kernel.org, James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Daniel Vetter <daniel@ffwll.ch>, Arnd Bergmann <arnd@arndb.de>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	Uma Krishnan <ukrishn@linux.ibm.com>,
	John Johansen <john.johansen@canonical.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	linuxppc-dev@lists.ozlabs.org, Joel Becker <jlbec@evilplan.org>
Subject: [PATCH v2 3/7] libfs: introduce new_inode_current_time
Date: Tue, 21 Apr 2020 15:57:37 +0200	[thread overview]
Message-ID: <20200421135741.30657-1-eesposit@redhat.com> (raw)
In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com>

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 <eesposit@redhat.com>
---
 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


WARNING: multiple messages have this Message-ID (diff)
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, Christoph Hellwig <hch@lst.de>,
	Andrew Donnellan <ajd@linux.ibm.com>,
	Emanuele Giuseppe Esposito <eesposit@redhat.com>,
	linux-scsi@vger.kernel.org, James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Arnd Bergmann <arnd@arndb.de>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Manoj N. Kumar" <manoj@linux.ibm.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	"Matthew R. Ochs" <mrochs@linux.ibm.com>,
	Uma Krishnan <ukrishn@linux.ibm.com>,
	John Johansen <john.johansen@canonical.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Frederic Barrat <fbarrat@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	linuxppc-dev@lists.ozlabs.org, Joel Becker <jlbec@evilplan.org>
Subject: [PATCH v2 3/7] libfs: introduce new_inode_current_time
Date: Tue, 21 Apr 2020 15:57:37 +0200	[thread overview]
Message-ID: <20200421135741.30657-1-eesposit@redhat.com> (raw)
In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com>

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 <eesposit@redhat.com>
---
 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

  parent reply	other threads:[~2020-04-21 13:58 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 13:51 [PATCH v2 0/7] libfs: group and simplify linux fs code Emanuele Giuseppe Esposito
2020-04-21 13:51 ` Emanuele Giuseppe Esposito
2020-04-21 13:51 ` Emanuele Giuseppe Esposito
2020-04-21 13:51 ` [PATCH v2 1/7] apparmor: just use vfs_kern_mount to make .null Emanuele Giuseppe Esposito
2020-04-21 13:51   ` Emanuele Giuseppe Esposito
2020-04-21 13:51   ` Emanuele Giuseppe Esposito
2020-04-21 13:51 ` [PATCH v2 2/7] libfs: wrap simple_pin_fs/simple_release_fs arguments in a struct Emanuele Giuseppe Esposito
2020-04-21 13:51   ` Emanuele Giuseppe Esposito
2020-04-21 13:51   ` Emanuele Giuseppe Esposito
2020-04-22 16:50   ` James Morris
2020-04-22 16:50     ` James Morris
2020-04-22 16:50     ` James Morris
2020-04-21 13:57 ` Emanuele Giuseppe Esposito [this message]
2020-04-21 13:57   ` [PATCH v2 3/7] libfs: introduce new_inode_current_time Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-21 13:57 ` [PATCH v2 4/7] libfs: add alloc_anon_inode wrapper Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-21 13:57 ` [PATCH v2 5/7] libfs: add file creation functions Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-21 13:57 ` [PATCH v2 6/7] debugfs: switch to simplefs inode creation API Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-27 15:15   ` Paolo Bonzini
2020-04-27 15:15     ` Paolo Bonzini
2020-04-27 15:15     ` Paolo Bonzini
2020-04-21 13:57 ` [PATCH v2 7/7] tracefs: " Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito
2020-04-21 13:57   ` Emanuele Giuseppe Esposito

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200421135741.30657-1-eesposit@redhat.com \
    --to=eesposit@redhat.com \
    --cc=airlied@linux.ie \
    --cc=ajd@linux.ibm.com \
    --cc=arnd@arndb.de \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fbarrat@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=jejb@linux.ibm.com \
    --cc=jlbec@evilplan.org \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=manoj@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=mripard@kernel.org \
    --cc=mrochs@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=rafael@kernel.org \
    --cc=serge@hallyn.com \
    --cc=tzimmermann@suse.de \
    --cc=ukrishn@linux.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.