svn commit: r368703 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Wed Dec 16 18:01:41 UTC 2020


Author: mjg
Date: Wed Dec 16 18:01:41 2020
New Revision: 368703
URL: https://svnweb.freebsd.org/changeset/base/368703

Log:
  fd: remove redundant saturation check from fget_unlocked_seq
  
  refcount_acquire_if_not_zero returns true on saturation.
  The case of 0 is handled by looping again, after which the originally
  found pointer will no longer be there.
  
  Noted by:	kib

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Wed Dec 16 17:09:38 2020	(r368702)
+++ head/sys/kern/kern_descrip.c	Wed Dec 16 18:01:41 2020	(r368703)
@@ -3022,13 +3022,6 @@ fget_unlocked_seq(struct filedesc *fdp, int fd, cap_ri
 #endif
 		if (__predict_false(!refcount_acquire_if_not_zero(&fp->f_count))) {
 			/*
-			 * The count was found either saturated or zero.
-			 * This re-read is not any more racy than using the
-			 * return value from fcmpset.
-			 */
-			if (refcount_load(&fp->f_count) != 0)
-				return (EBADF);
-			/*
 			 * Force a reload. Other thread could reallocate the
 			 * table before this fd was closed, so it is possible
 			 * that there is a stale fp pointer in cached version.


More information about the svn-src-all mailing list