* [f2fs-dev] [PATCH] mkfs.f2fs: add -r (fake_seed) flag
@ 2020-08-18 11:18 Theotime Combes via Linux-f2fs-devel
2020-08-19 1:44 ` Chao Yu
0 siblings, 1 reply; 4+ messages in thread
From: Theotime Combes via Linux-f2fs-devel @ 2020-08-18 11:18 UTC (permalink / raw)
To: linux-f2fs-devel
r flag sets the checkpointing seed to 0 (initially used to
remove randomness for apex generation)
Signed-off-by: Theotime Combes <tcombes@google.com>
---
include/f2fs_fs.h | 1 +
man/mkfs.f2fs.8 | 6 ++++++
mkfs/f2fs_format.c | 2 +-
mkfs/f2fs_format_main.c | 6 +++++-
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index a9982f0..e6f996b 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -407,6 +407,7 @@ struct f2fs_configuration {
__le32 feature; /* defined features */
/* mkfs parameters */
+ int fake_seed;
u_int32_t next_free_nid;
u_int32_t quota_inum;
u_int32_t quota_dnum;
diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8
index 022941f..d517165 100644
--- a/man/mkfs.f2fs.8
+++ b/man/mkfs.f2fs.8
@@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system
.B \-q
]
[
+.B \-r
+]
+[
.B \-R
.I root_owner
]
@@ -212,6 +215,9 @@ Default is disabled.
Quiet mode.
With it, mkfs.f2fs does not show any messages, including the basic messages.
.TP
+.BI \-r
+Sets the checkpointing srand seed to 0.
+.TP
.BI \-R
Give root_owner option for initial uid/gid assignment.
Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 1639752..d31cca4 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void)
}
/* 1. cp page 1 of checkpoint pack 1 */
- srand(time(NULL));
+ srand((c.fake_seed) ? 0 : time(NULL));
cp->checkpoint_ver = cpu_to_le64(rand() | 0x1);
set_cp(cur_node_segno[0], c.cur_seg[CURSEG_HOT_NODE]);
set_cp(cur_node_segno[1], c.cur_seg[CURSEG_WARM_NODE]);
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 27c1f1d..ac9d8c8 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -59,6 +59,7 @@ static void mkfs_usage()
MSG(0, " -C [encoding[:flag1,...]] Support casefolding with optional flags\n");
MSG(0, " -p number of pinned segments (2MB) [default:0]\n");
MSG(0, " -q quiet mode\n");
+ MSG(0, " -r set checkpointing seed (srand()) to 0\n");
MSG(0, " -R root_owner [default: 0:0]\n");
MSG(0, " -s # of segments per section [default:1]\n");
MSG(0, " -S sparse mode\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:rR:s:S:z:t:U:Vfw:";
int32_t option=0;
int val;
char *token;
@@ -187,6 +188,9 @@ static void f2fs_parse_options(int argc, char *argv[])
case 'p':
c.pinned_segments = atof(optarg);
break;
+ case 'r':
+ c.fake_seed = 1;
+ break;
case 'R':
if (parse_root_owner(optarg, &c.root_uid, &c.root_gid))
mkfs_usage();
--
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] 4+ messages in thread
* Re: [f2fs-dev] [PATCH] mkfs.f2fs: add -r (fake_seed) flag
2020-08-18 11:18 [f2fs-dev] [PATCH] mkfs.f2fs: add -r (fake_seed) flag Theotime Combes via Linux-f2fs-devel
@ 2020-08-19 1:44 ` Chao Yu
2020-08-19 8:49 ` Theotime Combes via Linux-f2fs-devel
0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2020-08-19 1:44 UTC (permalink / raw)
To: Theotime Combes, linux-f2fs-devel
Hi Theotime,
The implementation looks clean to me, but could you please describe more
about what the problem will be caused by randomness for apex generation?
On 2020/8/18 19:18, Theotime Combes via Linux-f2fs-devel wrote:
> r flag sets the checkpointing seed to 0 (initially used to
> remove randomness for apex generation)
>
> Signed-off-by: Theotime Combes <tcombes@google.com>
> ---
> include/f2fs_fs.h | 1 +
> man/mkfs.f2fs.8 | 6 ++++++
> mkfs/f2fs_format.c | 2 +-
> mkfs/f2fs_format_main.c | 6 +++++-
> 4 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index a9982f0..e6f996b 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -407,6 +407,7 @@ struct f2fs_configuration {
> __le32 feature; /* defined features */
>
> /* mkfs parameters */
> + int fake_seed;
> u_int32_t next_free_nid;
> u_int32_t quota_inum;
> u_int32_t quota_dnum;
> diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8
> index 022941f..d517165 100644
> --- a/man/mkfs.f2fs.8
> +++ b/man/mkfs.f2fs.8
> @@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system
> .B \-q
> ]
> [
> +.B \-r
> +]
> +[
> .B \-R
> .I root_owner
> ]
> @@ -212,6 +215,9 @@ Default is disabled.
> Quiet mode.
> With it, mkfs.f2fs does not show any messages, including the basic messages.
> .TP
> +.BI \-r
> +Sets the checkpointing srand seed to 0.
> +.TP
> .BI \-R
> Give root_owner option for initial uid/gid assignment.
> Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> index 1639752..d31cca4 100644
> --- a/mkfs/f2fs_format.c
> +++ b/mkfs/f2fs_format.c
> @@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void)
> }
>
> /* 1. cp page 1 of checkpoint pack 1 */
> - srand(time(NULL));
> + srand((c.fake_seed) ? 0 : time(NULL));
> cp->checkpoint_ver = cpu_to_le64(rand() | 0x1);
> set_cp(cur_node_segno[0], c.cur_seg[CURSEG_HOT_NODE]);
> set_cp(cur_node_segno[1], c.cur_seg[CURSEG_WARM_NODE]);
> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
> index 27c1f1d..ac9d8c8 100644
> --- a/mkfs/f2fs_format_main.c
> +++ b/mkfs/f2fs_format_main.c
> @@ -59,6 +59,7 @@ static void mkfs_usage()
> MSG(0, " -C [encoding[:flag1,...]] Support casefolding with optional flags\n");
> MSG(0, " -p number of pinned segments (2MB) [default:0]\n");
> MSG(0, " -q quiet mode\n");
> + MSG(0, " -r set checkpointing seed (srand()) to 0\n");
> MSG(0, " -R root_owner [default: 0:0]\n");
> MSG(0, " -s # of segments per section [default:1]\n");
> MSG(0, " -S sparse mode\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:rR:s:S:z:t:U:Vfw:";
> int32_t option=0;
> int val;
> char *token;
> @@ -187,6 +188,9 @@ static void f2fs_parse_options(int argc, char *argv[])
> case 'p':
> c.pinned_segments = atof(optarg);
> break;
> + case 'r':
> + c.fake_seed = 1;
> + break;
> case 'R':
> if (parse_root_owner(optarg, &c.root_uid, &c.root_gid))
> mkfs_usage();
>
_______________________________________________
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] 4+ messages in thread
* Re: [f2fs-dev] [PATCH] mkfs.f2fs: add -r (fake_seed) flag
2020-08-19 1:44 ` Chao Yu
@ 2020-08-19 8:49 ` Theotime Combes via Linux-f2fs-devel
2020-08-19 9:45 ` Chao Yu
0 siblings, 1 reply; 4+ messages in thread
From: Theotime Combes via Linux-f2fs-devel @ 2020-08-19 8:49 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel
On Wed, Aug 19, 2020 at 3:44 AM Chao Yu <yuchao0@huawei.com> wrote:
>
> Hi Theotime,
>
> The implementation looks clean to me, but could you please describe more
> about what the problem will be caused by randomness for apex generation?
>
Hi Chao,
We are adding F2FS support for apex_payload.img (read-only filesystem;
https://source.android.com/devices/tech/ota/apex).
It is necessary for the APEX workflow to have a deterministic output
at generation time (i.e: given the same set of input files, we need to
have the exact same payload regardless of the time of creation).
Fixing the seed is part of solving this problem!
I hope that it makes sense.
> On 2020/8/18 19:18, Theotime Combes via Linux-f2fs-devel wrote:
> > r flag sets the checkpointing seed to 0 (initially used to
> > remove randomness for apex generation)
> >
> > Signed-off-by: Theotime Combes <tcombes@google.com>
> > ---
> > include/f2fs_fs.h | 1 +
> > man/mkfs.f2fs.8 | 6 ++++++
> > mkfs/f2fs_format.c | 2 +-
> > mkfs/f2fs_format_main.c | 6 +++++-
> > 4 files changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> > index a9982f0..e6f996b 100644
> > --- a/include/f2fs_fs.h
> > +++ b/include/f2fs_fs.h
> > @@ -407,6 +407,7 @@ struct f2fs_configuration {
> > __le32 feature; /* defined features */
> >
> > /* mkfs parameters */
> > + int fake_seed;
> > u_int32_t next_free_nid;
> > u_int32_t quota_inum;
> > u_int32_t quota_dnum;
> > diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8
> > index 022941f..d517165 100644
> > --- a/man/mkfs.f2fs.8
> > +++ b/man/mkfs.f2fs.8
> > @@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system
> > .B \-q
> > ]
> > [
> > +.B \-r
> > +]
> > +[
> > .B \-R
> > .I root_owner
> > ]
> > @@ -212,6 +215,9 @@ Default is disabled.
> > Quiet mode.
> > With it, mkfs.f2fs does not show any messages, including the basic messages.
> > .TP
> > +.BI \-r
> > +Sets the checkpointing srand seed to 0.
> > +.TP
> > .BI \-R
> > Give root_owner option for initial uid/gid assignment.
> > Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
> > diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
> > index 1639752..d31cca4 100644
> > --- a/mkfs/f2fs_format.c
> > +++ b/mkfs/f2fs_format.c
> > @@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void)
> > }
> >
> > /* 1. cp page 1 of checkpoint pack 1 */
> > - srand(time(NULL));
> > + srand((c.fake_seed) ? 0 : time(NULL));
> > cp->checkpoint_ver = cpu_to_le64(rand() | 0x1);
> > set_cp(cur_node_segno[0], c.cur_seg[CURSEG_HOT_NODE]);
> > set_cp(cur_node_segno[1], c.cur_seg[CURSEG_WARM_NODE]);
> > diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
> > index 27c1f1d..ac9d8c8 100644
> > --- a/mkfs/f2fs_format_main.c
> > +++ b/mkfs/f2fs_format_main.c
> > @@ -59,6 +59,7 @@ static void mkfs_usage()
> > MSG(0, " -C [encoding[:flag1,...]] Support casefolding with optional flags\n");
> > MSG(0, " -p number of pinned segments (2MB) [default:0]\n");
> > MSG(0, " -q quiet mode\n");
> > + MSG(0, " -r set checkpointing seed (srand()) to 0\n");
> > MSG(0, " -R root_owner [default: 0:0]\n");
> > MSG(0, " -s # of segments per section [default:1]\n");
> > MSG(0, " -S sparse mode\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:rR:s:S:z:t:U:Vfw:";
> > int32_t option=0;
> > int val;
> > char *token;
> > @@ -187,6 +188,9 @@ static void f2fs_parse_options(int argc, char *argv[])
> > case 'p':
> > c.pinned_segments = atof(optarg);
> > break;
> > + case 'r':
> > + c.fake_seed = 1;
> > + break;
> > case 'R':
> > if (parse_root_owner(optarg, &c.root_uid, &c.root_gid))
> > mkfs_usage();
> >
_______________________________________________
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] 4+ messages in thread
* Re: [f2fs-dev] [PATCH] mkfs.f2fs: add -r (fake_seed) flag
2020-08-19 8:49 ` Theotime Combes via Linux-f2fs-devel
@ 2020-08-19 9:45 ` Chao Yu
0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2020-08-19 9:45 UTC (permalink / raw)
To: Theotime Combes; +Cc: linux-f2fs-devel
On 2020/8/19 16:49, Theotime Combes wrote:
> On Wed, Aug 19, 2020 at 3:44 AM Chao Yu <yuchao0@huawei.com> wrote:
>>
>> Hi Theotime,
>>
>> The implementation looks clean to me, but could you please describe more
>> about what the problem will be caused by randomness for apex generation?
>>
>
> Hi Chao,
> We are adding F2FS support for apex_payload.img (read-only filesystem;
> https://source.android.com/devices/tech/ota/apex).
> It is necessary for the APEX workflow to have a deterministic output
Ah, I got it, the purpose is to get rid of random bits in apex image
during its initialization.
Thanks for the explanation. :)
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
> at generation time (i.e: given the same set of input files, we need to
> have the exact same payload regardless of the time of creation).
> Fixing the seed is part of solving this problem!
> I hope that it makes sense.
>
>> On 2020/8/18 19:18, Theotime Combes via Linux-f2fs-devel wrote:
>>> r flag sets the checkpointing seed to 0 (initially used to
>>> remove randomness for apex generation)
>>>
>>> Signed-off-by: Theotime Combes <tcombes@google.com>
>>> ---
>>> include/f2fs_fs.h | 1 +
>>> man/mkfs.f2fs.8 | 6 ++++++
>>> mkfs/f2fs_format.c | 2 +-
>>> mkfs/f2fs_format_main.c | 6 +++++-
>>> 4 files changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
>>> index a9982f0..e6f996b 100644
>>> --- a/include/f2fs_fs.h
>>> +++ b/include/f2fs_fs.h
>>> @@ -407,6 +407,7 @@ struct f2fs_configuration {
>>> __le32 feature; /* defined features */
>>>
>>> /* mkfs parameters */
>>> + int fake_seed;
>>> u_int32_t next_free_nid;
>>> u_int32_t quota_inum;
>>> u_int32_t quota_dnum;
>>> diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8
>>> index 022941f..d517165 100644
>>> --- a/man/mkfs.f2fs.8
>>> +++ b/man/mkfs.f2fs.8
>>> @@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system
>>> .B \-q
>>> ]
>>> [
>>> +.B \-r
>>> +]
>>> +[
>>> .B \-R
>>> .I root_owner
>>> ]
>>> @@ -212,6 +215,9 @@ Default is disabled.
>>> Quiet mode.
>>> With it, mkfs.f2fs does not show any messages, including the basic messages.
>>> .TP
>>> +.BI \-r
>>> +Sets the checkpointing srand seed to 0.
>>> +.TP
>>> .BI \-R
>>> Give root_owner option for initial uid/gid assignment.
>>> Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
>>> diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
>>> index 1639752..d31cca4 100644
>>> --- a/mkfs/f2fs_format.c
>>> +++ b/mkfs/f2fs_format.c
>>> @@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void)
>>> }
>>>
>>> /* 1. cp page 1 of checkpoint pack 1 */
>>> - srand(time(NULL));
>>> + srand((c.fake_seed) ? 0 : time(NULL));
>>> cp->checkpoint_ver = cpu_to_le64(rand() | 0x1);
>>> set_cp(cur_node_segno[0], c.cur_seg[CURSEG_HOT_NODE]);
>>> set_cp(cur_node_segno[1], c.cur_seg[CURSEG_WARM_NODE]);
>>> diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
>>> index 27c1f1d..ac9d8c8 100644
>>> --- a/mkfs/f2fs_format_main.c
>>> +++ b/mkfs/f2fs_format_main.c
>>> @@ -59,6 +59,7 @@ static void mkfs_usage()
>>> MSG(0, " -C [encoding[:flag1,...]] Support casefolding with optional flags\n");
>>> MSG(0, " -p number of pinned segments (2MB) [default:0]\n");
>>> MSG(0, " -q quiet mode\n");
>>> + MSG(0, " -r set checkpointing seed (srand()) to 0\n");
>>> MSG(0, " -R root_owner [default: 0:0]\n");
>>> MSG(0, " -s # of segments per section [default:1]\n");
>>> MSG(0, " -S sparse mode\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:rR:s:S:z:t:U:Vfw:";
>>> int32_t option=0;
>>> int val;
>>> char *token;
>>> @@ -187,6 +188,9 @@ static void f2fs_parse_options(int argc, char *argv[])
>>> case 'p':
>>> c.pinned_segments = atof(optarg);
>>> break;
>>> + case 'r':
>>> + c.fake_seed = 1;
>>> + break;
>>> case 'R':
>>> if (parse_root_owner(optarg, &c.root_uid, &c.root_gid))
>>> mkfs_usage();
>>>
> .
>
_______________________________________________
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] 4+ messages in thread
end of thread, other threads:[~2020-08-19 9:45 UTC | newest]
Thread overview: 4+ 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 -r (fake_seed) flag Theotime Combes via Linux-f2fs-devel
2020-08-19 1:44 ` Chao Yu
2020-08-19 8:49 ` Theotime Combes via Linux-f2fs-devel
2020-08-19 9:45 ` Chao Yu
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.