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 X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97DB6C433FF for ; Tue, 6 Aug 2019 01:26:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6518B2147A for ; Tue, 6 Aug 2019 01:26:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="G1vC68dN"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="iJBpdkb2"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="1Vm4ii7i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6518B2147A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net 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.90_1) (envelope-from ) id 1huoF2-0008Lp-1R; Tue, 06 Aug 2019 01:26:20 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1huoEz-0008Lf-JA for linux-f2fs-devel@lists.sourceforge.net; Tue, 06 Aug 2019 01:26:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: 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=0ORLkKORHQS3k7q10UaIzmFI4p54TDmVUVhNQXjMelo=; b=G1vC68dN7OQCUkhyDgIWdrcloD LrMVRZmzTnGykVFMU0BzkwG4iOM9jdeBBnhUtAP4sqjB20z+JCGdPAFaPHn9obRSZEArEuZxcFuFk oYbs5iZSz8KOemvIw8dVAk61QmslZrTpEbfL4vIxVEOZIyWbAr28O0b9JtdvzbhxASIc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding: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=0ORLkKORHQS3k7q10UaIzmFI4p54TDmVUVhNQXjMelo=; b=iJBpdkb2FsKFet1kZtAizFZCNq WyvJQmHIzPTxrYB6VSw3B5+wQVsWckSEXUVfaWr3jQjKTRlka6TOtTipYvvpYn/c2+dsXH8X+L9t6 4sfEOXo06QPV5LmbFa/Vcgo5t7uzOQBIfiDkyz8+qSBC3KN4NhoUL7VZNTb7QlH+lJXA=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1huoEx-00CLEA-0V for linux-f2fs-devel@lists.sourceforge.net; Tue, 06 Aug 2019 01:26:16 +0000 Received: from localhost (unknown [104.132.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 671F42147A; Tue, 6 Aug 2019 01:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565054769; bh=2r2dojN0+obCTkqJmHix8I/F/giOsUnKxOU30/+g64k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1Vm4ii7iX4yWh7Ufx4lKDprk4q0lghqC8OoCefKiJHsVl+NGHUdGMI/kCDbwNNqsc COkrVZJtgYRv2o8ywlkcQVR+nqimzOsZOOuLPBaAmhTdII2MxexQYASSD5DL1qm14C c2zFGLpfmrc+v9JnX+InHM5apYVzYcVh8uEWecm0= Date: Mon, 5 Aug 2019 18:26:08 -0700 From: Jaegeuk Kim To: Chao Yu Message-ID: <20190806012608.GC1029@jaegeuk-macbookpro.roam.corp.google.com> References: <20190727154434.5946-1-chao@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) X-Headers-End: 1huoEx-00CLEA-0V Subject: Re: [f2fs-dev] [PATCH v2] f2fs_io: support defrag_file 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: , 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 On 08/06, Chao Yu wrote: > On 2019/7/27 23:44, Chao Yu wrote: > > From: Chao Yu > > > > Support 'defrag_file' sub command to trigger file based defragment via > > ioctl in f2fs. > > > > Signed-off-by: Chao Yu > > --- > > v2: > > - remove unneeded debug info. > > - fix compile warning. > > Sorry I sent the old one... > > I add -v option, but w/o implement the details, because I just see generic/018 > want this, also other filesystem utils have this option, not sure we should > remove this option... any thoughts? Ah, we don't need this option. > > "f2fs_io defrag_file [start] [length] [-v] [file_path]\n\n" > > > tools/f2fs_io/f2fs_io.c | 41 +++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 41 insertions(+) > > > > diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c > > index f087da4..59ef8a7 100644 > > --- a/tools/f2fs_io/f2fs_io.c > > +++ b/tools/f2fs_io/f2fs_io.c > > @@ -442,6 +442,46 @@ static void do_gc_urgent(int argc, char **argv, const struct cmd_desc *cmd) > > } > > } > > > > +#define defrag_file_desc "do defragment on file" > > +#define defrag_file_help \ > > +"f2fs_io defrag_file [start] [length] [-v] [file_path]\n\n" \ > > +" start : start offset of defragment region, unit: bytes\n" \ > > +" length : bytes number of defragment region\n" \ > > +" -v : be verbose\n" \ > > + > > +static void do_defrag_file(int argc, char **argv, const struct cmd_desc *cmd) > > +{ > > + struct f2fs_defragment df; > > + u64 len; > > + int ret, fd; > > + > > + if (argc != 5) { > > + fputs("Excess arguments\n\n", stderr); > > + fputs(cmd->cmd_help, stderr); > > + exit(1); > > + } > > + > > + df.start = atoll(argv[1]); > > + df.len = len = atoll(argv[2]); > > + > > + fd = open(argv[4], O_RDWR); > > + if (fd == -1) { > > + fputs("Open failed\n\n", stderr); > > + fputs(cmd->cmd_help, stderr); > > + exit(1); > > + } > > +printf("%lu, %lu\n", df.start, df.len); > > + ret = ioctl(fd, F2FS_IOC_DEFRAGMENT, &df); > > + if (ret < 0) { > > + perror("F2FS_IOC_DEFRAGMENT"); > > + exit(1); > > + } > > + printf("defrag %s in region[%lu, %lu]\n", argv[3], > > + df.start, df.start + len); > > + exit(0); > > +} > > + > > + > > #define CMD_HIDDEN 0x0001 > > #define CMD(name) { #name, do_##name, name##_desc, name##_help, 0 } > > #define _CMD(name) { #name, do_##name, NULL, NULL, CMD_HIDDEN } > > @@ -456,6 +496,7 @@ const struct cmd_desc cmd_list[] = { > > CMD(read), > > CMD(fiemap), > > CMD(gc_urgent), > > + CMD(defrag_file), > > { NULL, NULL, NULL, NULL, 0 } > > }; > > > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel