* [PATCH] mshv_eventfd: convert to CLASS(fd)
@ 2025-07-12 16:52 Al Viro
2025-07-15 1:51 ` Wei Liu
2025-07-15 17:15 ` Nuno Das Neves
0 siblings, 2 replies; 3+ messages in thread
From: Al Viro @ 2025-07-12 16:52 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-hyperv
[in viro/vfs.git #work.fd; if nobody objects, into #for-next it goes...]
similar to 66635b077624 ("assorted variants of irqfd setup: convert
to CLASS(fd)") a year ago...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c
index 8dd22be2ca0b..48c514da34eb 100644
--- a/drivers/hv/mshv_eventfd.c
+++ b/drivers/hv/mshv_eventfd.c
@@ -377,10 +377,11 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
struct eventfd_ctx *eventfd = NULL, *resamplefd = NULL;
struct mshv_irqfd *irqfd, *tmp;
unsigned int events;
- struct fd f;
int ret;
int idx;
+ CLASS(fd, f)(args->fd);
+
irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL);
if (!irqfd)
return -ENOMEM;
@@ -390,8 +391,7 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
INIT_WORK(&irqfd->irqfd_shutdown, mshv_irqfd_shutdown);
seqcount_spinlock_init(&irqfd->irqfd_irqe_sc, &pt->pt_irqfds_lock);
- f = fdget(args->fd);
- if (!fd_file(f)) {
+ if (fd_empty(f)) {
ret = -EBADF;
goto out;
}
@@ -496,12 +496,6 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
mshv_assert_irq_slow(irqfd);
srcu_read_unlock(&pt->pt_irq_srcu, idx);
- /*
- * do not drop the file until the irqfd is fully initialized, otherwise
- * we might race against the POLLHUP
- */
- fdput(f);
-
return 0;
fail:
@@ -514,8 +508,6 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
if (eventfd && !IS_ERR(eventfd))
eventfd_ctx_put(eventfd);
- fdput(f);
-
out:
kfree(irqfd);
return ret;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mshv_eventfd: convert to CLASS(fd)
2025-07-12 16:52 [PATCH] mshv_eventfd: convert to CLASS(fd) Al Viro
@ 2025-07-15 1:51 ` Wei Liu
2025-07-15 17:15 ` Nuno Das Neves
1 sibling, 0 replies; 3+ messages in thread
From: Wei Liu @ 2025-07-15 1:51 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, linux-hyperv, Wei Liu
On Sat, Jul 12, 2025 at 05:52:44PM +0100, Al Viro wrote:
> [in viro/vfs.git #work.fd; if nobody objects, into #for-next it goes...]
>
> similar to 66635b077624 ("assorted variants of irqfd setup: convert
> to CLASS(fd)") a year ago...
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Thanks for the patch, Al.
Acked-by: Wei Liu <wei.liu@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mshv_eventfd: convert to CLASS(fd)
2025-07-12 16:52 [PATCH] mshv_eventfd: convert to CLASS(fd) Al Viro
2025-07-15 1:51 ` Wei Liu
@ 2025-07-15 17:15 ` Nuno Das Neves
1 sibling, 0 replies; 3+ messages in thread
From: Nuno Das Neves @ 2025-07-15 17:15 UTC (permalink / raw)
To: Al Viro, linux-fsdevel; +Cc: linux-hyperv
On 7/12/2025 9:52 AM, Al Viro wrote:
> [in viro/vfs.git #work.fd; if nobody objects, into #for-next it goes...]
>
> similar to 66635b077624 ("assorted variants of irqfd setup: convert
> to CLASS(fd)") a year ago...
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
> diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c
> index 8dd22be2ca0b..48c514da34eb 100644
> --- a/drivers/hv/mshv_eventfd.c
> +++ b/drivers/hv/mshv_eventfd.c
> @@ -377,10 +377,11 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
> struct eventfd_ctx *eventfd = NULL, *resamplefd = NULL;
> struct mshv_irqfd *irqfd, *tmp;
> unsigned int events;
> - struct fd f;
> int ret;
> int idx;
>
> + CLASS(fd, f)(args->fd);
> +
> irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL);
> if (!irqfd)
> return -ENOMEM;
> @@ -390,8 +391,7 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
> INIT_WORK(&irqfd->irqfd_shutdown, mshv_irqfd_shutdown);
> seqcount_spinlock_init(&irqfd->irqfd_irqe_sc, &pt->pt_irqfds_lock);
>
> - f = fdget(args->fd);
> - if (!fd_file(f)) {
> + if (fd_empty(f)) {
> ret = -EBADF;
> goto out;
> }
> @@ -496,12 +496,6 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
> mshv_assert_irq_slow(irqfd);
>
> srcu_read_unlock(&pt->pt_irq_srcu, idx);
> - /*
> - * do not drop the file until the irqfd is fully initialized, otherwise
> - * we might race against the POLLHUP
> - */
> - fdput(f);
> -
> return 0;
>
> fail:
> @@ -514,8 +508,6 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
> if (eventfd && !IS_ERR(eventfd))
> eventfd_ctx_put(eventfd);
>
> - fdput(f);
> -
> out:
> kfree(irqfd);
> return ret;
Looks fine to me, thanks.
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-15 17:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12 16:52 [PATCH] mshv_eventfd: convert to CLASS(fd) Al Viro
2025-07-15 1:51 ` Wei Liu
2025-07-15 17:15 ` Nuno Das Neves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).