Re: [PATCH 7/7] ubifs: Add quota support

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

 



Hi Sascha!

On Mon 11-11-19 09:57:45, Sascha Hauer wrote:
> On Wed, Nov 06, 2019 at 11:14:28AM +0100, Jan Kara wrote:
> > > +/**
> > > + * ubifs_dqblk_find_next - find the next qid
> > > + * @c: UBIFS file-system description object
> > > + * @qid: The qid to look for
> > > + *
> > > + * Find the next dqblk entry with a qid that is bigger or equally big than the
> > > + * given qid. Returns the next dqblk entry if found or NULL if no dqblk exists
> > > + * with a qid that is at least equally big.
> > > + */
> > > +static struct ubifs_dqblk *ubifs_dqblk_find_next(struct ubifs_info *c,
> > > +						 struct kqid qid)
> > > +{
> > > +	struct rb_node *node = c->dqblk_tree[qid.type].rb_node;
> > > +	struct ubifs_dqblk *next = NULL;
> > > +
> > > +	while (node) {
> > > +		struct ubifs_dqblk *ud = rb_entry(node, struct ubifs_dqblk, rb);
> > > +
> > > +		if (qid_eq(qid, ud->kqid))
> > > +			return ud;
> > > +
> > > +		if (qid_lt(qid, ud->kqid)) {
> > > +			if (!next || qid_lt(ud->kqid, next->kqid))
			^^^
This condition looks superfluous as it should be always true. The last node
where you went left should be the least greater node if you didn't find the
exact match...

> > > +				next = ud;
> > > +
> > > +			node = node->rb_left;
> > > +		} else {
> > > +			node = node->rb_right;
> > > +		}
> > > +	}
> > > +
> > > +	return next;
> > > +}
> > 
> > Why not use rb_next() here? It should do what you need, shouldn't it?
> 
> I could use rb_next(), but it defeats the purpose of a tree to iterate
> over the whole tree to find an entry. If I wanted that I would have used
> a list.

I wasn't quite clear in my suggestion and now that I look at it it was
actually misleading. I'm sorry for that. So a second try :):

You have ubifs_dqblk_find() and ubifs_dqblk_find_next() doing very similar
rbtree traversal. I think you could remove that duplication by using
ubifs_dqblk_find_next() from ubifs_dqblk_find()?

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



[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