mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andreas Dilger <adilger@clusterfs.com>, linux-kernel@vger.kernel.org
Subject: Re: How can I force a read to hit the disk?
Date: Mon, 8 Sep 2003 15:42:51 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.53.0309081539560.366@chaos> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0309081512150.665-100000@ida.rowland.org>

On Mon, 8 Sep 2003, Alan Stern wrote:

> On Fri, 5 Sep 2003, Andreas Dilger wrote:
>
> > On Sep 05, 2003  13:46 -0400, Alan Stern wrote:
> > > My kernel module for Linux-2.6 needs to be able to verify that the media
> > > on which a file resides actually is readable.  How can I do that?
> > >
> > > It would certainly suffice to use the normal VFS read routines, if there
> > > was some way to force the system to actually read from the device rather
> > > than just returning data already in the cache.  So I guess it would be
> > > enough to perform an fdatasync for the file and then invalidate the file's
> > > cache entries.  How does one invalidate a file's cache entries?  Does
> > > filemap_flush() perform both these operations for you?
> >
> > If you open the file with O_DIRECT, it should read/write directly on the
> > disk, and it will also invalidate any existing cache for the read/written
> > area.
>
> I tried doing that, but it caused a segmentation violation.  The trouble
> was this line near the start of fs/direct_io.c:dio_refill_pages()
>
> 	down_read(&current->mm->mmap_sem);
>
> Unfortunately, in a kernel thread (which is where my code runs)
> current->mm is NULL.
>
> Can anybody offer additional advice?  How about a way to invalidate all
> the page cache entries that contain a page from the file?
>
> Alan Stern

When your thread code starts up, execute
                init_rwsem(&current->mm->mmap_sem);

... This is in the thread's code, not the module init code.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (794.73 BogoMips).
            Note 96.31% of all statistics are fiction.



  reply	other threads:[~2003-09-08 19:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-05 17:46 Alan Stern
2003-09-05 18:15 ` Andreas Dilger
2003-09-05 18:49   ` Alan Stern
2003-09-05 19:09     ` Jörn Engel
2003-09-05 19:56       ` Alan Stern
2003-09-05 20:12   ` Alan Stern
2003-09-08 19:22   ` Alan Stern
2003-09-08 19:42     ` Richard B. Johnson [this message]
2003-09-08 20:36       ` Alan Stern
2003-09-09 12:13         ` Richard B. Johnson
2003-09-09 13:56           ` Alan Stern
2003-09-09 14:51             ` Richard B. Johnson
2003-09-09 20:16               ` Alan Stern
2003-09-05 18:42 ` Richard B. Johnson
2003-09-05 19:16   ` Alan Stern

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=Pine.LNX.4.53.0309081539560.366@chaos \
    --to=root@chaos.analogic.com \
    --cc=adilger@clusterfs.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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

all inboxes | Powered by JetHome®