All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] mkfs.f2fs: add -T flag
@ 2020-08-18 11:18 Theotime Combes via Linux-f2fs-devel
  2020-08-19  1:51 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Theotime Combes via Linux-f2fs-devel @ 2020-08-18 11:18 UTC (permalink / raw)
  To: linux-f2fs-devel

T flag sets timestamps to a given value

Signed-off-by: Theotime Combes <tcombes@google.com>
---
 include/f2fs_fs.h       |  2 +-
 man/mkfs.f2fs.8         |  8 ++++++++
 mkfs/f2fs_format.c      | 25 ++++++++++++++-----------
 mkfs/f2fs_format_main.c |  6 +++++-
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index a9982f0..3750e56 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -405,6 +405,7 @@ struct f2fs_configuration {
 	int large_nat_bitmap;
 	int fix_chksum;			/* fix old cp.chksum position */
 	__le32 feature;			/* defined features */
+	time_t fixed_time;
 
 	/* mkfs parameters */
 	u_int32_t next_free_nid;
@@ -427,7 +428,6 @@ struct f2fs_configuration {
 	char *mount_point;
 	char *target_out_dir;
 	char *fs_config_file;
-	time_t fixed_time;
 #ifdef HAVE_LIBSELINUX
 	struct selinux_opt seopt_file[8];
 	int nr_opt;
diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8
index 022941f..729afdf 100644
--- a/man/mkfs.f2fs.8
+++ b/man/mkfs.f2fs.8
@@ -74,6 +74,10 @@ mkfs.f2fs \- create an F2FS file system
 .I nodiscard/discard
 ]
 [
+.B \-T
+.I timestamp
+]
+[
 .B \-w
 .I wanted-sector-size
 ]
@@ -228,6 +232,10 @@ Enable sparse mode.
 Specify 1 or 0 to enable or disable discard policy, respectively.
 The default value is 1.
 .TP
+.BI \-T " timestamp"
+Set inodes times to a given timestamp. By default, the current time will be used.
+This behaviour corresponds to the value -1.
+.TP
 .BI \-w " wanted-sector-size"
 Specify the sector size in bytes.
 Without it, the sectors will be calculated by device sector size.
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 1639752..7414b00 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -35,6 +35,9 @@ struct f2fs_checkpoint *cp;
 #define last_zone(cur)		((cur - 1) * c.segs_per_zone)
 #define last_section(cur)	(cur + (c.secs_per_zone - 1) * c.segs_per_sec)
 
+/* Return time fixed by the user or current time by default */
+#define mkfs_time ((c.fixed_time == -1) ? time(NULL) : c.fixed_time)
+
 static unsigned int quotatype_bits = 0;
 
 const char *media_ext_lists[] = {
@@ -1192,11 +1195,11 @@ static int f2fs_write_root_inode(void)
 	raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes); /* dentry */
 	raw_node->i.i_blocks = cpu_to_le64(2);
 
-	raw_node->i.i_atime = cpu_to_le32(time(NULL));
+	raw_node->i.i_atime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_atime_nsec = 0;
-	raw_node->i.i_ctime = cpu_to_le32(time(NULL));
+	raw_node->i.i_ctime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_ctime_nsec = 0;
-	raw_node->i.i_mtime = cpu_to_le32(time(NULL));
+	raw_node->i.i_mtime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_mtime_nsec = 0;
 	raw_node->i.i_generation = 0;
 	raw_node->i.i_xattr_nid = 0;
@@ -1213,7 +1216,7 @@ static int f2fs_write_root_inode(void)
 		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
-		raw_node->i.i_crtime = cpu_to_le32(time(NULL));
+		raw_node->i.i_crtime = cpu_to_le32(mkfs_time);
 		raw_node->i.i_crtime_nsec = 0;
 	}
 
@@ -1350,11 +1353,11 @@ static int f2fs_write_qf_inode(int qtype)
 	raw_node->i.i_size = cpu_to_le64(1024 * 6); /* Hard coded */
 	raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype));
 
-	raw_node->i.i_atime = cpu_to_le32(time(NULL));
+	raw_node->i.i_atime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_atime_nsec = 0;
-	raw_node->i.i_ctime = cpu_to_le32(time(NULL));
+	raw_node->i.i_ctime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_ctime_nsec = 0;
-	raw_node->i.i_mtime = cpu_to_le32(time(NULL));
+	raw_node->i.i_mtime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_mtime_nsec = 0;
 	raw_node->i.i_generation = 0;
 	raw_node->i.i_xattr_nid = 0;
@@ -1545,11 +1548,11 @@ static int f2fs_write_lpf_inode(void)
 	raw_node->i.i_size = cpu_to_le64(1 * blk_size_bytes);
 	raw_node->i.i_blocks = cpu_to_le64(2);
 
-	raw_node->i.i_atime = cpu_to_le32(time(NULL));
+	raw_node->i.i_atime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_atime_nsec = 0;
-	raw_node->i.i_ctime = cpu_to_le32(time(NULL));
+	raw_node->i.i_ctime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_ctime_nsec = 0;
-	raw_node->i.i_mtime = cpu_to_le32(time(NULL));
+	raw_node->i.i_mtime = cpu_to_le32(mkfs_time);
 	raw_node->i.i_mtime_nsec = 0;
 	raw_node->i.i_generation = 0;
 	raw_node->i.i_xattr_nid = 0;
@@ -1569,7 +1572,7 @@ static int f2fs_write_lpf_inode(void)
 		raw_node->i.i_projid = cpu_to_le32(F2FS_DEF_PROJID);
 
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CRTIME)) {
-		raw_node->i.i_crtime = cpu_to_le32(time(NULL));
+		raw_node->i.i_crtime = cpu_to_le32(mkfs_time);
 		raw_node->i.i_crtime_nsec = 0;
 	}
 
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 27c1f1d..9433223 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -63,6 +63,7 @@ static void mkfs_usage()
 	MSG(0, "  -s # of segments per section [default:1]\n");
 	MSG(0, "  -S sparse mode\n");
 	MSG(0, "  -t 0: nodiscard, 1: discard [default:1]\n");
+	MSG(0, "  -T timestamps\n");
 	MSG(0, "  -w wanted sector size\n");
 	MSG(0, "  -z # of sections per zone [default:1]\n");
 	MSG(0, "  -V print the version number and exit\n");
@@ -124,7 +125,7 @@ static void add_default_options(void)
 
 static void f2fs_parse_options(int argc, char *argv[])
 {
-	static const char *option_string = "qa:c:C:d:e:E:g:il:mo:O:p:R:s:S:z:t:U:Vfw:";
+	static const char *option_string = "qa:c:C:d:e:E:g:il:mo:O:p:R:s:S:z:t:T:U:Vfw:";
 	int32_t option=0;
 	int val;
 	char *token;
@@ -205,6 +206,9 @@ static void f2fs_parse_options(int argc, char *argv[])
 		case 't':
 			c.trim = atoi(optarg);
 			break;
+		case 'T':
+			c.fixed_time = strtoul(optarg, NULL, 0);
+			break;
 		case 'U':
 			c.vol_uuid = strdup(optarg);
 			break;
-- 
2.28.0.220.ged08abb693-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] mkfs.f2fs: add -T flag
  2020-08-18 11:18 [f2fs-dev] [PATCH] mkfs.f2fs: add -T flag Theotime Combes via Linux-f2fs-devel
@ 2020-08-19  1:51 ` Chao Yu
  2020-08-19  9:00   ` Theotime Combes via Linux-f2fs-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2020-08-19  1:51 UTC (permalink / raw)
  To: Theotime Combes, linux-f2fs-devel

On 2020/8/18 19:18, Theotime Combes via Linux-f2fs-devel wrote:
> T flag sets timestamps to a given value

I'm curious about why do we need to configure timestamp of root/qf/lpf
inode.

> 
> Signed-off-by: Theotime Combes <tcombes@google.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] mkfs.f2fs: add -T flag
  2020-08-19  1:51 ` Chao Yu
@ 2020-08-19  9:00   ` Theotime Combes via Linux-f2fs-devel
  0 siblings, 0 replies; 3+ messages in thread
From: Theotime Combes via Linux-f2fs-devel @ 2020-08-19  9:00 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel

On Wed, Aug 19, 2020 at 3:51 AM Chao Yu <yuchao0@huawei.com> wrote:
>
> On 2020/8/18 19:18, Theotime Combes via Linux-f2fs-devel wrote:
> > T flag sets timestamps to a given value
>
> I'm curious about why do we need to configure timestamp of root/qf/lpf
> inode.
>
Thanks for the review.
It is also for APEX generation (see my reply to the fakeseed thread :)),
we need to have a deterministic output when we generate an apex given
a set of files.
Configuring these timestamps is the other part of solving this problem.

> >
> > Signed-off-by: Theotime Combes <tcombes@google.com>
>
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>
> Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-19  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 11:18 [f2fs-dev] [PATCH] mkfs.f2fs: add -T flag Theotime Combes via Linux-f2fs-devel
2020-08-19  1:51 ` Chao Yu
2020-08-19  9:00   ` Theotime Combes via Linux-f2fs-devel

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.