Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157770990
D5787.id14753.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D5787.id14753.diff
View Options
Index: sys/kern/vfs_aio.c
===================================================================
--- sys/kern/vfs_aio.c
+++ sys/kern/vfs_aio.c
@@ -1173,7 +1173,7 @@
struct cdevsw *csw;
struct cdev *dev;
struct kaioinfo *ki;
- int error, ref, unmap, poff;
+ int error, ref, poff;
vm_prot_t prot;
cb = &job->uaiocb;
@@ -1206,12 +1206,13 @@
ki = p->p_aioinfo;
poff = (vm_offset_t)cb->aio_buf & PAGE_MASK;
- unmap = ((dev->si_flags & SI_UNMAPPED) && unmapped_buf_allowed);
- if (unmap) {
+ if ((dev->si_flags & SI_UNMAPPED) && unmapped_buf_allowed) {
if (cb->aio_nbytes > MAXPHYS) {
error = -1;
goto unref;
}
+
+ pbuf = NULL;
} else {
if (cb->aio_nbytes > MAXPHYS - poff) {
error = -1;
@@ -1221,18 +1222,14 @@
error = -1;
goto unref;
}
- }
- job->bp = bp = g_alloc_bio();
- if (!unmap) {
+
job->pbuf = pbuf = (struct buf *)getpbuf(NULL);
BUF_KERNPROC(pbuf);
- } else
- pbuf = NULL;
-
- AIO_LOCK(ki);
- if (!unmap)
+ AIO_LOCK(ki);
ki->kaio_buffer_count++;
- AIO_UNLOCK(ki);
+ AIO_UNLOCK(ki);
+ }
+ job->bp = bp = g_alloc_bio();
bp->bio_length = cb->aio_nbytes;
bp->bio_bcount = cb->aio_nbytes;
@@ -1246,17 +1243,18 @@
prot = VM_PROT_READ;
if (cb->aio_lio_opcode == LIO_READ)
prot |= VM_PROT_WRITE; /* Less backwards than it looks */
- if ((job->npages = vm_fault_quick_hold_pages(
- &curproc->p_vmspace->vm_map,
+ job->npages = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map,
(vm_offset_t)bp->bio_data, bp->bio_length, prot, job->pages,
- sizeof(job->pages)/sizeof(job->pages[0]))) < 0) {
+ nitems(job->pages));
+ if (job->npages < 0) {
error = EFAULT;
goto doerror;
}
- if (!unmap) {
+ if (pbuf != NULL) {
pmap_qenter((vm_offset_t)pbuf->b_data,
job->pages, job->npages);
bp->bio_data = pbuf->b_data + poff;
+ atomic_add_int(&num_buf_aio, 1);
} else {
bp->bio_ma = job->pages;
bp->bio_ma_n = job->npages;
@@ -1265,20 +1263,16 @@
bp->bio_flags |= BIO_UNMAPPED;
}
- if (!unmap)
- atomic_add_int(&num_buf_aio, 1);
-
/* Perform transfer. */
csw->d_strategy(bp);
dev_relthread(dev, ref);
return (0);
doerror:
- AIO_LOCK(ki);
- if (!unmap)
+ if (pbuf != NULL) {
+ AIO_LOCK(ki);
ki->kaio_buffer_count--;
- AIO_UNLOCK(ki);
- if (pbuf) {
+ AIO_UNLOCK(ki);
relpbuf(pbuf, NULL);
job->pbuf = NULL;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 26, 12:14 AM (18 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33520346
Default Alt Text
D5787.id14753.diff (2 KB)
Attached To
Mode
D5787: Tidy up the unmapped I/O code in qphysio.
Attached
Detach File
Event Timeline
Log In to Comment