Skip to content

Commit

Permalink
new helper: iter_is_iovec()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Dec 17, 2014
1 parent b1bc6d7 commit 777eda2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/linux/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ static inline size_t iov_iter_count(struct iov_iter *i)
return i->count;
}

static inline bool iter_is_iovec(struct iov_iter *i)
{
return !(i->type & (ITER_BVEC | ITER_KVEC));
}

/*
* Cap the iov_iter by given limit; note that the second argument is
* *not* the new size - it's upper limit for such. Passing it a value
Expand Down
2 changes: 1 addition & 1 deletion mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ ssize_t generic_perform_write(struct file *file,
/*
* Copies from kernel address space cannot fail (NFSD is a big user).
*/
if (segment_eq(get_fs(), KERNEL_DS))
if (!iter_is_iovec(i))
flags |= AOP_FLAG_UNINTERRUPTIBLE;

do {
Expand Down
2 changes: 1 addition & 1 deletion mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
* holes of a sparse file, we actually need to allocate those pages,
* and even mark them dirty, so it cannot exceed the max_blocks limit.
*/
if (segment_eq(get_fs(), KERNEL_DS))
if (!iter_is_iovec(to))
sgp = SGP_DIRTY;

index = *ppos >> PAGE_CACHE_SHIFT;
Expand Down

0 comments on commit 777eda2

Please sign in to comment.