Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 
0003 #include <linux/net.h>
0004 #include <linux/uio.h>
0005 #include <net/sock.h>
0006 #include <linux/nospec.h>
0007 
0008 #include "rsrc.h"
0009 
0010 #define IO_NOTIF_SPLICE_BATCH   32
0011 
0012 struct io_notif_data {
0013     struct file     *file;
0014     struct ubuf_info    uarg;
0015     unsigned long       account_pages;
0016 };
0017 
0018 void io_notif_flush(struct io_kiocb *notif);
0019 struct io_kiocb *io_alloc_notif(struct io_ring_ctx *ctx);
0020 
0021 static inline struct io_notif_data *io_notif_to_data(struct io_kiocb *notif)
0022 {
0023     return io_kiocb_to_cmd(notif, struct io_notif_data);
0024 }
0025 
0026 static inline int io_notif_account_mem(struct io_kiocb *notif, unsigned len)
0027 {
0028     struct io_ring_ctx *ctx = notif->ctx;
0029     struct io_notif_data *nd = io_notif_to_data(notif);
0030     unsigned nr_pages = (len >> PAGE_SHIFT) + 2;
0031     int ret;
0032 
0033     if (ctx->user) {
0034         ret = __io_account_mem(ctx->user, nr_pages);
0035         if (ret)
0036             return ret;
0037         nd->account_pages += nr_pages;
0038     }
0039     return 0;
0040 }