From: Jeff Layton <jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: jk-mnsaURCQ41sdnm+yROfE0A@public.gmane.org,
arnd-r2nGTMty4D4@public.gmane.org,
mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org,
npiggin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
christophe.leroy-2tlSp11Fh4xulxpn9UvDqw@public.gmane.org,
hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
borntraeger-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
svens-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
arve-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
tkjos-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
maco-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
joel-QYYGw3jwrUn5owFQY34kdNi2O/JbrIOy@public.gmane.org,
brauner-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
cmllamas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
surenb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
dennis.dalessandro-ntyVByD3zXaTtA8H5PvdGFaTQe2KTcn/@public.gmane.org,
jgg-uk2M96/98Pc@public.gmane.org,
leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
bwarrum-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
rituagar-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org,
ericvh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
lucho-OnYtXJJ0/fesTnJN9+BGXg@public.gmane.org,
asmadeus-9aU+PIKW3UvdtAWm4Da02A@public.gmane.org,
linux_oss-kKOvUW9iAPtl57MIdRCFDg@public.gmane.org,
dsterba-IBi9RG/b67k@public.gmane.org,
dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
marc.dionne-hRzEac23uH1Wk0Htik3J/w@public.gmane.org,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org,
raven-PKsaG3nR2I+sTnJN9+BGXg@public.gmane.org,
luisbg-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
salah.triki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
aivazian.tigran-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org, kees
Cc: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
Subject: [PATCH v2 07/92] fs: add ctime accessors infrastructure
Date: Wed, 5 Jul 2023 14:58:10 -0400 [thread overview]
Message-ID: <20230705185812.579118-2-jlayton__12880.4860914656$1688583560$gmane$org@kernel.org> (raw)
In-Reply-To: <20230705185812.579118-1-jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
struct timespec64 has unused bits in the tv_nsec field that can be used
for other purposes. In future patches, we're going to change how the
inode->i_ctime is accessed in certain inodes in order to make use of
them. In order to do that safely though, we'll need to eradicate raw
accesses of the inode->i_ctime field from the kernel.
Add new accessor functions for the ctime that we use to replace them.
Reviewed-by: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
Reviewed-by: Luis Chamberlain <mcgrof-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Jeff Layton <jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
fs/inode.c | 16 ++++++++++++++++
include/linux/fs.h | 45 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/fs/inode.c b/fs/inode.c
index d37fad91c8da..21b026d95b51 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2499,6 +2499,22 @@ struct timespec64 current_time(struct inode *inode)
}
EXPORT_SYMBOL(current_time);
+/**
+ * inode_set_ctime_current - set the ctime to current_time
+ * @inode: inode
+ *
+ * Set the inode->i_ctime to the current value for the inode. Returns
+ * the current value that was assigned to i_ctime.
+ */
+struct timespec64 inode_set_ctime_current(struct inode *inode)
+{
+ struct timespec64 now = current_time(inode);
+
+ inode_set_ctime(inode, now.tv_sec, now.tv_nsec);
+ return now;
+}
+EXPORT_SYMBOL(inode_set_ctime_current);
+
/**
* in_group_or_capable - check whether caller is CAP_FSETID privileged
* @idmap: idmap of the mount @inode was found from
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 824accb89a91..bdfbd11a5811 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1474,7 +1474,50 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb,
kgid_has_mapping(fs_userns, kgid);
}
-extern struct timespec64 current_time(struct inode *inode);
+struct timespec64 current_time(struct inode *inode);
+struct timespec64 inode_set_ctime_current(struct inode *inode);
+
+/**
+ * inode_get_ctime - fetch the current ctime from the inode
+ * @inode: inode from which to fetch ctime
+ *
+ * Grab the current ctime from the inode and return it.
+ */
+static inline struct timespec64 inode_get_ctime(const struct inode *inode)
+{
+ return inode->i_ctime;
+}
+
+/**
+ * inode_set_ctime_to_ts - set the ctime in the inode
+ * @inode: inode in which to set the ctime
+ * @ts: value to set in the ctime field
+ *
+ * Set the ctime in @inode to @ts
+ */
+static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
+ struct timespec64 ts)
+{
+ inode->i_ctime = ts;
+ return ts;
+}
+
+/**
+ * inode_set_ctime - set the ctime in the inode
+ * @inode: inode in which to set the ctime
+ * @sec: tv_sec value to set
+ * @nsec: tv_nsec value to set
+ *
+ * Set the ctime in @inode to { @sec, @nsec }
+ */
+static inline struct timespec64 inode_set_ctime(struct inode *inode,
+ time64_t sec, long nsec)
+{
+ struct timespec64 ts = { .tv_sec = sec,
+ .tv_nsec = nsec };
+
+ return inode_set_ctime_to_ts(inode, ts);
+}
/*
* Snapshotting support.
--
2.41.0
next parent reply other threads:[~2023-07-05 18:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230705185812.579118-1-jlayton@kernel.org>
[not found] ` <20230705185812.579118-1-jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2023-07-05 18:58 ` Jeff Layton [this message]
2023-07-05 18:58 ` [PATCH v2 08/92] fs: new helper: simple_rename_timestamp Jeff Layton
2023-07-05 18:58 ` [PATCH v2 92/92] fs: rename i_ctime field to __i_ctime Jeff Layton
2023-07-05 21:57 ` [PATCH v2 00/89] fs: new accessors for inode->i_ctime Jeff Layton
[not found] ` <20230705185812.579118-2-jlayton@kernel.org>
[not found] ` <20230705185812.579118-2-jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2023-07-05 23:12 ` [PATCH v2 07/92] fs: add ctime accessors infrastructure Damien Le Moal
[not found] ` <20230705185812.579118-4-jlayton@kernel.org>
[not found] ` <20230705185812.579118-4-jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2023-07-05 23:19 ` [PATCH v2 92/92] fs: rename i_ctime field to __i_ctime Damien Le Moal
2023-07-06 14:58 ` Jan Kara
[not found] ` <a4e6cfec345487fc9ac8ab814a817c79a61b123a.camel@kernel.org>
[not found] ` <a4e6cfec345487fc9ac8ab814a817c79a61b123a.camel-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2023-07-06 15:16 ` [PATCH v2 00/89] fs: new accessors for inode->i_ctime Eric W. Biederman
2023-07-06 16:14 ` Jeff Layton
2023-07-07 12:42 ` Jeff Layton
2023-07-10 12:35 ` Christian Brauner
2023-07-10 13:32 ` Jeff Layton
2023-07-10 12:18 ` [PATCH v2 00/92] " Christian Brauner
[not found] ` <20230705185812.579118-3-jlayton@kernel.org>
[not found] ` <20230705185812.579118-3-jlayton-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2023-07-05 23:19 ` [PATCH v2 08/92] fs: new helper: simple_rename_timestamp Damien Le Moal
2023-07-06 10:27 ` Jan Kara
[not found] ` <3b403ef1-22e6-0220-6c9c-435e3444b4d3@kernel.org>
[not found] ` <3b403ef1-22e6-0220-6c9c-435e3444b4d3-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2023-07-06 0:04 ` Jeff Layton
[not found] ` <7c783969641b67d6ffdfb10e509f382d083c5291.camel@kernel.org>
2023-07-06 21:02 ` [apparmor] " Seth Arnold
2023-07-07 10:50 ` Jeff Layton
2023-08-30 0:19 ` Al Viro
2023-08-30 0:48 ` Jeff Layton
2023-09-04 18:11 ` [f2fs-dev] [PATCH v2 00/89] fs: new accessors for inode->i_ctime patchwork-bot+f2fs
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='20230705185812.579118-2-jlayton__12880.4860914656$1688583560$gmane$org@kernel.org' \
--to=jlayton-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
--cc=aivazian.tigran-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=arve-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=asmadeus-9aU+PIKW3UvdtAWm4Da02A@public.gmane.org \
--cc=borntraeger-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
--cc=brauner-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=bwarrum-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
--cc=christophe.leroy-2tlSp11Fh4xulxpn9UvDqw@public.gmane.org \
--cc=cmllamas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=dennis.dalessandro-ntyVByD3zXaTtA8H5PvdGFaTQe2KTcn/@public.gmane.org \
--cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=dsterba-IBi9RG/b67k@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=ericvh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
--cc=jack-AlSwsSmVLrQ@public.gmane.org \
--cc=jgg-uk2M96/98Pc@public.gmane.org \
--cc=jk-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
--cc=joel-QYYGw3jwrUn5owFQY34kdNi2O/JbrIOy@public.gmane.org \
--cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux_oss-kKOvUW9iAPtl57MIdRCFDg@public.gmane.org \
--cc=lucho-OnYtXJJ0/fesTnJN9+BGXg@public.gmane.org \
--cc=luisbg-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=maco-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=marc.dionne-hRzEac23uH1Wk0Htik3J/w@public.gmane.org \
--cc=mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org \
--cc=npiggin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=raven-PKsaG3nR2I+sTnJN9+BGXg@public.gmane.org \
--cc=rituagar-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
--cc=salah.triki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=surenb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=svens-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
--cc=tkjos-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).