Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kvack.org/~bcrl/aio-next

Pull aio updates from Benjamin LaHaise.

* git://git.kvack.org/~bcrl/aio-next:
aio: Skip timer for io_getevents if timeout=0
aio: Make it possible to remap aio ring

+34 -3
+31 -2
fs/aio.c
··· 286 286 287 287 static int aio_ring_mmap(struct file *file, struct vm_area_struct *vma) 288 288 { 289 + vma->vm_flags |= VM_DONTEXPAND; 289 290 vma->vm_ops = &generic_file_vm_ops; 290 291 return 0; 291 292 } 292 293 294 + static void aio_ring_remap(struct file *file, struct vm_area_struct *vma) 295 + { 296 + struct mm_struct *mm = vma->vm_mm; 297 + struct kioctx_table *table; 298 + int i; 299 + 300 + spin_lock(&mm->ioctx_lock); 301 + rcu_read_lock(); 302 + table = rcu_dereference(mm->ioctx_table); 303 + for (i = 0; i < table->nr; i++) { 304 + struct kioctx *ctx; 305 + 306 + ctx = table->table[i]; 307 + if (ctx && ctx->aio_ring_file == file) { 308 + ctx->user_id = ctx->mmap_base = vma->vm_start; 309 + break; 310 + } 311 + } 312 + 313 + rcu_read_unlock(); 314 + spin_unlock(&mm->ioctx_lock); 315 + } 316 + 293 317 static const struct file_operations aio_ring_fops = { 294 318 .mmap = aio_ring_mmap, 319 + .mremap = aio_ring_remap, 295 320 }; 296 321 297 322 #if IS_ENABLED(CONFIG_MIGRATION) ··· 1253 1228 * the ringbuffer empty. So in practice we should be ok, but it's 1254 1229 * something to be aware of when touching this code. 1255 1230 */ 1256 - wait_event_interruptible_hrtimeout(ctx->wait, 1257 - aio_read_events(ctx, min_nr, nr, event, &ret), until); 1231 + if (until.tv64 == 0) 1232 + aio_read_events(ctx, min_nr, nr, event, &ret); 1233 + else 1234 + wait_event_interruptible_hrtimeout(ctx->wait, 1235 + aio_read_events(ctx, min_nr, nr, event, &ret), 1236 + until); 1258 1237 1259 1238 if (!ret && signal_pending(current)) 1260 1239 ret = -EINTR;
+1
include/linux/fs.h
··· 1518 1518 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1519 1519 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1520 1520 int (*mmap) (struct file *, struct vm_area_struct *); 1521 + void (*mremap)(struct file *, struct vm_area_struct *); 1521 1522 int (*open) (struct inode *, struct file *); 1522 1523 int (*flush) (struct file *, fl_owner_t id); 1523 1524 int (*release) (struct inode *, struct file *);
+2 -1
mm/mremap.c
··· 288 288 old_len = new_len; 289 289 old_addr = new_addr; 290 290 new_addr = -ENOMEM; 291 - } 291 + } else if (vma->vm_file && vma->vm_file->f_op->mremap) 292 + vma->vm_file->f_op->mremap(vma->vm_file, new_vma); 292 293 293 294 /* Conceal VM_ACCOUNT so old reservation is not undone */ 294 295 if (vm_flags & VM_ACCOUNT) {