Re: [PATCH RFC 0/4] fs: port files to rcuref_long_t

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

 



On Sat, Oct 05, 2024 at 03:01:45PM GMT, Linus Torvalds wrote:
> On Sat, 5 Oct 2024 at 14:42, Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > and I think that might work, although the zero count case worries me
> > (ie 'fput twice').
> >
> > Currently we avoid the fput twice because we use that
> > "inc_not_zero()". So that needs some thinking about.
> 
> Actually, it's worse. Even the
> 
>         if (ret > 1)
> 
> case is dangerous, because we could have two or more threads doing
> that atomic_inc_return() on a dead file descriptor at the same time.
> 
> So that approach is just broken.

Iiuc, then we should retain the deadzone handling but should replace
atomic_long_add_negative() with atomic_long_add_negative_relaxed().

So I would add:

static inline __must_check bool rcuref_long_inc(rcuref_long_t *ref)
{
	/*
	 * Unconditionally increase the reference count with full
	 * ordering. The saturation and dead zones provide enough
	 * tolerance for this.
	 */
	if (likely(!atomic_long_add_negative(1, &ref->refcnt)))
		return true;

	/* Handle the cases inside the saturation and dead zones */
	return rcuref_long_get_slowpath(ref);
}

Or did I miss something else?




[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