diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index fab6e4cf8f06..aea82f2b9240 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3230,11 +3230,12 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) goto out; } - if (!inode_trylock(inode)) { - if (iocb->ki_flags & IOCB_NOWAIT) { + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock(inode)) { ret = -EAGAIN; goto out; } + } else { inode_lock(inode); }