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, 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 01BF3C3A589 for ; Fri, 16 Aug 2019 02:28:42 +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 BBFC1206C1; Fri, 16 Aug 2019 02:28:41 +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="ZqNEOcyg"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="DmtribS/"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="QSvBx9i+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBFC1206C1 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-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hyRyr-0000eC-Aq; Fri, 16 Aug 2019 02:28:41 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hyRyp-0000e2-Lj for linux-f2fs-devel@lists.sourceforge.net; Fri, 16 Aug 2019 02:28:39 +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=GFEI3c/+ha+dSMqB+4I/HGU8ieOI2Se2KzUBHPMTatQ=; b=ZqNEOcygzweRqqEZBQNxWkPVGd 8+YVocOulRGXzM3eWU4GJOQPwQ8WcHYPkunLlW6C71JmHuZe0R/x3AQEiREFg0unuCn692jZbz6e4 t7wVTzByYDIUhveG90CQtEe/kpRkw0ZfmdFEy5kSP3Gp/aeF/eLI5ic3PGtL17xc1u9Y=; 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=GFEI3c/+ha+dSMqB+4I/HGU8ieOI2Se2KzUBHPMTatQ=; b=DmtribS/HskiXh2w/hGcEewZhk gUQsVLVwMCIfCJJG7JoA2WqT9vCCaoSkADJNJsIO5PD5oMBhi2Jri7u2AxWmppyiFYk1vDb2jX0QM HnoH4Ph8dhrboUYsjOC1Ez+SXQKubQFH/KVhL6AUrd9dbepIk8chduwN8Qif4r4VRhgA=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hyRyi-005PBT-NS for linux-f2fs-devel@lists.sourceforge.net; Fri, 16 Aug 2019 02:28:39 +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 0D2EF206C1; Fri, 16 Aug 2019 02:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565922507; bh=wWFYva0cEhKIV3hoMFDMBJjcz1ABSgcJg0zl81pCfko=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QSvBx9i+yzwV9l72TAwps5Dfm1X4w3CAWqT0Plus6BR9yQmVE/I4ryzdpFpU/7/kD zZRWrNhhFq/1OT2TrwN58XJqc8m4WiaKdJREZbX5KrBEUUWkkkwQENZFlu7rcLtAUL uLVLTUbLZESUWny9v1BVL7LiYMvSGydKwL7TI4qk= Date: Thu, 15 Aug 2019 19:28:26 -0700 From: Jaegeuk Kim To: Chao Yu Message-ID: <20190816022826.GB73510@jaegeuk-macbookpro.roam.corp.google.com> References: <20190809152328.94814-1-jaegeuk@kernel.org> <0177358e-f900-857d-d7e6-5e5335497913@huawei.com> <20190816022311.GA73510@jaegeuk-macbookpro.roam.corp.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190816022311.GA73510@jaegeuk-macbookpro.roam.corp.google.com> User-Agent: Mutt/1.8.2 (2017-04-18) X-Headers-End: 1hyRyi-005PBT-NS Subject: Re: [f2fs-dev] [PATCH] f2fs_io: add get/setflags 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: Jaegeuk Kim , 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/15, Jaegeuk Kim wrote: > On 08/12, Chao Yu wrote: > > On 2019/8/9 23:23, Jaegeuk Kim wrote: > > > From: Jaegeuk Kim > > > > > > Signed-off-by: Jaegeuk Kim > > > --- > > > tools/f2fs_io/f2fs_io.c | 91 +++++++++++++++++++++++++++++++++++++++++ > > > tools/f2fs_io/f2fs_io.h | 14 +++++++ > > > 2 files changed, 105 insertions(+) > > > > > > diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c > > > index 6b43778..b57c458 100644 > > > --- a/tools/f2fs_io/f2fs_io.c > > > +++ b/tools/f2fs_io/f2fs_io.c > > > @@ -45,6 +45,95 @@ struct cmd_desc { > > > int cmd_flags; > > > }; > > > > > > +#define getflags_desc "getflags ioctl" > > > +#define getflags_help \ > > > +"f2fs_io getflags [file]\n\n" \ > > > +"get a flag given the file\n" \ > > > +"flag can show \n" \ > > > +" casefold\n" \ > > > +" compression\n" \ > > > +" nocompression\n" > > > > Could we support +/- flags? > > > > > + > > > +static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd) > > > +{ > > > + long flag; > > > + int ret, fd; > > > + int exist = 0; > > > + > > > + if (argc != 2) { > > > + fputs("Excess arguments\n\n", stderr); > > > + fputs(cmd->cmd_help, stderr); > > > + exit(1); > > > + } > > > + > > > + fd = open(argv[1], O_RDONLY); > > > + if (fd == -1) { > > > + fputs("Open failed\n\n", stderr); > > > + fputs(cmd->cmd_help, stderr); > > > + exit(1); > > > + } > > > + ret = ioctl(fd, F2FS_IOC_GETFLAGS, &flag); > > > + printf("get a flag on %s ret=%d, flags=", argv[1], ret); > > > + if (flag & FS_CASEFOLD_FL) { > > > + printf("casefold"); > > > + exist = 1; > > > + } > > > + if (flag & FS_COMPR_FL) { > > > + if (exist) > > > + printf(","); > > > + printf("compression"); > > > + exist = 1; > > > + } > > > + if (flag & FS_NOCOMP_FL) { > > > + if (exist) > > > + printf(","); > > > + printf("nocompression"); > > > + exist = 1; > > > + } > > > + if (!exist) > > > + printf("none"); > > > + printf("\n"); > > > + exit(0); > > > +} > > > + > > > +#define setflags_desc "setflags ioctl" > > > +#define setflags_help \ > > > +"f2fs_io setflags [flag] [file]\n\n" \ > > > +"set a flag given the file\n" \ > > > +"flag can be\n" \ > > > +" casefold\n" \ > > > +" compression\n" \ > > > +" nocompression\n" > > > + > > > +static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd) > > > +{ > > > + long flag; > > > + int ret, fd; > > > + > > > + if (argc != 3) { > > > + fputs("Excess arguments\n\n", stderr); > > > + fputs(cmd->cmd_help, stderr); > > > + exit(1); > > > + } > > > + > > > + fd = open(argv[2], O_RDONLY); > > > + if (fd == -1) { > > > + fputs("Open failed\n\n", stderr); > > > + fputs(cmd->cmd_help, stderr); > > > + exit(1); > > > + } > > > + if (!strcmp(argv[1], "casefold")) > > > + flag = FS_CASEFOLD_FL; > > > + else if (!strcmp(argv[1], "compression")) > > > + flag = FS_COMPR_FL; > > > + else if (!strcmp(argv[1], "nocompression")) > > > + flag = FS_NOCOMP_FL; > > > + > > > + ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag); > > > > It will drop other existed flags, should be: > > Is it correct? > > In f2fs_setflags_common, > > fi->i_flags = iflags | (fi->i_flags & ~mask); Hmm, it indeed drops the flags. :P > > > > > > F2FS_IOC_GETFLAGS flag > > flag +/- FS_*_FL > > F2FS_IOC_SETFLAGS flag > > > > Thanks, > > > > > + printf("set a flag: %s ret=%d\n", argv[2], ret); > > > + exit(0); > > > +} > > > + > > > #define shutdown_desc "shutdown filesystem" > > > #define shutdown_help \ > > > "f2fs_io shutdown [level] [dir]\n\n" \ > > > @@ -488,6 +577,8 @@ static void do_defrag_file(int argc, char **argv, const struct cmd_desc *cmd) > > > static void do_help(int argc, char **argv, const struct cmd_desc *cmd); > > > const struct cmd_desc cmd_list[] = { > > > _CMD(help), > > > + CMD(getflags), > > > + CMD(setflags), > > > CMD(shutdown), > > > CMD(pinfile), > > > CMD(fallocate), > > > diff --git a/tools/f2fs_io/f2fs_io.h b/tools/f2fs_io/f2fs_io.h > > > index 95fd5be..5768c1b 100644 > > > --- a/tools/f2fs_io/f2fs_io.h > > > +++ b/tools/f2fs_io/f2fs_io.h > > > @@ -41,9 +41,13 @@ typedef u32 __be32; > > > #ifndef FS_IOC_GETFLAGS > > > #define FS_IOC_GETFLAGS _IOR('f', 1, long) > > > #endif > > > +#ifndef FS_IOC_SETFLAGS > > > +#define FS_IOC_SETFLAGS _IOW('f', 2, long) > > > +#endif > > > > > > #define F2FS_IOCTL_MAGIC 0xf5 > > > #define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS > > > +#define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS > > > > > > #define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1) > > > #define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2) > > > @@ -98,6 +102,16 @@ typedef u32 __be32; > > > #define F2FS_IOC_FSGETXATTR FS_IOC_FSGETXATTR > > > #define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR > > > > > > +#ifndef FS_NOCOMP_FL > > > +#define FS_NOCOMP_FL 0x00000400 /* Don't compress */ > > > +#endif > > > +#ifndef FS_COMPR_FL > > > +#define FS_COMPR_FL 0x00000004 /* Compress file */ > > > +#endif > > > +#ifndef FS_CASEFOLD_FL > > > +#define FS_CASEFOLD_FL 0x40000000 /* Folder is case insensitive */ > > > +#endif > > > + > > > struct f2fs_gc_range { > > > u32 sync; > > > u64 start; > > > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel