Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2894557pxu; Mon, 7 Dec 2020 20:13:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwG8TNfEminI4/8Dj3839lnbWB1lZZp2nETMQ7qQynM7/F2D9zmxqZusA1l682ax64e/FQV X-Received: by 2002:a17:906:e24f:: with SMTP id gq15mr20358598ejb.256.1607400808011; Mon, 07 Dec 2020 20:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607400808; cv=none; d=google.com; s=arc-20160816; b=gwvNmnfShov8c51H7k8gVQnEuXrYyaGY9dsD9ca33+h8OH3507Q91sAb3d3AF+IM4G eVQFqvd5v2Mst4Ug6jRyQ9lAwqb3FtnwrnIFaaCjekxdbue1Syxl3coO1UPhWHKpUwTd CxdzFD//cMWWZjGx1ZL/NwqocuBBUQZx3X4yVNvnun3oZUqjOiyhVOq1vogAu/xlI61N nAsEfBcWK2zwLVVeshu1DCYbM79nSgftZead8jKQqzNVWlncRUF0OpROQx61jtg+bE4H X4455fUMtQX11mppP7lPZGTa8EOB0RNq7doI0KPUtAEIjjJVM5KuhotkNVCm8FZ8yFCl /5ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=DLo32PKIqBM5w0wTtv7kVLHl6QZIY2IiVw8y3BJbO8I=; b=X2/uiSQHIYvr7zqx9Gyh2N0OmLd37ksY63+nzddibn4Tco40OS7CurbmhRM4KuL4bT oorkP/qmtgsICURAjZcBt1CnPBNtgG6f8/sfDr/+ix+c8HPj9f8bAlOsmoqEqKuJFO7h iO66kbzY8Uxh9NFKkFV/lkRY5V1SXKM7epIwA2SY4aXqZ9xilTQUIm/lcVv2NJGZe1yk kDozZb0qVlRAsc8C2WBLbHlFJdHMqnzDHA0WMRGI95b+MA32KCtRHSx1nObt3X6lNjuS w896dP/lIUdRfSJuv104vRPad82cQKG+D8+7pQQauUFWbN5NyyLdqB0V7yCQQFNMbL+8 6lRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hj2AQrK1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si9364914edt.290.2020.12.07.20.13.05; Mon, 07 Dec 2020 20:13:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hj2AQrK1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726299AbgLHDwK (ORCPT + 99 others); Mon, 7 Dec 2020 22:52:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:60572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgLHDwK (ORCPT ); Mon, 7 Dec 2020 22:52:10 -0500 Date: Mon, 7 Dec 2020 19:51:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607399488; bh=uwHFkmRMJNQWu5o/EktiSUuQpKFAf8s/mDCjQuqN0WU=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=hj2AQrK111a4NAJdVMKLrtiByZkLgjt3j1np2yhikhW+uCESRy7eYd7DxHAtQvjBe 2yDJghoslgQxsec98NCG9pdjn8o81bXne83X09b5B3h8xhLDbnAIT67F0NFH358EFc 2h6ybdNfjOizuC8ETt+xjz/f41rLNhYAbFalqIEd5Ac5JLhJOWQFQiRv7s5z0Jx6R1 k5Y8XR3CkWT5mnyJtm/QnmZf93RgC7RJW2ZCVRGQvp6kHsnBnTI64wfSBesMwdPEUV aFfHhiadgico2WlHLVtYPC4sYe8uyt9pTB1W8BG/uF1U1UDu8AZMRBo80FhT8yAE/H 43O3L4Xa5pzAw== From: Eric Biggers To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [f2fs-dev] [PATCH v2 1/2] f2fs: add compress_mode mount option Message-ID: References: <20201201040803.3590442-1-daeho43@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201040803.3590442-1-daeho43@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 01:08:02PM +0900, Daeho Jeong wrote: > From: Daeho Jeong > > We will add a new "compress_mode" mount option to control file > compression mode. This supports "fs" and "user". In "fs" mode (default), > f2fs does automatic compression on the compression enabled files. > In "user" mode, f2fs disables the automaic compression and gives the > user discretion of choosing the target file and the timing. It means > the user can do manual compression/decompression on the compression > enabled files using ioctls. > > Signed-off-by: Daeho Jeong > --- > v2: changed mount option name and added more explanation of mount option > --- > Documentation/filesystems/f2fs.rst | 35 ++++++++++++++++++++++++++++++ > fs/f2fs/compress.c | 2 +- > fs/f2fs/data.c | 2 +- > fs/f2fs/f2fs.h | 30 +++++++++++++++++++++++++ > fs/f2fs/segment.c | 2 +- > fs/f2fs/super.c | 23 ++++++++++++++++++++ > 6 files changed, 91 insertions(+), 3 deletions(-) > > diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst > index b8ee761c9922..5eb8d63439ec 100644 > --- a/Documentation/filesystems/f2fs.rst > +++ b/Documentation/filesystems/f2fs.rst > @@ -260,6 +260,13 @@ compress_extension=%s Support adding specified extension, so that f2fs can enab > For other files, we can still enable compression via ioctl. > Note that, there is one reserved special extension '*', it > can be set to enable compression for all files. > +compress_mode=%s Control file compression mode. This supports "fs" and "user" > + modes. In "fs" mode (default), f2fs does automatic compression > + on the compression enabled files. In "user" mode, f2fs disables > + the automaic compression and gives the user discretion of > + choosing the target file and the timing. The user can do manual > + compression/decompression on the compression enabled files using > + ioctls. > inlinecrypt When possible, encrypt/decrypt the contents of encrypted > files using the blk-crypto framework rather than > filesystem-layer encryption. This allows the use of > @@ -810,6 +817,34 @@ Compress metadata layout:: > | data length | data chksum | reserved | compressed data | > +-------------+-------------+----------+----------------------------+ > > +Compression mode > +-------------------------- > + > +f2fs supports "fs" and "user" compression modes with "compression_mode" mount option. > +With this option, f2fs provides a choice to select the way how to compress the > +compression enabled files (refer to "Compression implementation" section for how to > +enable compression on a regular inode). > + > +1) compress_mode=fs > +This is the default option. f2fs does automatic compression in the writeback of the > +compression enabled files. > + > +2) compress_mode=user > +This disables the automaic compression and gives the user discretion of choosing the > +target file and the timing. The user can do manual compression/decompression on the > +compression enabled files using F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE > +ioctls like the below. > + > +To decompress a file, > + > +fd = open(filename, O_WRONLY, 0); > +ret = ioctl(fd, F2FS_IOC_DECOMPRESS_FILE); > + > +To compress a file, > + > +fd = open(filename, O_WRONLY, 0); > +ret = ioctl(fd, F2FS_IOC_COMPRESS_FILE); > + Why doesn't compress_mode=user just cause regular files to not inherit the compression flag? Then users could set or clear the compression flag using FS_IOC_SETFLAGS, without any need for these new ioctls. - Eric