Re: [PATCH 4/6] shmem: prepare shmem quota infrastructure

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

 



On Wed 12-04-23 13:14:43, Carlos Maiolino wrote:
> On Wed, Apr 12, 2023 at 12:04:40PM +0200, Jan Kara wrote:
> > Hi Carlos!
> > 
> > On Wed 12-04-23 11:44:32, Carlos Maiolino wrote:
> > > > > > +static int shmem_release_dquot(struct dquot *dquot)
> > > > > > +{
> > > > > > +	struct mem_dqinfo *info = sb_dqinfo(dquot->dq_sb, dquot->dq_id.type);
> > > > > > +	struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node;
> > > > > > +	qid_t id = from_kqid(&init_user_ns, dquot->dq_id);
> > > > > > +	struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
> > > > > > +	struct quota_id *entry = NULL;
> > > > > > +
> > > > > > +	mutex_lock(&dquot->dq_lock);
> > > > > > +	/* Check whether we are not racing with some other dqget() */
> > > > > > +	if (dquot_is_busy(dquot))
> > > > > > +		goto out_dqlock;
> > > > > > +
> > > > > > +	down_write(&dqopt->dqio_sem);
> > > > > > +	while (node) {
> > > > > > +		entry = rb_entry(node, struct quota_id, node);
> > > > > > +
> > > > > > +		if (id < entry->id)
> > > > > > +			node = node->rb_left;
> > > > > > +		else if (id > entry->id)
> > > > > > +			node = node->rb_right;
> > > > > > +		else
> > > > > > +			goto found;
> > > > > > +	}
> > > > > > +
> > > > > > +	up_write(&dqopt->dqio_sem);
> > > > > > +	mutex_unlock(&dquot->dq_lock);
> > > > >
> > > > > We should report some kind of error here, shouldn't we? We do expect to
> > > > > have the quota_id allocated from shmem_acquire_dquot() and we will be
> > > > > possibly loosing set limits here.
> > > > >
> > >
> > > I've been looking into this today, and I'm not sure if there is any error we
> > > should be reporting here, as there isn't anything to really go wrong here. I was
> > > comparing it with other filesystems, and most of them uses dquot_release()
> > > return value, as a return value for .release_dquot. And on such cases, the error
> > > could be other than zero, if something failed while writing the dquot to disk.
> > > In the case here, we just write to the RB tree in memory, and it has already
> > > been allocated, so, I don't think there is any error we could be returning here.
> > > Does it sound right to you?
> > 
> > My point is that it should never happen that we don't find the entry in the
> > rbtree in shmem_release_dquot(). So we should rather WARN_ON_ONCE() and
> > bail or something like that, rather then silently return success. Not a big
> > deal but for initial debugging it might be useful.
> > 
> 
> I see. Thanks Honza. What you think about something like this:
> 
> 	while (node) {
> 		entry = rb_entry(node, struct quota_id, node);
> 
> 		if (id < entry->id)
> 			node = node->rb_left;
> 		else if (id > entry->id)
> 			node = node->rb_right;
> 		else
> 			goto found;
> 	}
> 
> 	/* We should always find the entry in the rb tree */
> 	WARN_ONCE(1, "quota id not in rb tree!\n", __func__)
> 	return -ENOENT;
> 
> 
> I am not sure if -ENOENT is the best error here though. It seems the most
> logical one, as -ENOMEM wouldn't make much sense, any suggestions if you don't
> agree with ENOENT?

Yeah, ENOENT looks good to me. I don't think the error code matters much
here as it is in the "should never happen territory".

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



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

  Powered by Linux