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, 2020-09-14 at 18:30 -0700, Eric Biggers wrote:
> 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)'
> 

Yes, it's correct...see below.

> > +/**
> > + * 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.
> 

Thanks, fixed.

> > +	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?
> 

For now, I'm leaving that to the callers. It's arguably uglier to do it
that way but ceph_release_acl_sec_ctx needs to be called at the end of
the callers anyway, and it's not currently idempotent.

-- 
Jeff Layton <jlayton@xxxxxxxxxx>




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux