All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Liu <jeff.liu@oracle.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org, anand.jain@oracle.com,
	miaox@cn.fujitsu.com, Goffredo Baroncelli <kreijack@gmail.com>
Subject: Re: [RFC PATCH v8 2/2] Btrfs: Add a new ioctl to set/change the label of a mounted file system
Date: Mon, 31 Dec 2012 18:23:38 +0800	[thread overview]
Message-ID: <50E167AA.7000603@oracle.com> (raw)
In-Reply-To: <20121228120333.GV14116@twin.jikos.cz>

On 12/28/2012 08:03 PM, David Sterba wrote:
> On Fri, Dec 28, 2012 at 11:42:40AM +0800, Jeff Liu wrote:
>> +static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg)
>> +{
>> +	struct btrfs_root *root = BTRFS_I(fdentry(file)->d_inode)->root;
>> +	struct btrfs_super_block *super_block = root->fs_info->super_copy;
>> +	struct btrfs_trans_handle *trans;
>> +	char label[BTRFS_LABEL_SIZE];
>> +	int ret;
>> +
>> +	if (!capable(CAP_SYS_ADMIN))
>> +		return -EPERM;
>> +
>> +	if (copy_from_user(label, arg, sizeof(label)))
>> +		return -EFAULT;
>> +
>> +	if (strnlen(label, BTRFS_LABEL_SIZE) == BTRFS_LABEL_SIZE)
> 
> I would expect a message if this happens, similar to the 'get_fslabel'
> one, otherwise it's difficult to find out the reason.
That's sounds make sense.
> 
>> +		return -EINVAL;
>> +
>> +	ret = mnt_want_write_file(file);
>> +	if (ret)
>> +		return ret;
>> +
>> +	mutex_lock(&root->fs_info->volume_mutex);
>> +	trans = btrfs_start_transaction(root, 1);
> 
> Do we need to reserve 1 unit here? This does not touch any
> non-superblock metadata, modifies superblock in place. This could lead
> to an ENOSPC (changing label on a full fs), altghouh it need not happen.
Don't need, I can not recalled why I did that before, will fix it.

Thanks,
-Jeff
> 
>> +	if (IS_ERR(trans)) {
>> +		ret = PTR_ERR(trans);
>> +		goto out_unlock;
>> +	}
>> +
>> +	strcpy(super_block->label, label);
>> +	ret = btrfs_end_transaction(trans, root);
>> +
>> +out_unlock:
>> +	mutex_unlock(&root->fs_info->volume_mutex);
>> +	mnt_drop_write_file(file);
>> +	return ret;
>> +}


      reply	other threads:[~2012-12-31 10:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-28  3:42 [RFC PATCH v8 0/2] Btrfs: get/set label of a mounted file system Jeff Liu
2012-12-28  3:42 ` [RFC PATCH v8 1/2] Btrfs: Add a new ioctl to get the " Jeff Liu
2012-12-28 11:51   ` David Sterba
2012-12-28  3:42 ` [RFC PATCH v8 2/2] Btrfs: Add a new ioctl to set/change " Jeff Liu
2012-12-28 12:03   ` David Sterba
2012-12-31 10:23     ` Jeff Liu [this message]

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=50E167AA.7000603@oracle.com \
    --to=jeff.liu@oracle.com \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=kreijack@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=miaox@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.