From: Sun YangKai <sunk67188@gmail.com>
To: dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/5] btrfs: add new ioctl CLEAR_FREE
Date: Sat, 01 Mar 2025 11:19:13 +0800 [thread overview]
Message-ID: <8510159.T7Z3S40VBb@saltykitkat> (raw)
In-Reply-To: <ecc43a72997ae7836c2d227b69924d364698e665.1740753608.git.dsterba@suse.com>
New to lkml, please correct me if I made any mistake :P
> +static int btrfs_ioctl_clear_free(struct file *file, void __user *arg)
> +{
> + struct btrfs_fs_info *fs_info;
> + struct btrfs_ioctl_clear_free_args args;
> + u64 total_bytes;
> + int ret;
> +
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
> +
> + if (copy_from_user(&args, arg, sizeof(args)))
> + return -EFAULT;
> +
> + if (args.type >= BTRFS_NR_CLEAR_OP_TYPES)
> + return -EOPNOTSUPP;
> +
> + ret = mnt_want_write_file(file);
> + if (ret)
> + return ret;
> +
> + fs_info = inode_to_fs_info(file_inode(file));
> + total_bytes = btrfs_super_total_bytes(fs_info->super_copy);
> + if (args.start > total_bytes) {
> + ret = -EINVAL;
> + goto out_drop_write;
> + }
> +
> + ret = btrfs_clear_free_space(fs_info, &args);
> + if (ret < 0)
> + goto out_drop_write;
> +
> + if (copy_to_user(arg, &args, sizeof(args)))
> + ret = -EFAULT;
> +
> +out_drop_write:
> + mnt_drop_write_file(file);
> +
> + return 0;
previous stored return value int `ret` is not used here.
> +}
next prev parent reply other threads:[~2025-03-01 3:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 14:49 [PATCH 0/5] Ioctl to clear unused space in various ways David Sterba
2025-02-28 14:49 ` [PATCH 1/5] btrfs: extend trim callchains to pass the operation type David Sterba
2025-02-28 14:49 ` [PATCH 2/5] btrfs: add new ioctl CLEAR_FREE David Sterba
2025-03-01 3:19 ` Sun YangKai [this message]
2025-03-03 8:43 ` David Sterba
2025-03-03 8:47 ` David Sterba
2025-03-10 16:38 ` Johannes Thumshirn
2025-03-10 20:18 ` David Sterba
2025-03-11 0:11 ` Damien Le Moal
2025-03-11 18:39 ` David Sterba
2025-02-28 14:49 ` [PATCH 3/5] btrfs: add zeroout mode to CLEAR_FREE ioctl David Sterba
2025-02-28 14:49 ` [PATCH 4/5] btrfs: add secure erase " David Sterba
2025-02-28 14:49 ` [PATCH 5/5] btrfs: add more zeroout modes " David Sterba
2025-03-05 11:01 ` [PATCH 0/5] Ioctl to clear unused space in various ways David Sterba
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=8510159.T7Z3S40VBb@saltykitkat \
--to=sunk67188@gmail.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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