From nobody Thu Apr 28 16:41:35 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E36081992160; Thu, 28 Apr 2022 16:41:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Kq1bg637mz4lFC; Thu, 28 Apr 2022 16:41:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651164095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A81hYLuWM3Kxrlrz4iv7ZNrlAatguuYo5GmmeBf2vCA=; b=CPPcnVbOuZJd5uw9NcwSgiw/2DewSJ1a9AnTPiPCqQ9yWJaUBDFMxSswTVbkKp8TChVm7Z VK4uVmn2pyYsfMfgUh2TeG6La+71sP2bsDjQn4FffpfzDe94mUN6XjhBDMJa8HkjBmiqOh n7+hITN8oMpI3yBBoXyoCrS1NRjrb4N/rlEnOMHEluSqq1w81yQtmqDTd4OvByH7eBcLOZ g7WuUIz7kmzCoNSGvoJ7jto46ekc+mDNTg1lDZbnJ99c6Cn6ve4HgMsEfV9sj200rXkqIG v6EnSpVwee6Ffs7GIW3JpapTSmKM7brqbFGQBIlwukp63RyPLaQ+RSLmlo6sTQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B05541C481; Thu, 28 Apr 2022 16:41:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23SGfZ8K072648; Thu, 28 Apr 2022 16:41:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23SGfZXP072647; Thu, 28 Apr 2022 16:41:35 GMT (envelope-from git) Date: Thu, 28 Apr 2022 16:41:35 GMT Message-Id: <202204281641.23SGfZXP072647@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Wing Subject: git: 65c87a6c81f5 - main - geom_dev: extend kevent support for geom dev List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 65c87a6c81f52a8328d81ba9ede5662d9df23a0c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651164095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A81hYLuWM3Kxrlrz4iv7ZNrlAatguuYo5GmmeBf2vCA=; b=FZIjyFWyxD48cyhHj98PCDC3l5MR+k7ysNZyXd3I6mUrecYq639Qjm2wp3ijKE9WhmxH+K B9g7FD069GSvak1s2Dk6gA7Gu3g+OXmyUd3pEDnfOkLj8eFSeZD20tiTUT9pysXOZ8gE/5 cv/H0eL/YV4YnoUDxn0DCLX9xQC0tx8A/oDakutZQZDz0cvlt1BijX6pHYyP7AYNrb/sUi hP/0PyFqZMqK8729sNGaJjZkv2oSvZgvETjgsxmIjrbvFYWSAu48wjH+PBQI8ocPs6cBiN xt6P7LL+3fMEQai0WuP4kmHmZcJPZmwJqmL/sW93P7KyMhdDUVg3MMMWlhDfcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651164095; a=rsa-sha256; cv=none; b=asNEj3fZssFeMBmYT/2SAIRrD0JytRS4Q1rBtIYgxNAr0wNY376mhihq3IaGes40QOrnN7 W18BxYofviRiwdjRVbDn/qaXdW4iSCvo6NSVPQmPiQQCbP5g851VsdgW5C7KUco9uuCggl lwQK0L034x+DRq+ffCjJF4hqTi6H9MRuDcPJxwKnMLtLsJiJA0Ogdu9pqFmff6nBq7z4V5 TdTwFikhNtD/WEhbKIgHTRqwO8S/h5rOzvccJ5RLa20g9E6BzX4w2npFXRjepX15yKVH8O XlVdIKK5d13+7Tv0grGyrb8bXwcI0+23Lg8KrR6M44WFmAjzlqvG2ogrXrnR4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=65c87a6c81f52a8328d81ba9ede5662d9df23a0c commit 65c87a6c81f52a8328d81ba9ede5662d9df23a0c Author: Robert Wing AuthorDate: 2022-04-28 16:40:13 +0000 Commit: Robert Wing CommitDate: 2022-04-28 16:40:13 +0000 geom_dev: extend kevent support for geom dev Add support for the following NOTE events: NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, NOTE_READ, and NOTE_WRITE. Differential Revision: https://reviews.freebsd.org/D34777 --- sys/geom/geom_dev.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index 7bcab1645c4e..ad382b357f2f 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -471,6 +471,7 @@ g_dev_open(struct cdev *dev, int flags, int fmt, struct thread *td) atomic_clear_int(&sc->sc_active, SC_A_OPEN); else atomic_set_int(&sc->sc_active, SC_A_OPEN); + KNOTE_LOCKED(&sc->sc_selinfo.si_note, NOTE_OPEN); mtx_unlock(&sc->sc_mtx); } return (error); @@ -517,6 +518,7 @@ g_dev_close(struct cdev *dev, int flags, int fmt, struct thread *td) atomic_set_int(&sc->sc_active, SC_A_OPEN); while (sc->sc_open == 0 && (sc->sc_active & SC_A_ACTIVE) != 0) msleep(&sc->sc_active, &sc->sc_mtx, 0, "g_dev_close", hz / 10); + KNOTE_LOCKED(&sc->sc_selinfo.si_note, NOTE_CLOSE | (w ? NOTE_CLOSE_WRITE : 0)); mtx_unlock(&sc->sc_mtx); g_topology_lock(); error = g_access(cp, r, w, e); @@ -736,6 +738,10 @@ g_dev_done(struct bio *bp2) bp2, bp2->bio_error); bp->bio_flags |= BIO_ERROR; } else { + if (bp->bio_cmd == BIO_READ) + KNOTE_UNLOCKED(&sc->sc_selinfo.si_note, NOTE_READ); + if (bp->bio_cmd == BIO_WRITE) + KNOTE_UNLOCKED(&sc->sc_selinfo.si_note, NOTE_WRITE); g_trace(G_T_BIO, "g_dev_done(%p/%p) resid %ld completed %jd", bp2, bp, bp2->bio_resid, (intmax_t)bp2->bio_completed); } @@ -893,9 +899,10 @@ g_dev_kqfilter(struct cdev *dev, struct knote *kn) if (kn->kn_filter != EVFILT_VNODE) return (EINVAL); - /* XXX: extend support for other NOTE_* events */ - if (kn->kn_sfflags != NOTE_ATTRIB) - return (EINVAL); +#define SUPPORTED_EVENTS (NOTE_ATTRIB | NOTE_OPEN | NOTE_CLOSE | \ + NOTE_CLOSE_WRITE | NOTE_READ | NOTE_WRITE) + if (kn->kn_sfflags & ~SUPPORTED_EVENTS) + return (EOPNOTSUPP); kn->kn_fop = &gdev_filterops_vnode; kn->kn_hook = sc;