Re: [RFC PATCH v3 09/16] ceph: preallocate inode for ops that may create one

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 14, 2020 at 03:17:00PM -0400, Jeff Layton wrote:
> @@ -663,6 +658,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
>  	struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
>  	struct ceph_mds_client *mdsc = fsc->mdsc;
>  	struct ceph_mds_request *req;
> +	struct inode *new_inode = NULL;
>  	struct dentry *dn;
>  	struct ceph_acl_sec_ctx as_ctx = {};
>  	bool try_async = ceph_test_mount_opt(fsc, ASYNC_DIROPS);
> @@ -675,21 +671,21 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
>  
>  	if (dentry->d_name.len > NAME_MAX)
>  		return -ENAMETOOLONG;
> -
> +retry:
>  	if (flags & O_CREAT) {
>  		if (ceph_quota_is_max_files_exceeded(dir))
>  			return -EDQUOT;
> -		err = ceph_pre_init_acls(dir, &mode, &as_ctx);
> -		if (err < 0)
> -			return err;
> -		err = ceph_security_init_secctx(dentry, mode, &as_ctx);
> -		if (err < 0)
> +
> +		new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx);
> +		if (IS_ERR(new_inode)) {
> +			err = PTR_ERR(new_inode);
>  			goto out_ctx;
> +		}

Is the 'goto out_ctx;' correct here?  It looks like it should be
'return PTR_ERR(new_inode)'

> +/**
> + * ceph_new_inode - allocate a new inode in advance of an expected create
> + * @dir: parent directory for new inode
> + * @mode: mode of new inode
> + */
> +struct inode *ceph_new_inode(struct inode *dir, struct dentry *dentry,
> +			     umode_t *mode, struct ceph_acl_sec_ctx *as_ctx)

Some parameters aren't documented.

> +	int err;
>  	struct inode *inode;
>  
> -	inode = iget5_locked(sb, (unsigned long)vino.ino, ceph_ino_compare,
> -			     ceph_set_ino_cb, &vino);
> +	inode = new_inode_pseudo(dir->i_sb);
>  	if (!inode)
>  		return ERR_PTR(-ENOMEM);
>  
> +	if (!S_ISLNK(*mode)) {
> +		err = ceph_pre_init_acls(dir, mode, as_ctx);
> +		if (err < 0)
> +			goto out_err;
> +	}
> +
> +	err = ceph_security_init_secctx(dentry, *mode, as_ctx);
> +	if (err < 0)
> +		goto out_err;
> +
> +	inode->i_state = 0;
> +	inode->i_mode = *mode;
> +	return inode;
> +out_err:
> +	iput(inode);
> +	return ERR_PTR(err);
> +}

Should this be freeing anything from the ceph_acl_sec_ctx on error?

- Eric



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux