From patchwork Fri Feb 28 19:08:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13996950 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 BCD86C282C6 for ; Fri, 28 Feb 2025 19:09:25 +0000 (UTC) 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 1to5jg-0002Cr-Ti; Fri, 28 Feb 2025 19:09:25 +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 1to5jd-0002Cj-Ej for linux-f2fs-devel@lists.sourceforge.net; Fri, 28 Feb 2025 19:09:21 +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=/PV55AuDjJ7aLitYs7A41Vp5Z2gf/V85SSKBlRI4+Ws=; b=jctUcQ1ttvnhW1iGYCpA7bcMvT 0nxBqyeFA75qP5AZFe+2O6mCI63HOm0noR2bqNPY5LzWSyF89hMWZTNb7h63gu85vu1QkWZVLF7Qw igy3f2zKmbKULY0ryR5U2jzLrb8a24LcQhgSQHLN/E8kR5TFGXFwnkM0Z50dtLJLhQnQ=; 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=/PV55AuDjJ7aLitYs7A41Vp5Z2gf/V85SSKBlRI4+Ws=; b=F eWpqgxND0kC2zMKbww5WhzzFmsVdZL2qs1bYmUl11eJC/hgZAckrg81diQBNg+guAztD2N0h5jRUo 24KIO8jGon4XyHpKt05ND7OgMN2alyrSMbx6oy2zKm/watEYT1DJrZqWkU3MEELZUdUw7umZq9Nvl GsLYEGCZvIOScoQQ=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1to5jT-0000ZY-9U for linux-f2fs-devel@lists.sourceforge.net; Fri, 28 Feb 2025 19:09:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 086326116A for ; Fri, 28 Feb 2025 19:08:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36FE3C4CED6; Fri, 28 Feb 2025 19:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740769740; bh=1lUwhCUY4nLHnSKMSlYvh4CkH3xii91IdeHXolzqTFU=; h=From:To:Cc:Subject:Date:From; b=LZwB/ZNFHFf2jXqnSwtXIByQ8c98aMhVtfc0rKUJeqiTax26Ivjjmhy9x31NuESoP c+XLO7IVAW+w7pvxxWSYA/k/+KR3TCbskunwxB/57sQLaA4SEwRNegLeN+C3lIVj7o K34ifzyhxAaYQVJJvgFUadmR4wlBed+ZJLqBiuFiyLR30aEFYixy2VwscIswqHSMj6 7F/TpZFWHa7lab2TzFycJkS5zWEIVOw+lcF1T5nC/3Kuch5DZo2rz1J9tV9PZL5JkX Vd+OFXA0gvgcGFPsz8p09lBv6u6VtVFtKzWCCDozTb1Pn8q+3i0+bqLrI3LQZOFRbY mP5GIP87D2LyQ== To: linux-f2fs-devel@lists.sourceforge.net Date: Fri, 28 Feb 2025 19:08:53 +0000 Message-ID: <20250228190854.422890-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog MIME-Version: 1.0 X-Headers-End: 1to5jT-0000ZY-9U Subject: [f2fs-dev] [PATCH 1/2] f2fs_io: support fadvise dontneed, random, and noreuse 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: , X-Patchwork-Original-From: Jaegeuk Kim via Linux-f2fs-devel From: Jaegeuk Kim Reply-To: Jaegeuk Kim Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu --- man/f2fs_io.8 | 3 ++- tools/f2fs_io/f2fs_io.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/man/f2fs_io.8 b/man/f2fs_io.8 index 97a893b26114..5def508e494f 100644 --- a/man/f2fs_io.8 +++ b/man/f2fs_io.8 @@ -54,7 +54,8 @@ going down with fsck mark Get or set the pinning status on a file. .TP \fBfadvise\fR \fI[advice] [offset] [length] [file]\fR -Pass an advice to the specified file. The advice can be willneed and sequential. +Pass an advice to the specified file. The advice can be willneed, dontneed, +noreuse, sequential, random. .TP \fBfallocate\fR \fI[-c] [-i] [-p] [-z] [keep_size] [offset] [length] [file]\fR Request that space be allocated on a file. The diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 92345d2dd2d2..05126c8b44a6 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -454,7 +454,10 @@ static void do_shutdown(int argc, char **argv, const struct cmd_desc *cmd) "fadvice given the file\n" \ "advice can be\n" \ " willneed\n" \ +" dontneed\n" \ +" noreuse\n" \ " sequential\n" \ +" random\n" \ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd) { @@ -471,8 +474,14 @@ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd) if (!strcmp(argv[1], "willneed")) { advice = POSIX_FADV_WILLNEED; + } else if (!strcmp(argv[1], "dontneed")) { + advice = POSIX_FADV_DONTNEED; + } else if (!strcmp(argv[1], "noreuse")) { + advice = POSIX_FADV_NOREUSE; } else if (!strcmp(argv[1], "sequential")) { advice = POSIX_FADV_SEQUENTIAL; + } else if (!strcmp(argv[1], "random")) { + advice = POSIX_FADV_RANDOM; } else { fputs("Wrong advice\n\n", stderr); fputs(cmd->cmd_help, stderr); From patchwork Fri Feb 28 19:08:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13996949 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 4A0D7C282C6 for ; Fri, 28 Feb 2025 19:09:19 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1to5jZ-0004sC-Ra; Fri, 28 Feb 2025 19:09:18 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1to5jY-0004s2-RS for linux-f2fs-devel@lists.sourceforge.net; Fri, 28 Feb 2025 19:09:17 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=RBWHALs+pQra8EBxbjJTamIGlpgwDEYEyC8sfc9N6p4=; b=NUSP2XsXABiYvq7I8gEWoQREwx NYunzKyrJ9hPBOOx07xw48bLIPFsEDeK++aHjQ4bdHZ71VtK9JjpOKtLvYu9q1kpt9Zi0ss80ZxYJ TrasWPjx8+3EEfsfOHOGslSGw7G6oRUoXC0iloQlImj5unjEOYBMq1EY4AE0CAl8eg14=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RBWHALs+pQra8EBxbjJTamIGlpgwDEYEyC8sfc9N6p4=; b=U9/bRoVxz3wk3wrhQIO0FZ6UpJ lepCYKBrJm6+GAWWNnY4/zcqcHwF1VDGPD/A8Sf4qpdmNF/p5gRCTtOVgFm9n+MxvKeUpE9ebYuq8 TUUYSYlKZoT1Aq/I17hkUSFLOV7Ug2RSga27L+KgEH/6r5/AVYO9sobqQHPdudl92wNI=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1to5jO-0000ZR-T6 for linux-f2fs-devel@lists.sourceforge.net; Fri, 28 Feb 2025 19:09:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A647D5C6995 for ; Fri, 28 Feb 2025 19:06:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B553C4CED6; Fri, 28 Feb 2025 19:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740769741; bh=9YuEuWyD2rw96fYZspKuWjKx/UU5T7CzTFvFhynJyvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7P9mm+21YhRrnfZg62atZ+HolVEiqZnquBpwotZK6LlQxfxNoFjTSwfJ2iVZon3b R0CwnncJ1Abz+o67KjSZ/SQ4KNVie7m4YcA1+/5VUbqDGBHaxWMS5oTAF66Jd1cBFx eZynDJ/lFHkW/63M0xXCL5tTZU4QIp4BCmOi3Z7Fdoo+sWzDCCxk254scps8oLR74+ lKf5UxFEp2shLW4JoTJnWuYP3QX55+qArBpvsggOays4bbe2ShDYDxVTEsba4I/i+e fJCE0+p+x+JBOQEmz1oIN+vr5D+vmcnk7V1uMDRgFUflr0gE6q90prKxcM7Qbtl2cs 1UHJUI7fzmicg== To: linux-f2fs-devel@lists.sourceforge.net Date: Fri, 28 Feb 2025 19:08:54 +0000 Message-ID: <20250228190854.422890-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog In-Reply-To: <20250228190854.422890-1-jaegeuk@kernel.org> References: <20250228190854.422890-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1to5jO-0000ZR-T6 Subject: [f2fs-dev] [PATCH 2/2] f2fs_io: add ioprio command to give a io priority hint 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: , X-Patchwork-Original-From: Jaegeuk Kim via Linux-f2fs-devel From: Jaegeuk Kim Reply-To: Jaegeuk Kim Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This adds a command to call ioctl(F2FS_IOC_IO_PRIO). Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu --- man/f2fs_io.8 | 3 +++ tools/f2fs_io/f2fs_io.c | 35 +++++++++++++++++++++++++++++++++++ tools/f2fs_io/f2fs_io.h | 7 +++++++ 3 files changed, 45 insertions(+) diff --git a/man/f2fs_io.8 b/man/f2fs_io.8 index 5def508e494f..b71965cf447a 100644 --- a/man/f2fs_io.8 +++ b/man/f2fs_io.8 @@ -181,6 +181,9 @@ Trigger gc to move data blocks from specified address range .TP \fBget_advise\fR \fI[file]\fR Get i_advise value and info in file +.TP +\fBioprio\fR \fI[hint] [file]\fR +Set ioprio to the file. The ioprio can be ioprio_write. .SH AUTHOR This version of .B f2fs_io diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 05126c8b44a6..155d44f147ad 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -498,6 +498,40 @@ static void do_fadvise(int argc, char **argv, const struct cmd_desc *cmd) exit(0); } +#define ioprio_desc "ioprio" +#define ioprio_help \ +"f2fs_io ioprio [hint] [file]\n\n" \ +"ioprio given the file\n" \ +"hint can be\n" \ +" ioprio_write\n" \ + +static void do_ioprio(int argc, char **argv, const struct cmd_desc *cmd) +{ + int fd, hint; + + if (argc != 3) { + fputs("Excess arguments\n\n", stderr); + fputs(cmd->cmd_help, stderr); + exit(1); + } + + fd = xopen(argv[2], O_RDWR, 0); + + if (!strcmp(argv[1], "ioprio_write")) { + hint = F2FS_IOPRIO_WRITE; + } else { + fputs("Not supported hint\n\n", stderr); + fputs(cmd->cmd_help, stderr); + exit(1); + } + + if (ioctl(fd, F2FS_IOC_IO_PRIO, &hint) != 0) + die_errno("ioprio failed"); + + printf("ioprio_hint %d to a file: %s\n", hint, argv[2]); + exit(0); +} + #define pinfile_desc "pin file control" #define pinfile_help \ "f2fs_io pinfile [get|set|unset] [file] {size}\n\n" \ @@ -1966,6 +2000,7 @@ const struct cmd_desc cmd_list[] = { CMD(removexattr), CMD(lseek), CMD(get_advise), + CMD(ioprio), { NULL, NULL, NULL, NULL, 0 } }; diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h index c32def72fe45..22102884faab 100644 --- a/tools/f2fs_io/f2fs_io.h +++ b/tools/f2fs_io/f2fs_io.h @@ -94,6 +94,8 @@ typedef u32 __be32; #define F2FS_IOC_DECOMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 23) #define F2FS_IOC_COMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 24) #define F2FS_IOC_START_ATOMIC_REPLACE _IO(F2FS_IOCTL_MAGIC, 25) +#define F2FS_IOC_GET_DEV_ALIAS_FILE _IOR(F2FS_IOCTL_MAGIC, 26, __u32) +#define F2FS_IOC_IO_PRIO _IOW(F2FS_IOCTL_MAGIC, 28, __u32) #ifndef FSCRYPT_POLICY_V1 #define FSCRYPT_POLICY_V1 0 @@ -193,6 +195,11 @@ struct fsverity_enable_arg { #define FADVISE_VERITY_BIT 0x40 #define FADVISE_TRUNC_BIT 0x80 +/* used for F2FS_IOC_IO_PRIO */ +enum { + F2FS_IOPRIO_WRITE = 1, /* high write priority */ +}; + #ifndef FS_IMMUTABLE_FL #define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */ #endif