Re: [f2fs-dev] [PATCH] f2fs-tools: set the block size of zoned devices to the logical block size
From: Daeho Jeong
Date: Tue Nov 17 2026 - 15:35:17 EST
On Tue, Nov 17, 2026 at 11:14 AM Jaegeuk Kim <jaegeuk@xxxxxxxxxx> wrote:
>
> Could you please fix the build error?
Hi Jaegeuk,
The build error is not from "f2fs-tools: set the block size of zoned
devices to the logical block size". These calloc() calls are in dev and
master as well, and gcc 14 or later reports them: dev-test without that
patch fails in the same way with gcc 14 and 15, and builds with gcc 13.
If you want, I can submit a fix to resolve this issue as a separate patch.
Thanks,
>
> make[2]: Entering directory '/home/runner/work/f2fs-tools/f2fs-tools/lib'
> CC libf2fs_la-libf2fs.lo
> CC libf2fs_la-libf2fs_io.lo
> CC libf2fs_la-libf2fs_zoned.lo
> CC libf2fs_la-nls_utf8.lo
> libf2fs.c: In function 'utf8_to_utf16':
> libf2fs.c:127:47: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
> 127 | uint16_t *volume_name = calloc(sizeof(uint16_t), MAX_VOLUME_NAME);
> | ^~~~~~~~
> libf2fs.c:127:47: note: earlier argument should specify number of elements, later size of each element
> libf2fs.c: In function 'utf16_to_utf8':
> libf2fs.c:222:47: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
> 222 | uint16_t *volume_name = calloc(sizeof(uint16_t), MAX_VOLUME_NAME);
> | ^~~~~~~~
> libf2fs.c:222:47: note: earlier argument should specify number of elements, later size of each element
> cc1: all warnings being treated as errors
> make[2]: *** [Makefile:456: libf2fs_la-libf2fs.lo] Error 1
> make[2]: *** Waiting for unfinished jobs....
> make[2]: Leaving directory '/home/runner/work/f2fs-tools/f2fs-tools/lib'
> make[1]: *** [Makefile:421: all-recursive] Error 1
> make[1]: Leaving directory '/home/runner/work/f2fs-tools/f2fs-tools'
> make: *** [Makefile:353: all] Error 2
>
> On 11/13, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@xxxxxxxxxx>
> >
> > The kernel caches a block device in units of its soft block size, which
> > is set to the largest power of two that divides the device size, up to
> > PAGE_SIZE. On a 16KB page kernel, it is 16KB even for a 4KB logical
> > block device, so a buffered 4KB write is written back as a whole 16KB
> > unit.
> >
> > On a host-managed zoned device, the first write in a unit then moves the
> > write pointer of the sequential zone beyond the written data, and the
> > next write in the same unit is rejected as an unaligned write, e.g.
> >
> > Buffer I/O error on dev nvme0n1, logical block 24576, lost async page write
> > Error: While writing the quota_blk to disk!!!
> >
> > Set the soft block size of zoned devices to their logical block size
> > with BLKBSZSET, so that each write covers whole units. If it cannot be
> > set and the current one is larger, fail right away instead of failing in
> > the middle of the writes. Skip it for dump.f2fs and --dry-run, which do
> > not write to the device, and when the page size is not larger than the
> > logical block size, as the soft block size is not larger then either.
> >
> > Signed-off-by: Daeho Jeong <daehojeong@xxxxxxxxxx>
> > ---
> > lib/libf2fs.c | 36 ++++++++++++++++++++++++++++++++++++
> > 1 file changed, 36 insertions(+)
> >
> > diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> > index 93f36ca..b0cdf09 100644
> > --- a/lib/libf2fs.c
> > +++ b/lib/libf2fs.c
> > @@ -922,6 +922,14 @@ void get_kernel_uname_version(__u8 *version)
> > #define BLKSSZGET _IO(0x12,104)
> > #endif
> >
> > +#if defined(__linux__) && defined(_IOR) && !defined(BLKBSZGET)
> > +#define BLKBSZGET _IOR(0x12,112, size_t)
> > +#endif
> > +
> > +#if defined(__linux__) && defined(_IOW) && !defined(BLKBSZSET)
> > +#define BLKBSZSET _IOW(0x12,113, size_t)
> > +#endif
> > +
> > #if defined(__APPLE__)
> > #include <sys/disk.h>
> > #define BLKGETSIZE DKIOCGETBLOCKCOUNT
> > @@ -1047,6 +1055,34 @@ int get_device_info(int i)
> > else if (dev->sector_size < sector_size)
> > dev->sector_size = sector_size;
> > #endif
> > +#if defined(BLKBSZGET) && defined(BLKBSZSET)
> > + /*
> > + * The page cache of a block device is managed in units of its
> > + * soft block size, which can be as large as PAGE_SIZE. A
> > + * smaller write is then written back as a whole unit, which
> > + * moves the write pointer of a sequential zone beyond the
> > + * written data, and makes the next write in the same unit
> > + * fail. Use the logical block size for zoned devices, and do
> > + * not go on to write to the device if it cannot be set. The
> > + * soft block size is larger than the logical block size only
> > + * when PAGE_SIZE is, so leave it alone otherwise.
> > + */
> > + if (dev->zoned_model == F2FS_ZONED_HM &&
> > + c.func != DUMP && !c.dry_run &&
> > + sysconf(_SC_PAGESIZE) > (long)dev->sector_size) {
> > + int bsz = dev->sector_size;
> > + int cur_bsz = 0;
> > +
> > + if (ioctl(fd, BLKBSZSET, &bsz) < 0 &&
> > + (ioctl(fd, BLKBSZGET, &cur_bsz) < 0 ||
> > + cur_bsz > bsz)) {
> > + MSG(0, "\tError: Cannot set the block size "
> > + "of %s to %d\n", dev->path, bsz);
> > + free(stat_buf);
> > + return -1;
> > + }
> > + }
> > +#endif
> > #ifdef BLKGETSIZE64
> > if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {
> > MSG(0, "\tError: Cannot get the device size\n");
> > --
> > 2.56.0.611.g1030f0b940-goog
> >
> >
> >
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel