On Fri, Apr 14, 2017 at 07:02:57AM -0500, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> > > Return EAGAIN if any of the following checks fail > + i_rwsem is not lockable > + NODATACOW or PREALLOC is not set > + Cannot nocow at the desired location > + Writing beyond end of file which is not allocated > > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx> Acked-by: David Sterba <dsterba@xxxxxxxx> > + if ((iocb->ki_flags & IOCB_NOWAIT) && > + (iocb->ki_flags & IOCB_DIRECT)) { > + /* Don't sleep on inode rwsem */ > + if (!inode_trylock(inode)) > + return -EAGAIN; > + /* > + * We will allocate space in case nodatacow is not set, > + * so bail > + */ > + if (!(BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | > + BTRFS_INODE_PREALLOC)) || > + check_can_nocow(BTRFS_I(inode), pos, &count) <= 0) { > + inode_unlock(inode); > + return -EAGAIN; > + } > + } else } else { > + inode_lock(inode); }