All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Van Hensbergen <ericvh@gmail.com>
To: v9fs-developer@lists.sourceforge.net
Cc: kernel-mentors@selenic.com, linux-fsdevel@vger.kernel.org,
	Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
	Christoph Hellwig <hch@infradead.org>
Subject: v9fs writepage
Date: Sat, 30 Apr 2005 12:17:56 -0500	[thread overview]
Message-ID: <a4e6962a05043010173a89ccfd@mail.gmail.com> (raw)

One critique I got back (from Chris Hellwig) on the v9fs
implementation was the way that I went about implementing writepage. 
I'll agree that my existing solution is imperfect so I'd like to
solicit ideas from the community.

Essentially, the 9P protocols requires I associate each transaction
with a FID (which can be thought of a file descriptor known both to
the client and the server which is associated with a particular
thread/user).  In most areas of the v9fs driver it is fairly trivial
to map an access back to a particular FID (be looking at the process
context in which the system call was executed).  However, in the
address_space code (to support mmap), I'm not given an easy handle (in
most cases its the dentry or the file structure) to resolve a FID
against.  In order to try and guess what the right FID to use for the
writepage transaction is, I wrote the following function which
essentially scans through the dentries of an inode and tries to find
the right FID.

/**
 * v9fs_find_file - find a file pointer based on page
  * @page: page to lookup file based on 
 *
 */
static struct file *v9fs_find_file(struct page *page)
{
        struct address_space *mapping = page->mapping;
        struct inode *inode = NULL;
        struct dentry *dentry = NULL;
        struct v9fs_fid *fid = NULL;
        struct list_head *p, *temp;

        dprintk(DEBUG_VFS, " page: %p\n", page);
        if (!mapping) {
                dprintk(DEBUG_ERROR, "No mapping\n");
                return NULL;
        }

        inode = mapping->host;
        if (!inode) {
                dprintk(DEBUG_ERROR, "No inode\n");
                return NULL;
        }

        list_for_each_safe(p, temp, &inode->i_dentry) {
                dentry = list_entry(p, struct dentry, d_alias);
                fid = v9fs_fid_lookup(dentry, FID_OP);
                if (fid)
                        return fid->filp;
        }

        return NULL;
}

The problem is that v9fs_fid_lookup() tries to find the right fid
based on information in current (and therefore assumes it is running
in the same context of the thread that initiated the transaction). 
This isn't always the case in writepage, although I try to force this
by always calling writepage from my dirtypage method (which I believe
is always called in the context of the process who is "dirtying" the
page).  This seems to work for simple cases (like running fsx), but
hch pointed out that he believes it won't work in certain scenarios.

Can anyone suggest a methodology using the address_space_operations to
be able to associate memory writes with a particular thread/user?

If you would like to see more context, the v9fs code is available in
several flavors:
 tarballs: http://v9fs.sf.net
  CVSweb: http://cvs.sourceforge.net/viewcvs.py/v9fs/linux-9p/
  CVS: :pserver:anonymous@cvs.sourceforge.net:/cvsroot/v9fs/linux-9p
  BitKeeper: bk://linux-v9fs.bkbits.net

Thanks for your help.
 
             -eric

             reply	other threads:[~2005-04-30 17:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-30 17:17 Eric Van Hensbergen [this message]
2005-04-30 17:58 ` v9fs writepage Miklos Szeredi
2005-04-30 18:10   ` Eric Van Hensbergen
2005-04-30 18:36     ` Al Viro
2005-04-30 18:47       ` Eric Van Hensbergen
2005-04-30 19:01         ` Al Viro
2005-04-30 20:03           ` Miklos Szeredi
2005-04-30 20:09             ` Al Viro
2005-04-30 21:44               ` Miklos Szeredi
2005-05-01  1:10           ` Eric Van Hensbergen
2005-05-01 15:36             ` [V9fs-developer] " Ronald G. Minnich
2005-05-01 15:29           ` Ronald G. Minnich
2005-04-30 19:53     ` Miklos Szeredi

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=a4e6962a05043010173a89ccfd@mail.gmail.com \
    --to=ericvh@gmail.com \
    --cc=hch@infradead.org \
    --cc=kernel-mentors@selenic.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.