goto out_put_req;
        }
 
+       if ((req->common.ki_flags & IOCB_NOWAIT) &&
+                       !(req->common.ki_flags & IOCB_DIRECT)) {
+               ret = -EOPNOTSUPP;
+               goto out_put_req;
+       }
+
        ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
        if (unlikely(ret)) {
                pr_debug("EFAULT: aio_key\n");
 
 /* File was opened by fanotify and shouldn't generate fanotify events */
 #define FMODE_NONOTIFY         ((__force fmode_t)0x4000000)
 
+/* File is capable of returning -EAGAIN if AIO will block */
+#define FMODE_AIO_NOWAIT       ((__force fmode_t)0x8000000)
+
 /*
  * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
  * that indicates that they should check the contents of the iovec are
 #define IOCB_DSYNC             (1 << 4)
 #define IOCB_SYNC              (1 << 5)
 #define IOCB_WRITE             (1 << 6)
+#define IOCB_NOWAIT            (1 << 7)
 
 struct kiocb {
        struct file             *ki_filp;
        if (unlikely(flags & ~RWF_SUPPORTED))
                return -EOPNOTSUPP;
 
+       if (flags & RWF_NOWAIT) {
+               if (!(ki->ki_filp->f_mode & FMODE_AIO_NOWAIT))
+                       return -EOPNOTSUPP;
+               ki->ki_flags |= IOCB_NOWAIT;
+       }
        if (flags & RWF_HIPRI)
                ki->ki_flags |= IOCB_HIPRI;
        if (flags & RWF_DSYNC)
 
 #define RWF_HIPRI                      0x00000001 /* high priority request, poll if possible */
 #define RWF_DSYNC                      0x00000002 /* per-IO O_DSYNC */
 #define RWF_SYNC                       0x00000004 /* per-IO O_SYNC */
+#define RWF_NOWAIT                     0x00000008 /* per-IO, return -EAGAIN if operation would block */
 
-#define RWF_SUPPORTED                  (RWF_HIPRI | RWF_DSYNC | RWF_SYNC)
+#define RWF_SUPPORTED                  (RWF_HIPRI | RWF_DSYNC | RWF_SYNC |\
+                                        RWF_NOWAIT)
 
 #endif /* _UAPI_LINUX_FS_H */