diff options
author | jeff <jeff@FreeBSD.org> | 2009-06-02 06:55:32 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2009-06-02 06:55:32 +0000 |
commit | 7bd92180e74fab8260b697c4de1f4bfe36a17a4a (patch) | |
tree | 7011b0e00fdf71efc1e4de53d50f1121481d9b87 | |
parent | 6ae620b4f5311ca09905a5dfa91a97adb6bbd03d (diff) | |
download | FreeBSD-src-7bd92180e74fab8260b697c4de1f4bfe36a17a4a.zip FreeBSD-src-7bd92180e74fab8260b697c4de1f4bfe36a17a4a.tar.gz |
- Use an acquire barrier to increment f_count in fget_unlocked and
remove the volatile cast. Describe the reason in detail in a comment.
Discussed with: bde, jhb
-rw-r--r-- | sys/kern/kern_descrip.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index c93d05a..1221825 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2075,9 +2075,13 @@ fget_unlocked(struct filedesc *fdp, int fd) count = fp->f_count; if (count == 0) continue; - if (atomic_cmpset_int(&fp->f_count, count, count + 1) != 1) + /* + * Use an acquire barrier to prevent caching of fd_ofiles + * so it is refreshed for verification. + */ + if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) != 1) continue; - if (fp == ((struct file *volatile*)fdp->fd_ofiles)[fd]) + if (fp == fdp->fd_ofiles[fd]) break; fdrop(fp, curthread); } |