* [f2fs-dev] [PATCH 0/3] Three f2fs patches @ 2022-06-14 23:17 Bart Van Assche 2022-06-14 23:17 ` [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check Bart Van Assche ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Bart Van Assche @ 2022-06-14 23:17 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel Hi Jaegeuk, This patch series fixes one issue reported by Peter Collingbourne and two issues I discovered by reading the zoned block device source code. Please consider these patches for inclusion in the official f2fs-tools repository. Thanks, Bart. Bart Van Assche (3): Fix the struct f2fs_dentry_block size check Fix f2fs_report_zone() Improve compile-time type checking for f2fs_report_zone() include/f2fs_fs.h | 6 ++++-- lib/libf2fs_zoned.c | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) _______________________________________________ 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] 9+ messages in thread
* [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check 2022-06-14 23:17 [f2fs-dev] [PATCH 0/3] Three f2fs patches Bart Van Assche @ 2022-06-14 23:17 ` Bart Van Assche 2022-06-18 23:41 ` Chao Yu 2022-06-14 23:17 ` [f2fs-dev] [PATCH 2/3] Fix f2fs_report_zone() Bart Van Assche ` (2 subsequent siblings) 3 siblings, 1 reply; 9+ messages in thread From: Bart Van Assche @ 2022-06-14 23:17 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: Peter Collingbourne, Bart Van Assche, linux-f2fs-devel Fix the f2fs-tools build on systems for which PAGE_SIZE != 4096. Cc: Peter Collingbourne <pcc@google.com> Reported-by: Peter Collingbourne <pcc@google.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- include/f2fs_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 21a7e70d952d..3b1bd6eb7dc7 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1341,7 +1341,7 @@ struct f2fs_dentry_block { __u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN]; }; -static_assert(sizeof(struct f2fs_dentry_block) == 4096, ""); +static_assert(sizeof(struct f2fs_dentry_block) == PAGE_SIZE, ""); /* for inline stuff */ #define DEF_INLINE_RESERVED_SIZE 1 _______________________________________________ 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] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check 2022-06-14 23:17 ` [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check Bart Van Assche @ 2022-06-18 23:41 ` Chao Yu [not found] ` <CAMn1gO4=iy7tzvvcx6n5DLBM+V4f9Kj=_U1abRf4Cm8XAL+gCA@mail.gmail.com> 0 siblings, 1 reply; 9+ messages in thread From: Chao Yu @ 2022-06-18 23:41 UTC (permalink / raw) To: Bart Van Assche, Jaegeuk Kim; +Cc: Peter Collingbourne, linux-f2fs-devel On 2022/6/15 7:17, Bart Van Assche wrote: > Fix the f2fs-tools build on systems for which PAGE_SIZE != 4096. > > Cc: Peter Collingbourne <pcc@google.com> > Reported-by: Peter Collingbourne <pcc@google.com> > Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> 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] 9+ messages in thread
[parent not found: <CAMn1gO4=iy7tzvvcx6n5DLBM+V4f9Kj=_U1abRf4Cm8XAL+gCA@mail.gmail.com>]
* Re: [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check [not found] ` <CAMn1gO4=iy7tzvvcx6n5DLBM+V4f9Kj=_U1abRf4Cm8XAL+gCA@mail.gmail.com> @ 2022-06-19 22:12 ` Jaegeuk Kim 0 siblings, 0 replies; 9+ messages in thread From: Jaegeuk Kim @ 2022-06-19 22:12 UTC (permalink / raw) To: Peter Collingbourne; +Cc: Bart Van Assche, linux-f2fs-devel On 06/18, Peter Collingbourne wrote: > On Sat, Jun 18, 2022, 16:41 Chao Yu <chao@kernel.org> wrote: > > > On 2022/6/15 7:17, Bart Van Assche wrote: > > > Fix the f2fs-tools build on systems for which PAGE_SIZE != 4096. > > > > > > Cc: Peter Collingbourne <pcc@google.com> > > > Reported-by: Peter Collingbourne <pcc@google.com> > > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > > > > Reviewed-by: Chao Yu <chao@kernel.org> > > > > I'm not sure if this is the correct fix. From what I was able to figure out > this is actually an on-disk data structure so it needs to be sized the same > way as in the kernel. The kernel implementation of the file system requires > a 4K page size which means that it only makes sense for this to be sized as > if PAGE_SIZE was defined to 4096. It should at least be possible to use > this tool on a non-4K page size kernel to create a file system that can be > read on a 4K page size kernel, so I think the right fix would be to change > the definition of this struct to use F2FS_BLKSIZE (or just hardcode 4096). Yeah, since F2FS support 4KB page size, we need F2FS_BLKSIZE. > > Peter _______________________________________________ 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] 9+ messages in thread
* [f2fs-dev] [PATCH 2/3] Fix f2fs_report_zone() 2022-06-14 23:17 [f2fs-dev] [PATCH 0/3] Three f2fs patches Bart Van Assche 2022-06-14 23:17 ` [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check Bart Van Assche @ 2022-06-14 23:17 ` Bart Van Assche 2022-06-18 23:41 ` Chao Yu 2022-06-14 23:17 ` [f2fs-dev] [PATCH 3/3] Improve compile-time type checking for f2fs_report_zone() Bart Van Assche 2022-06-15 16:58 ` [f2fs-dev] [PATCH 0/3] Three f2fs patches Jaegeuk Kim 3 siblings, 1 reply; 9+ messages in thread From: Bart Van Assche @ 2022-06-14 23:17 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: Shin'ichiro Kawasaki, Bart Van Assche, linux-f2fs-devel The definition of struct blk_zone_report is as follows: struct blk_zone_report { __u64 sector; __u32 nr_zones; __u32 flags; struct blk_zone zones[0]; }; Since f2fs_report_zone() allocates the above data structure with malloc() and since f2fs_report_zone() only initializes the sector and nr_zones members, the flags member is not initialized. Modify f2fs_report_zone() such that 0 is passed as flags to the BLKREPORTZONE ioctl instead of a random value. This has been discovered by reading the source code. Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Fixes: 6d7c7b785feb ("libf2fs_zoned: Introduce f2fs_report_zone() helper function") Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- lib/libf2fs_zoned.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c index f383ce275342..d8de66b82029 100644 --- a/lib/libf2fs_zoned.c +++ b/lib/libf2fs_zoned.c @@ -206,7 +206,8 @@ int f2fs_report_zone(int i, uint64_t sector, void *blkzone) struct blk_zone_report *rep; int ret = -1; - rep = malloc(sizeof(struct blk_zone_report) + sizeof(struct blk_zone)); + rep = calloc(1, sizeof(struct blk_zone_report) + + sizeof(struct blk_zone)); if (!rep) { ERR_MSG("No memory for report zones\n"); return -ENOMEM; _______________________________________________ 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] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 2/3] Fix f2fs_report_zone() 2022-06-14 23:17 ` [f2fs-dev] [PATCH 2/3] Fix f2fs_report_zone() Bart Van Assche @ 2022-06-18 23:41 ` Chao Yu 0 siblings, 0 replies; 9+ messages in thread From: Chao Yu @ 2022-06-18 23:41 UTC (permalink / raw) To: Bart Van Assche, Jaegeuk Kim; +Cc: Shin'ichiro Kawasaki, linux-f2fs-devel On 2022/6/15 7:17, Bart Van Assche wrote: > The definition of struct blk_zone_report is as follows: > > struct blk_zone_report { > __u64 sector; > __u32 nr_zones; > __u32 flags; > struct blk_zone zones[0]; > }; > > Since f2fs_report_zone() allocates the above data structure with > malloc() and since f2fs_report_zone() only initializes the sector and > nr_zones members, the flags member is not initialized. Modify > f2fs_report_zone() such that 0 is passed as flags to the > BLKREPORTZONE ioctl instead of a random value. This has been > discovered by reading the source code. > > Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> > Fixes: 6d7c7b785feb ("libf2fs_zoned: Introduce f2fs_report_zone() helper function") > Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> 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] 9+ messages in thread
* [f2fs-dev] [PATCH 3/3] Improve compile-time type checking for f2fs_report_zone() 2022-06-14 23:17 [f2fs-dev] [PATCH 0/3] Three f2fs patches Bart Van Assche 2022-06-14 23:17 ` [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check Bart Van Assche 2022-06-14 23:17 ` [f2fs-dev] [PATCH 2/3] Fix f2fs_report_zone() Bart Van Assche @ 2022-06-14 23:17 ` Bart Van Assche 2022-06-18 23:42 ` Chao Yu 2022-06-15 16:58 ` [f2fs-dev] [PATCH 0/3] Three f2fs patches Jaegeuk Kim 3 siblings, 1 reply; 9+ messages in thread From: Bart Van Assche @ 2022-06-14 23:17 UTC (permalink / raw) To: Jaegeuk Kim; +Cc: Bart Van Assche, linux-f2fs-devel Change the type of the third argument of f2fs_report_zone() from void * into struct blk_zone * to enable type checking. Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- include/f2fs_fs.h | 4 +++- lib/libf2fs_zoned.c | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 3b1bd6eb7dc7..2dbb56967676 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1560,9 +1560,11 @@ blk_zone_cond_str(struct blk_zone *blkz) #endif +struct blk_zone; + extern int f2fs_get_zoned_model(int); extern int f2fs_get_zone_blocks(int); -extern int f2fs_report_zone(int, uint64_t, void *); +extern int f2fs_report_zone(int, uint64_t, struct blk_zone *); typedef int (report_zones_cb_t)(int i, void *, void *); extern int f2fs_report_zones(int, report_zones_cb_t *, void *); extern int f2fs_check_zones(int); diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c index d8de66b82029..f0df15220d56 100644 --- a/lib/libf2fs_zoned.c +++ b/lib/libf2fs_zoned.c @@ -200,21 +200,24 @@ int f2fs_get_zone_blocks(int i) return 0; } -int f2fs_report_zone(int i, uint64_t sector, void *blkzone) +int f2fs_report_zone(int i, uint64_t sector, struct blk_zone *blkzone) { - struct blk_zone *blkz = (struct blk_zone *)blkzone; - struct blk_zone_report *rep; + struct one_zone_report { + struct blk_zone_report rep; + struct blk_zone zone; + } *rep; int ret = -1; - rep = calloc(1, sizeof(struct blk_zone_report) + - sizeof(struct blk_zone)); + rep = calloc(1, sizeof(*rep)); if (!rep) { ERR_MSG("No memory for report zones\n"); return -ENOMEM; } - rep->sector = sector; - rep->nr_zones = 1; + rep->rep = (struct blk_zone_report){ + .sector = sector, + .nr_zones = 1, + }; ret = ioctl(c.devices[i].fd, BLKREPORTZONE, rep); if (ret != 0) { ret = -errno; @@ -222,7 +225,7 @@ int f2fs_report_zone(int i, uint64_t sector, void *blkzone) goto out; } - *blkz = *(struct blk_zone *)(rep + 1); + *blkzone = rep->zone; out: free(rep); return ret; @@ -531,7 +534,8 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb) #else -int f2fs_report_zone(int i, uint64_t UNUSED(sector), void *UNUSED(blkzone)) +int f2fs_report_zone(int i, uint64_t UNUSED(sector), + struct blk_zone *UNUSED(blkzone)) { ERR_MSG("%d: Unsupported zoned block device\n", i); return -1; _______________________________________________ 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] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 3/3] Improve compile-time type checking for f2fs_report_zone() 2022-06-14 23:17 ` [f2fs-dev] [PATCH 3/3] Improve compile-time type checking for f2fs_report_zone() Bart Van Assche @ 2022-06-18 23:42 ` Chao Yu 0 siblings, 0 replies; 9+ messages in thread From: Chao Yu @ 2022-06-18 23:42 UTC (permalink / raw) To: Bart Van Assche, Jaegeuk Kim; +Cc: linux-f2fs-devel On 2022/6/15 7:17, Bart Van Assche wrote: > Change the type of the third argument of f2fs_report_zone() from void * > into struct blk_zone * to enable type checking. > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> 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] 9+ messages in thread
* Re: [f2fs-dev] [PATCH 0/3] Three f2fs patches 2022-06-14 23:17 [f2fs-dev] [PATCH 0/3] Three f2fs patches Bart Van Assche ` (2 preceding siblings ...) 2022-06-14 23:17 ` [f2fs-dev] [PATCH 3/3] Improve compile-time type checking for f2fs_report_zone() Bart Van Assche @ 2022-06-15 16:58 ` Jaegeuk Kim 3 siblings, 0 replies; 9+ messages in thread From: Jaegeuk Kim @ 2022-06-15 16:58 UTC (permalink / raw) To: Bart Van Assche; +Cc: linux-f2fs-devel Thanks, merged. On 06/14, Bart Van Assche wrote: > Hi Jaegeuk, > > This patch series fixes one issue reported by Peter Collingbourne and two > issues I discovered by reading the zoned block device source code. Please > consider these patches for inclusion in the official f2fs-tools repository. > > Thanks, > > Bart. > > Bart Van Assche (3): > Fix the struct f2fs_dentry_block size check > Fix f2fs_report_zone() > Improve compile-time type checking for f2fs_report_zone() > > include/f2fs_fs.h | 6 ++++-- > lib/libf2fs_zoned.c | 21 +++++++++++++-------- > 2 files changed, 17 insertions(+), 10 deletions(-) _______________________________________________ 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] 9+ messages in thread
end of thread, other threads:[~2022-06-19 22:12 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-06-14 23:17 [f2fs-dev] [PATCH 0/3] Three f2fs patches Bart Van Assche 2022-06-14 23:17 ` [f2fs-dev] [PATCH 1/3] Fix the struct f2fs_dentry_block size check Bart Van Assche 2022-06-18 23:41 ` Chao Yu [not found] ` <CAMn1gO4=iy7tzvvcx6n5DLBM+V4f9Kj=_U1abRf4Cm8XAL+gCA@mail.gmail.com> 2022-06-19 22:12 ` Jaegeuk Kim 2022-06-14 23:17 ` [f2fs-dev] [PATCH 2/3] Fix f2fs_report_zone() Bart Van Assche 2022-06-18 23:41 ` Chao Yu 2022-06-14 23:17 ` [f2fs-dev] [PATCH 3/3] Improve compile-time type checking for f2fs_report_zone() Bart Van Assche 2022-06-18 23:42 ` Chao Yu 2022-06-15 16:58 ` [f2fs-dev] [PATCH 0/3] Three f2fs patches Jaegeuk Kim
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 NNTP newsgroup(s).