From nobody Sun Feb 8 22:43:55 2026 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8B912038A0 for ; Tue, 29 Oct 2024 08:28:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730190529; cv=none; b=mUqDPpf2hE0OmfvDrbHtRUH6uUIPl0xlJwU3g8c3mtXHikeY8zoE1cD3IWNVY5q2PW8xTvrCkqLNYfofTasd8Duz2E2mDxak/AmRnWasdhX8KXxGwVzea4FEzR4Xj4U96VbdauC0eVNKa1NWUdOuQIwCEWvMRh5kbgRuj8xPYBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730190529; c=relaxed/simple; bh=fpeTunYSSpqkvriMRTKtcPZDTWFPneAiDM5w2MTmqgg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gbZsIYamgBBzSjBsKYJzn65Xf6LA74RyRAH2J4+2vuSEWwtfCSW66oktW+tyYw/mWDDh891546K/3xTXrAVPOGdgzcmb84QxL4USqXWo5V9UezMleHtRB8i7mM2PUtNvtP38/RzMr2FZDd0nyFgJTfRgrwbLqoZOXwNTirzwJDA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 49T8S8nh094583; Tue, 29 Oct 2024 16:28:08 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4Xd3KJ2Grxz2K4lJF; Tue, 29 Oct 2024 16:27:32 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 29 Oct 2024 16:28:05 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH V2] f2fs-io: unify default block size Date: Tue, 29 Oct 2024 16:27:46 +0800 Message-ID: <1730190466-13015-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 49T8S8nh094583 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" F2FS_BLKSIZE and 4096 are both used in f2fs_io for IO/buffer size, but F2FS_BLKSIZE may confuse user becasue it may be 4KB, 16KB, so use macro F2FS_DEFAULT_BLKSIZE to unify F2FS_BLKSIZE and 4096 in f2fs_io, also adjust "-c" parameters in mkfs man, to be consistent with commit c35fa8cd75ac ("mkfs.f2fs: change -c option description"). Signed-off-by: Zhiguo Niu Reviewed-by: Chao Yu --- V2: unify default block size in f2fs_io.c --- man/mkfs.f2fs.8 | 2 +- tools/f2fs_io/f2fs_io.c | 37 ++++++++++++++++++++----------------- tools/f2fs_io/f2fs_io.h | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 index de885be..8b3b0cc 100644 --- a/man/mkfs.f2fs.8 +++ b/man/mkfs.f2fs.8 @@ -122,7 +122,7 @@ block size matches the page size. The default value is 4096. .TP .BI \-c " device-list" -Build f2fs with these additional comma separated devices, so that the user= can +Build f2fs with these additional devices, so that the user can see all the devices as one big volume. Supports up to 7 devices except meta device. .TP diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 95f575f..837f8a9 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -209,7 +209,7 @@ static void do_set_verity(int argc, char **argv, const = struct cmd_desc *cmd) struct fsverity_enable_arg args =3D {.version =3D 1}; =20 args.hash_algorithm =3D FS_VERITY_HASH_ALG_SHA256; - args.block_size =3D 4096; + args.block_size =3D F2FS_DEFAULT_BLKSIZE; =20 if (argc !=3D 2) { fputs("Excess arguments\n\n", stderr); @@ -659,11 +659,11 @@ static void do_write_with_advice(int argc, char **arg= v, if (bs > 1024) die("Too big chunk size - limit: 4MB"); =20 - buf_size =3D bs * 4096; + buf_size =3D bs * F2FS_DEFAULT_BLKSIZE; =20 offset =3D atoi(argv[2]) * buf_size; =20 - buf =3D aligned_xalloc(4096, buf_size); + buf =3D aligned_xalloc(F2FS_DEFAULT_BLKSIZE, buf_size); count =3D atoi(argv[3]); =20 if (!strcmp(argv[4], "zero")) @@ -874,11 +874,11 @@ static void do_read(int argc, char **argv, const stru= ct cmd_desc *cmd) bs =3D atoi(argv[1]); if (bs > 1024) die("Too big chunk size - limit: 4MB"); - buf_size =3D bs * 4096; + buf_size =3D bs * F2FS_DEFAULT_BLKSIZE; =20 offset =3D atoi(argv[2]) * buf_size; =20 - buf =3D aligned_xalloc(4096, buf_size); + buf =3D aligned_xalloc(F2FS_DEFAULT_BLKSIZE, buf_size); =20 count =3D atoi(argv[3]); if (!strcmp(argv[4], "dio")) @@ -898,9 +898,11 @@ static void do_read(int argc, char **argv, const struc= t cmd_desc *cmd) =20 advice =3D atoi(argv[5]); if (advice) { - if (posix_fadvise(fd, 0, 4096, POSIX_FADV_SEQUENTIAL) !=3D 0) + if (posix_fadvise(fd, 0, F2FS_DEFAULT_BLKSIZE, + POSIX_FADV_SEQUENTIAL) !=3D 0) die_errno("fadvise failed"); - if (posix_fadvise(fd, 0, 4096, POSIX_FADV_WILLNEED) !=3D 0) + if (posix_fadvise(fd, 0, F2FS_DEFAULT_BLKSIZE, + POSIX_FADV_WILLNEED) !=3D 0) die_errno("fadvise failed"); printf("fadvise SEQUENTIAL|WILLNEED to a file: %s\n", argv[7]); } @@ -976,9 +978,9 @@ static void do_randread(int argc, char **argv, const st= ruct cmd_desc *cmd) bs =3D atoi(argv[1]); if (bs > 1024) die("Too big chunk size - limit: 4MB"); - buf_size =3D bs * 4096; + buf_size =3D bs * F2FS_DEFAULT_BLKSIZE; =20 - buf =3D aligned_xalloc(4096, buf_size); + buf =3D aligned_xalloc(F2FS_DEFAULT_BLKSIZE, buf_size); =20 count =3D atoi(argv[2]); if (!strcmp(argv[3], "dio")) @@ -991,17 +993,17 @@ static void do_randread(int argc, char **argv, const = struct cmd_desc *cmd) if (fstat(fd, &stbuf) !=3D 0) die_errno("fstat of source file failed"); =20 - aligned_size =3D (u64)stbuf.st_size & ~((u64)(4096 - 1)); + aligned_size =3D (u64)stbuf.st_size & ~((u64)(F2FS_DEFAULT_BLKSIZE - 1)); if (aligned_size < buf_size) die("File is too small to random read"); - end_idx =3D (u64)(aligned_size - buf_size) / (u64)4096 + 1; + end_idx =3D (u64)(aligned_size - buf_size) / (u64)F2FS_DEFAULT_BLKSIZE + = 1; =20 srand((unsigned) time(&t)); =20 for (i =3D 0; i < count; i++) { idx =3D rand() % end_idx; =20 - ret =3D pread(fd, buf, buf_size, 4096 * idx); + ret =3D pread(fd, buf, buf_size, F2FS_DEFAULT_BLKSIZE * idx); if (ret !=3D buf_size) break; =20 @@ -1031,15 +1033,16 @@ static void do_fiemap(int argc, char **argv, const = struct cmd_desc *cmd) } =20 memset(fm, 0, sizeof(struct fiemap)); - start =3D (u64)atoi(argv[1]) * F2FS_BLKSIZE; - length =3D (u64)atoi(argv[2]) * F2FS_BLKSIZE; + start =3D (u64)atoi(argv[1]) * F2FS_DEFAULT_BLKSIZE; + length =3D (u64)atoi(argv[2]) * F2FS_DEFAULT_BLKSIZE; fm->fm_start =3D start; fm->fm_length =3D length; =20 fd =3D xopen(argv[3], O_RDONLY | O_LARGEFILE, 0); =20 printf("Fiemap: offset =3D %"PRIu64" len =3D %"PRIu64"\n", - start / F2FS_BLKSIZE, length / F2FS_BLKSIZE); + start / F2FS_DEFAULT_BLKSIZE, + length / F2FS_DEFAULT_BLKSIZE); if (ioctl(fd, FS_IOC_FIEMAP, fm) < 0) die_errno("FIEMAP failed"); =20 @@ -1219,9 +1222,9 @@ static void do_copy(int argc, char **argv, const stru= ct cmd_desc *cmd) if (ret < 0) die_errno("sendfile failed"); } else { - char *buf =3D aligned_xalloc(4096, 4096); + char *buf =3D aligned_xalloc(F2FS_DEFAULT_BLKSIZE, F2FS_DEFAULT_BLKSIZE); =20 - while ((ret =3D xread(src_fd, buf, 4096)) > 0) + while ((ret =3D xread(src_fd, buf, F2FS_DEFAULT_BLKSIZE)) > 0) full_write(dst_fd, buf, ret); free(buf); } diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h index e55db5f..14c9dc1 100644 --- a/tools/f2fs_io/f2fs_io.h +++ b/tools/f2fs_io/f2fs_io.h @@ -48,7 +48,7 @@ typedef u16 __be16; typedef u32 __be32; #endif =20 -#define F2FS_BLKSIZE 4096 +#define F2FS_DEFAULT_BLKSIZE 4096 #define NEW_ADDR 0xFFFFFFFF =20 #ifndef FS_IOC_GETFLAGS --=20 1.9.1