Re: [PATCH 4/4] ext4: Improve scalability of ext4 orphan file handling

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

 



On Wed 30-06-21 15:46:35, Lukas Czerner wrote:
> On Wed, Jun 16, 2021 at 12:56:55PM +0200, Jan Kara wrote:
> > @@ -28,28 +42,24 @@ static int ext4_orphan_file_add(handle_t *handle, struct inode *inode)
> >  		 */
> >  		return -ENOSPC;
> >  	}
> > -	oi->of_binfo[i].ob_free_entries--;
> > -	spin_unlock(&oi->of_lock);
> >  
> > -	/*
> > -	 * Get access to orphan block. We have dropped of_lock but since we
> > -	 * have decremented number of free entries we are guaranteed free entry
> > -	 * in our block.
> > -	 */
> >  	ret = ext4_journal_get_write_access(handle, inode->i_sb,
> >  				oi->of_binfo[i].ob_bh, EXT4_JTR_ORPHAN_FILE);
> >  	if (ret)
> >  		return ret;
> >  
> >  	bdata = (__le32 *)(oi->of_binfo[i].ob_bh->b_data);
> > -	spin_lock(&oi->of_lock);
> >  	/* Find empty slot in a block */
> > -	for (j = 0; j < inodes_per_ob && bdata[j]; j++);
> > -	BUG_ON(j == inodes_per_ob);
> > -	bdata[j] = cpu_to_le32(inode->i_ino);
> > +	j = 0;
> > +	do {
> > +		while (bdata[j]) {
> > +			if (++j >= inodes_per_ob)
> > +				j = 0;
> > +		}
> > +	} while (cmpxchg(&bdata[j], 0, cpu_to_le32(inode->i_ino)) != 0);
> 
> In case there is any sort of corruption on disk or in memory we can
> potentially get stuck here forever right ? Not sure if that matters
> all that much.
> 
> Other than that it looks good and negates some of my comments on the
> previous patch, sorry about that ;)
> 
> You can add
> 
> Reviewed-by: Lukas Czerner <lczerner@xxxxxxxxxx>

Good point. I've added some limitations (and cond_resched()) to the loop so
that we cannot loop indefinitely. Thanks for review!

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



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux