Skip to content

Commit

Permalink
aio: remove write-only jobid & kernelinfo
Browse files Browse the repository at this point in the history
The jobid (which was stored in kernelinfo) was used to look up
jobs until 1ce9182, where it became essentially write only.
Remove it to simplify the code and pave the way for future work
to make aio scale better.

Note this has been slated for removal "soon" for 18 years.

Suggested by: jhb
Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D47583
  • Loading branch information
Andrew Gallatin authored and Andrew Gallatin committed Nov 15, 2024
1 parent 79af8f7 commit 4605a99
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 42 deletions.
42 changes: 1 addition & 41 deletions sys/kern/vfs_aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@
#include <vm/uma.h>
#include <sys/aio.h>

/*
* Counter for allocating reference ids to new jobs. Wrapped to 1 on
* overflow. (XXX will be removed soon.)
*/
static u_long jobrefid;

/*
* Counter for aio_fsync.
*/
Expand Down Expand Up @@ -297,7 +291,6 @@ struct aiocb_ops {
long (*fetch_error)(struct aiocb *ujob);
int (*store_status)(struct aiocb *ujob, long status);
int (*store_error)(struct aiocb *ujob, long error);
int (*store_kernelinfo)(struct aiocb *ujob, long jobref);
int (*store_aiocb)(struct aiocb **ujobp, struct aiocb *ujob);
};

Expand Down Expand Up @@ -418,7 +411,6 @@ aio_onceonly(void)
aiolio_zone = uma_zcreate("AIOLIO", sizeof(struct aioliojob), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
aiod_lifetime = AIOD_LIFETIME_DEFAULT;
jobrefid = 1;
p31b_setcfg(CTL_P1003_1B_ASYNCHRONOUS_IO, _POSIX_ASYNCHRONOUS_IO);
p31b_setcfg(CTL_P1003_1B_AIO_MAX, MAX_AIO_QUEUE);
p31b_setcfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, 0);
Expand Down Expand Up @@ -1455,13 +1447,6 @@ aiocb_store_error(struct aiocb *ujob, long error)
return (suword(&ujob->_aiocb_private.error, error));
}

static int
aiocb_store_kernelinfo(struct aiocb *ujob, long jobref)
{

return (suword(&ujob->_aiocb_private.kernelinfo, jobref));
}

static int
aiocb_store_aiocb(struct aiocb **ujobp, struct aiocb *ujob)
{
Expand All @@ -1475,7 +1460,6 @@ static struct aiocb_ops aiocb_ops = {
.fetch_error = aiocb_fetch_error,
.store_status = aiocb_store_status,
.store_error = aiocb_store_error,
.store_kernelinfo = aiocb_store_kernelinfo,
.store_aiocb = aiocb_store_aiocb,
};

Expand All @@ -1486,7 +1470,6 @@ static struct aiocb_ops aiocb_ops_osigevent = {
.fetch_error = aiocb_fetch_error,
.store_status = aiocb_store_status,
.store_error = aiocb_store_error,
.store_kernelinfo = aiocb_store_kernelinfo,
.store_aiocb = aiocb_store_aiocb,
};
#endif
Expand All @@ -1507,7 +1490,6 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
int opcode;
int error;
int fd, kqfd;
int jid;
u_short evflags;

if (p->p_aioinfo == NULL)
Expand All @@ -1517,7 +1499,6 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,

ops->store_status(ujob, -1);
ops->store_error(ujob, 0);
ops->store_kernelinfo(ujob, -1);

if (num_queue_count >= max_queue_count ||
ki->kaio_count >= max_aio_queue_per_proc) {
Expand Down Expand Up @@ -1630,16 +1611,8 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
job->fd_file = fp;

mtx_lock(&aio_job_mtx);
jid = jobrefid++;
job->seqno = jobseqno++;
mtx_unlock(&aio_job_mtx);
error = ops->store_kernelinfo(ujob, jid);
if (error) {
error = EINVAL;
goto err3;
}
job->uaiocb._aiocb_private.kernelinfo = (void *)(intptr_t)jid;

if (opcode == LIO_NOP) {
fdrop(fp, td);
MPASS(job->uiop == &job->uio || job->uiop == NULL);
Expand Down Expand Up @@ -2728,7 +2701,7 @@ filt_lio(struct knote *kn, long hint)
struct __aiocb_private32 {
int32_t status;
int32_t error;
uint32_t kernelinfo;
uint32_t spare;
};

#ifdef COMPAT_FREEBSD6
Expand Down Expand Up @@ -2807,7 +2780,6 @@ aiocb32_copyin_old_sigevent(struct aiocb *ujob, struct kaiocb *kjob,
CP(job32, *kcb, aio_reqprio);
CP(job32, *kcb, _aiocb_private.status);
CP(job32, *kcb, _aiocb_private.error);
PTRIN_CP(job32, *kcb, _aiocb_private.kernelinfo);
return (convert_old_sigevent32(&job32.aio_sigevent,
&kcb->aio_sigevent));
}
Expand Down Expand Up @@ -2844,7 +2816,6 @@ aiocb32_copyin(struct aiocb *ujob, struct kaiocb *kjob, int type)
CP(job32, *kcb, aio_reqprio);
CP(job32, *kcb, _aiocb_private.status);
CP(job32, *kcb, _aiocb_private.error);
PTRIN_CP(job32, *kcb, _aiocb_private.kernelinfo);
error = convert_sigevent32(&job32.aio_sigevent, &kcb->aio_sigevent);

return (error);
Expand Down Expand Up @@ -2886,15 +2857,6 @@ aiocb32_store_error(struct aiocb *ujob, long error)
return (suword32(&ujob32->_aiocb_private.error, error));
}

static int
aiocb32_store_kernelinfo(struct aiocb *ujob, long jobref)
{
struct aiocb32 *ujob32;

ujob32 = (struct aiocb32 *)ujob;
return (suword32(&ujob32->_aiocb_private.kernelinfo, jobref));
}

static int
aiocb32_store_aiocb(struct aiocb **ujobp, struct aiocb *ujob)
{
Expand All @@ -2908,7 +2870,6 @@ static struct aiocb_ops aiocb32_ops = {
.fetch_error = aiocb32_fetch_error,
.store_status = aiocb32_store_status,
.store_error = aiocb32_store_error,
.store_kernelinfo = aiocb32_store_kernelinfo,
.store_aiocb = aiocb32_store_aiocb,
};

Expand All @@ -2919,7 +2880,6 @@ static struct aiocb_ops aiocb32_ops_osigevent = {
.fetch_error = aiocb32_fetch_error,
.store_status = aiocb32_store_status,
.store_error = aiocb32_store_error,
.store_kernelinfo = aiocb32_store_kernelinfo,
.store_aiocb = aiocb32_store_aiocb,
};
#endif
Expand Down
2 changes: 1 addition & 1 deletion sys/sys/aio.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
struct __aiocb_private {
long status;
long error;
void *kernelinfo;
void *spare;
};

/*
Expand Down

0 comments on commit 4605a99

Please sign in to comment.