From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A548CCF9F8 for ; Mon, 3 Nov 2025 06:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:Message-ID:Date:To:Sender: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=T1MP9qu2b4ynJAw/g4T7cAbtf+PSXNj5niX87iN9nI0=; b=aU72ltDt7QzRA/gaSAo5UsMovH t0G7zklGbZ1DmmvNq7tVzNn3ZvMJXFkbuaIbqp6feTHrlL8r9UsEbh4WZE+YEVuNsquQ06l4z2TnX hdtJZxaew+63mKfr4UQfRDxhVdYRwtxBwqXkxpyQcuatrw8RyFi++/hbmyVyL9eCHRWk=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vFoEF-00067n-F6; Mon, 03 Nov 2025 06:39:47 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vFoEE-00067h-Hu for linux-f2fs-devel@lists.sourceforge.net; Mon, 03 Nov 2025 06:39:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PGaKq3eJu9ULEQrpBnyzOY3OHUm/rIQb6aEdASqd8n0=; b=IqvLvfqdH23578OEE0wiDF24in qQcpRT1re1zAaTOoBp7WmB9ELrKIb1bCwG1AuR8jPQaYrEicEPUaPW8XJmD3KM6SlsueqRn6aSod8 BTt6Wk+tMWQcoyMXyjHGDhoHju6xRyBR8AIj3FRE8K3+W+Xi+CWDWPFnZF+ZYI32uOvU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=PGaKq3eJu9ULEQrpBnyzOY3OHUm/rIQb6aEdASqd8n0=; b=K qton/C/nw8JxbkA6ouYEhDFpa3OaflBqZ1p7SzjBP9kHjV/Zpb8KsK9ug1OwmkyOj6ywZeFYRffeK frGNGY+UJjYKB5gtbFOAlzmJ6969Cw9QsflFtwBPOV/cTr3LNALLtGAYlwIs4gZzJxTosN6wdfQIM hzcRunEZdTM6gpgg=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vFoEE-0000VB-5o for linux-f2fs-devel@lists.sourceforge.net; Mon, 03 Nov 2025 06:39:46 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id BEAF64485D for ; Mon, 3 Nov 2025 06:39:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 704E1C4CEE7; Mon, 3 Nov 2025 06:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762151980; bh=VBij2mITexCO1TcPruw5+kHPYC8QobFazbd9hyFugx8=; h=From:To:Cc:Subject:Date:From; b=IQfMPIxsWV3tv9AA88RIlz8NpXd/kdLLqy9gjUbqit3z55kKoM8oFksAgcdQOGuWm RL2RnHH22yaKvIWy0CXDvFrgBAC8D3GeLBk5hJu/JG9rMMFQHAECDKgoBhe9gDQzXY 0xqSG6DatkPz+7RrW91UO9S4nItYhCbk7a/rn81/W+2uTdwqrr/dlT5lyfDyxp3fSP Z0swz5eBgoG6Rx4IY1iz6o6CFgkynj2iX89FAxp0K5y/KREu1VQez6sVAopiqM/3w9 +0kLOBkdgaQ+QbYpvjWZDBb3IzCYNegK7UzTy8j2dgj+wI2c1brPrEcCwSRB8ZeQ6s Q6xGbAyuzzofQ== To: jaegeuk@kernel.org Date: Mon, 3 Nov 2025 14:39:31 +0800 Message-ID: <20251103063931.2663358-1-chao@kernel.org> X-Mailer: git-send-email 2.51.2.997.g839fc31de9-goog MIME-Version: 1.0 X-Headers-End: 1vFoEE-0000VB-5o Subject: [f2fs-dev] [PATCH] f2fs_io: ranndread: support block device X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Chao Yu via Linux-f2fs-devel Reply-To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Otherwise, f2fs_io randread will fail due to i_size of block device inode is zero. - f2fs_io randread 1 1000 buffered 1 /dev/vdc fadvise RANDOM|WILLNEED to a file: /dev/vdc File is too small to random read Signed-off-by: Chao Yu --- tools/f2fs_io/f2fs_io.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 1f26c7c..231da47 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -1225,6 +1225,7 @@ static void do_randread(int argc, char **argv, const struct cmd_desc *cmd) int fd, advice; time_t t; struct stat stbuf; + u64 size; if (argc != 6) { fputs("Excess arguments\n\n", stderr); @@ -1261,7 +1262,17 @@ static void do_randread(int argc, char **argv, const struct cmd_desc *cmd) if (fstat(fd, &stbuf) != 0) die_errno("fstat of source file failed"); - aligned_size = (u64)stbuf.st_size & ~((u64)(F2FS_DEFAULT_BLKSIZE - 1)); + if (S_ISBLK(stbuf.st_mode)) { + u64 devsize; + + if (ioctl(fd, BLKGETSIZE64, &devsize) < 0) + die_errno("BLKGETSIZE64 failed"); + size = devsize; + } else { + size = (u64)stbuf.st_size; + } + + aligned_size = (u64)size & ~((u64)(F2FS_DEFAULT_BLKSIZE - 1)); if (aligned_size < buf_size) die("File is too small to random read"); end_idx = (u64)(aligned_size - buf_size) / (u64)F2FS_DEFAULT_BLKSIZE + 1; -- 2.49.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel