From: Anton Altaparmakov <aia21@cam.ac.uk>
To: "Kathy KN (HK)" <kathy.kn@gmail.com>
Cc: Jeffrey Mahoney <jeffm@suse.com>,
Bryan Henderson <hbryan@us.ibm.com>,
linux-fsdevel@vger.kernel.org
Subject: Re: Access content of file via inodes
Date: Thu, 07 Apr 2005 09:09:56 +0100 [thread overview]
Message-ID: <1112861396.2842.7.camel@imp.csi.cam.ac.uk> (raw)
In-Reply-To: <4254D78F.9030705@suse.com>
On Thu, 2005-04-07 at 02:47 -0400, Jeffrey Mahoney wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Kathy KN (HK) wrote:
> > Just wondering. Say, reiserfs/r4, how is it possible to access
> > the tail which contain the data of the file, since most of our
> > production boxes uses either reiserfs and/or reiser4.
>
> Hi Kathy -
>
> Using vfs_read or the page cache functions will allow you access to the
> tail since they will map it in as part of the file. You'd only run into
> that problem if you were trying to access the data block-by-block as you
> were initially.
Exactly the same for ntfs in case you care. (-: Btw. Kathy, if you
want examples how to do page cache reads you could look at the ntfs
driver. It does them all over the place (because metadata is in the
page cache). So for example fs/ntfs/aops.c::ntfs_map_page() is (with
comments):
static inline struct page *ntfs_map_page(struct address_space *mapping,
unsigned long index)
// mapping is the address space mapping, i.e. struct inode *->i_mapping
// index is file position you want to access >> PAGE_CACHE_SHIFT
{
struct page *page = read_cache_page(mapping, index,
(filler_t*)mapping->a_ops->readpage, NULL);
// the above read_cache_page initiates the page to be read
asynchronously so it is not finished when the call returns.
if (!IS_ERR(page)) {
// if no synchronous error occured:
wait_on_page_locked(page);
// wait that the page becomes unlocked, which implies that either an
asynchronous error occured or that the page has been read successfully
kmap(page);
// map the page so can read the contents, you could do this much later
and only use kmap_atomic() depending on when/how you need to read/write
from/to the page
if (PageUptodate(page) && !PageError(page))
return page;
// if the page is now uptodate and it does not have the error bit set
the read was successful!
ntfs_unmap_page(page);
// ouch. asynchronous error occured. ntfs_unmap_page simply does a
"kunmap(page)" and a "page_cache_release(page)".
return ERR_PTR(-EIO);
// return -EIO error code encoded as a pointer.
}
return page;
// ouch synchronous error. "page" contains the error code encoded as a
pointer.
}
When you are finished accessing the page contents, simply unmap the page
if you have mapped it and do a "page_cache_release()" on the page.
Hope this helps.
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
next prev parent reply other threads:[~2005-04-07 8:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-05 1:23 Access content of file via inodes Kathy KN
2005-04-05 7:22 ` Christoph Hellwig
2005-04-05 17:53 ` Bryan Henderson
2005-04-06 1:27 ` Kathy KN (HK)
2005-04-06 1:53 ` Jeff Mahoney
2005-04-06 17:57 ` Bryan Henderson
2005-04-06 7:54 ` Anton Altaparmakov
2005-04-06 11:33 ` Anton Altaparmakov
2005-04-06 13:09 ` Jeffrey Mahoney
2005-04-07 5:25 ` Kathy KN (HK)
2005-04-07 6:47 ` Jeffrey Mahoney
2005-04-07 8:09 ` Anton Altaparmakov [this message]
2005-04-05 19:01 ` Jeff Mahoney
2005-04-06 1:32 ` Kathy KN (HK)
2005-04-06 1:50 ` Jeff Mahoney
2005-04-08 6:01 ` Kathy KN (HK)
2005-04-08 8:17 ` Anton Altaparmakov
2005-05-27 19:13 ` Martin Jambor
2005-05-28 15:57 ` Anton Altaparmakov
2005-05-28 21:44 ` Martin Jambor
2005-05-29 7:26 ` Anton Altaparmakov
2005-05-30 21:51 ` Martin Jambor
2005-05-30 22:19 ` Anton Altaparmakov
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=1112861396.2842.7.camel@imp.csi.cam.ac.uk \
--to=aia21@cam.ac.uk \
--cc=hbryan@us.ibm.com \
--cc=jeffm@suse.com \
--cc=kathy.kn@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).