From owner-svn-src-stable-11@freebsd.org Thu Mar 30 20:09:50 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C5629D26835; Thu, 30 Mar 2017 20:09:50 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B2563C9; Thu, 30 Mar 2017 20:09:50 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2UK9nNi046495; Thu, 30 Mar 2017 20:09:49 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2UK9nGp046494; Thu, 30 Mar 2017 20:09:49 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201703302009.v2UK9nGp046494@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Thu, 30 Mar 2017 20:09:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r316298 - stable/11/sys/compat/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Mar 2017 20:09:50 -0000 Author: dchagin Date: Thu Mar 30 20:09:49 2017 New Revision: 316298 URL: https://svnweb.freebsd.org/changeset/base/316298 Log: MFC r314343: Unify eventfd ioctl method and use it for other similar interfaces. Modified: stable/11/sys/compat/linux/linux_event.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linux/linux_event.c ============================================================================== --- stable/11/sys/compat/linux/linux_event.c Thu Mar 30 20:08:25 2017 (r316297) +++ stable/11/sys/compat/linux/linux_event.c Thu Mar 30 20:09:49 2017 (r316298) @@ -177,7 +177,7 @@ static struct fileops timerfdops = { .fo_read = timerfd_read, .fo_write = invfo_rdwr, .fo_truncate = invfo_truncate, - .fo_ioctl = invfo_ioctl, + .fo_ioctl = eventfd_ioctl, .fo_poll = timerfd_poll, .fo_kqfilter = timerfd_kqfilter, .fo_stat = timerfd_stat, @@ -760,7 +760,7 @@ eventfd_read(struct file *fp, struct uio mtx_lock(&efd->efd_lock); retry: if (efd->efd_count == 0) { - if ((efd->efd_flags & LINUX_O_NONBLOCK) != 0) { + if ((fp->f_flag & FNONBLOCK) != 0) { mtx_unlock(&efd->efd_lock); return (EAGAIN); } @@ -811,7 +811,7 @@ eventfd_write(struct file *fp, struct ui mtx_lock(&efd->efd_lock); retry: if (UINT64_MAX - efd->efd_count <= count) { - if ((efd->efd_flags & LINUX_O_NONBLOCK) != 0) { + if ((fp->f_flag & FNONBLOCK) != 0) { mtx_unlock(&efd->efd_lock); /* Do not not return the number of bytes written */ uio->uio_resid += sizeof(eventfd_t); @@ -927,19 +927,18 @@ static int eventfd_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td) { - struct eventfd *efd; - efd = fp->f_data; - if (fp->f_type != DTYPE_LINUXEFD || efd == NULL) + if (fp->f_data == NULL || (fp->f_type != DTYPE_LINUXEFD && + fp->f_type != DTYPE_LINUXTFD)) return (EINVAL); switch (cmd) { case FIONBIO: - if (*(int *)data) - efd->efd_flags |= LINUX_O_NONBLOCK; + if ((*(int *)data)) + atomic_set_int(&fp->f_flag, FNONBLOCK); else - efd->efd_flags &= ~LINUX_O_NONBLOCK; + atomic_clear_int(&fp->f_flag, FNONBLOCK); case FIOASYNC: return (0); default: