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/

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to