diff mbox

[23/39] ovl: add O_DIRECT support

Message ID 20180529144339.16538-24-mszeredi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Miklos Szeredi May 29, 2018, 2:43 p.m. UTC
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/overlayfs/file.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Al Viro June 10, 2018, 5:31 a.m. UTC | #1
On Tue, May 29, 2018 at 04:43:23PM +0200, Miklos Szeredi wrote:
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
>  fs/overlayfs/file.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index 3f610a5b38e4..e5e7ccaaf9ec 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -110,6 +110,9 @@ static int ovl_open(struct inode *inode, struct file *file)
>  	if (IS_ERR(realfile))
>  		return PTR_ERR(realfile);
>  
> +	/* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */
> +	file->f_mapping = realfile->f_mapping;

Umm...  What happens if upper layer doesn't allow O_DIRECT, while the lower one does?
Miklos Szeredi June 11, 2018, 8:08 a.m. UTC | #2
On Sun, Jun 10, 2018 at 7:31 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Tue, May 29, 2018 at 04:43:23PM +0200, Miklos Szeredi wrote:
>> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
>> ---
>>  fs/overlayfs/file.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
>> index 3f610a5b38e4..e5e7ccaaf9ec 100644
>> --- a/fs/overlayfs/file.c
>> +++ b/fs/overlayfs/file.c
>> @@ -110,6 +110,9 @@ static int ovl_open(struct inode *inode, struct file *file)
>>       if (IS_ERR(realfile))
>>               return PTR_ERR(realfile);
>>
>> +     /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */
>> +     file->f_mapping = realfile->f_mapping;
>
> Umm...  What happens if upper layer doesn't allow O_DIRECT, while the lower one does?

Will get EINVAL on read(2) after copy up.  Not sure if it can be
called a regression, since it's a corner case of a corner case.

I think proper solution is to support O_DIRECT unconditionally on
upper (and for the likes of shmfs, just fall back to "cached" I/O).

Thanks,
Miklos
diff mbox

Patch

diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 3f610a5b38e4..e5e7ccaaf9ec 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -110,6 +110,9 @@  static int ovl_open(struct inode *inode, struct file *file)
 	if (IS_ERR(realfile))
 		return PTR_ERR(realfile);
 
+	/* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */
+	file->f_mapping = realfile->f_mapping;
+
 	file->private_data = realfile;
 
 	return 0;