From: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: Dmitry Kasatkin <d.kasatkin@samsung.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
akpm@linux-foundation.org, Al Viro <viro@zeniv.linux.org.uk>,
Mimi Zohar <zohar@linux.vnet.ibm.com>,
linux-security-module <linux-security-module@vger.kernel.org>,
Greg KH <gregkh@linuxfoundation.org>
Subject: Re: IMA: kernel reading files opened with O_DIRECT
Date: Wed, 2 Jul 2014 21:12:03 +0300 [thread overview]
Message-ID: <CACE9dm_YF+aYSDXQg=JV2b4i7Uw9AcpsTt4DRCC+F7zUt_qO-w@mail.gmail.com> (raw)
In-Reply-To: <x49y4wbu54y.fsf@segfault.boston.devel.redhat.com>
Hi Jeff,
Thanks for reply.
On 2 July 2014 18:55, Jeff Moyer <jmoyer@redhat.com> wrote:
> Hi, Dmitry,
>
> Dmitry Kasatkin <d.kasatkin@samsung.com> writes:
>
>> Hi,
>>
>> We are looking for advice on reading files opened for direct_io.
>
> [snip]
>
>> 2. Temporarily clear O_DIRECT in file->f_flags.
>
> [snip]
>
>> 3. Open another instance of the file with 'dentry_open'
>
> [snip]
>
>> Is temporarily clearing O_DIRECT flag really unacceptable or not?
>
> It's acceptable. However, what you're proposing to do is read the
> entire file into the page cache to calculate your checksum. Then, when
> the application goes to read the file using O_DIRECT, it will ignore the
> cached copy and re-read the portions of the file it wants from disk. So
> yes, you can do that, but it's not going to be fast. If you want to
> avoid polluting the cache, you can call invalidate_inode_pages2_range
> after you're done calculating your checksum.
>
Ok. If I understand correctly, after reading chunck/range like
kernel_read(offset, len),
just always drop loaded pages like
invalidate_inode_pages2_range(inode->i_mapping, offset, offset + len);
I see that generic_file_direct_write() calls this function too, before
doing direct IO and after...
Thanks!
>> Or may be there is a way to allocate "special" user-space like buffer
>> for kernel and use it with O_DIRECT?
>
> In-kernel O_DIRECT support has been proposed in the past, but there is
> no solution for that yet.
>
> Cheers,
> Jeff
--
Thanks,
Dmitry
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-07-02 18:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-02 9:40 Dmitry Kasatkin
2014-07-02 15:55 ` Jeff Moyer
2014-07-02 18:12 ` Dmitry Kasatkin [this message]
2014-07-02 18:40 ` Christoph Hellwig
2014-07-02 18:45 ` Jeff Moyer
2014-07-02 19:07 ` Dmitry Kasatkin
2014-07-11 20:10 ` Pavel Machek
2014-07-11 22:22 ` Dmitry Kasatkin
2014-07-15 13:03 ` Pavel Machek
2014-07-16 12:48 ` Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACE9dm_YF+aYSDXQg=JV2b4i7Uw9AcpsTt4DRCC+F7zUt_qO-w@mail.gmail.com' \
--to=dmitry.kasatkin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=d.kasatkin@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zohar@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox