mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daeho Jeong <daeho43@gmail.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Chao Yu <yuchao0@huawei.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com,
	Daeho Jeong <daehojeong@google.com>
Subject: Re: [f2fs-dev] [PATCH v5 2/2] f2fs: add F2FS_IOC_SET_COMPRESS_OPTION ioctl
Date: Fri, 30 Oct 2020 10:46:16 +0900	[thread overview]
Message-ID: <CACOAw_xc5KYhVgp-b8NTs8vapWxiLF3m-qUMO2qgjp4gQQb2Pw@mail.gmail.com> (raw)
In-Reply-To: <20201029155453.GB849@sol.localdomain>

Chao, got it on f2fs_is_compress_algorithm_valid().
I also agree on Eric's opinion on that error value.

2020년 10월 30일 (금) 오전 12:54, Eric Biggers <ebiggers@kernel.org>님이 작성:
>
> On Thu, Oct 29, 2020 at 03:29:17PM +0800, Chao Yu wrote:
> > > +static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
> > > +{
> > > +   struct inode *inode = file_inode(filp);
> > > +   struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> > > +   struct f2fs_comp_option option;
> > > +   int ret = 0;
> > > +
> > > +   if (!f2fs_sb_has_compression(sbi))
> > > +           return -EOPNOTSUPP;
> > > +
> > > +   if (!(filp->f_mode & FMODE_WRITE))
> > > +           return -EBADF;
> > > +
> > > +   if (copy_from_user(&option, (struct f2fs_comp_option __user *)arg,
> > > +                           sizeof(option)))
> > > +           return -EFAULT;
> > > +
> > > +   if (!f2fs_compressed_file(inode) ||
> > > +                   option.log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
> > > +                   option.log_cluster_size > MAX_COMPRESS_LOG_SIZE ||
> > > +                   option.algorithm >= COMPRESS_MAX)
> > > +           return -EINVAL;
> > > +
> > > +   file_start_write(filp);
> > > +   inode_lock(inode);
> > > +
> > > +   if (f2fs_is_mmap_file(inode) || get_dirty_pages(inode)) {
> > > +           ret = -EBUSY;
> > > +           goto out;
> > > +   }
> > > +
> > > +   if (inode->i_size != 0) {
> > > +           ret = -EFBIG;
> > > +           goto out;
> > > +   }
> >
> > Hmm...
> >
> > Shouldn't it be:
> >
> > if (algorithm >= COMPRESS_MAX) {
> >       ret = -ENOPKG;
> >       goto out;
> > }
> >
> > if (!f2fs_cops[algorithm])
> >       f2fs_warn(...);
>
> Note that my intent with recommending ENOPKG was for it to be returned in the
> !f2fs_cops[algorithm] case, similar to how opening an encrypted file when the
> encryption algorithm is recognized but not supported by the kernel returns
> ENOPKG.  For a truly unrecognized algorithm (algorithm >= COMPRESS_MAX), EINVAL
> would probably be more appropriate.  So if !f2fs_cops[algorithm] is now allowed,
> then ENOPKG should no longer be among the error codes this ioctl returns.
>
> - Eric

  reply	other threads:[~2020-10-30  1:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29  4:15 [PATCH v5 1/2] f2fs: add F2FS_IOC_GET_COMPRESS_OPTION ioctl Daeho Jeong
2020-10-29  4:15 ` [PATCH v5 2/2] f2fs: add F2FS_IOC_SET_COMPRESS_OPTION ioctl Daeho Jeong
2020-10-29  7:29   ` [f2fs-dev] " Chao Yu
2020-10-29  7:39     ` Daeho Jeong
2020-10-29  7:57       ` Chao Yu
2020-10-29 15:54     ` Eric Biggers
2020-10-30  1:46       ` Daeho Jeong [this message]
2020-10-30  1:52       ` Chao Yu
2020-10-29  7:24 ` [f2fs-dev] [PATCH v5 1/2] f2fs: add F2FS_IOC_GET_COMPRESS_OPTION ioctl Chao Yu
2020-10-30  2:37   ` Chao Yu
2020-10-30  3:25     ` Daeho Jeong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACOAw_xc5KYhVgp-b8NTs8vapWxiLF3m-qUMO2qgjp4gQQb2Pw@mail.gmail.com \
    --to=daeho43@gmail.com \
    --cc=daehojeong@google.com \
    --cc=ebiggers@kernel.org \
    --cc=kernel-team@android.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®