Re: [PATCH] don't allow sys_readahead() on files opened with O_DIRECT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christoph Hellwig wrote:
> your check is wrong, it's testing whether the filesystem supports O_DIRECT, not
> whether sys_readahead is used on a file descriptor that has been opened with O_DIRECT

D'oh! You're right.

Jan

do_readahead() doesn't make sense if the file is opened with O_DIRECT, 
since only the page cache is stuffed but never used.

Signed-off-by: Jan Blunck <[email protected]>

 mm/filemap.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

Index: experimental-um/mm/filemap.c
===================================================================
--- experimental-um.orig/mm/filemap.c
+++ experimental-um/mm/filemap.c
@@ -1110,7 +1110,8 @@ static ssize_t
 do_readahead(struct address_space *mapping, struct file *filp,
 	     unsigned long index, unsigned long nr)
 {
-	if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage)
+	if (!mapping || !mapping->a_ops || !mapping->a_ops->readpage
+	    || (filp->f_flags & O_DIRECT))
 		return -EINVAL;
 
 	force_page_cache_readahead(mapping, filp, index,

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux