LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Eric Van Hensbergen <ericvh@gmail.com>
Cc: linux-kernel@vger.kernel.org, v9fs-developer@lists.sourceforge.net
Subject: Re: [PATCH] 9p: add write-cache support to loose cache mode (take 3)
Date: Fri, 16 Feb 2007 12:12:26 -0800	[thread overview]
Message-ID: <20070216121226.f2382a17.akpm@linux-foundation.org> (raw)
In-Reply-To: <1171640221420-git-send-email-ericvh@gmail.com>

On Fri, 16 Feb 2007 09:37:01 -0600 Eric Van Hensbergen <ericvh@gmail.com> wrote:

> +static int v9fs_vfs_writepage(struct page *page, struct writeback_control *wbc)
> +{
> +	char *buffer = NULL;
> +	struct address_space *mapping = page->mapping;
> +	int retval = -EIO;
> +	loff_t offset = 0;
> +	pgoff_t end_index;
> +	int count = PAGE_CACHE_SIZE;
> +	struct file *filp = v9fs_find_file(page);
> +	struct inode *inode = mapping->host;
> +
> +	dprintk(DEBUG_VFS, "page: %p\n", page);
> +
> +	if ((!inode) || (!filp))
> +		goto UnlockPage;
> +
> +	end_index = inode->i_size >> PAGE_CACHE_SHIFT;
> +
> +	/* complicated case at end of file */
> +	if (page->index >= end_index) {
> +		/* things got complicated... */
> +		count = inode->i_size & (PAGE_CACHE_SIZE - 1);
> +		if (page->index >= end_index + 1 || !count)
> +			return 0;	/* truncated - don't care */
> +	}
> +
> +	buffer = kmap(page);
> +	offset = ((loff_t) page->index << PAGE_CACHE_SHIFT);
> +	page_cache_get(page);
> +	retval = v9fs_write(filp, NULL, buffer, count, &offset);
> +
>  	kunmap(page);
> +
> +      UnlockPage:
>  	unlock_page(page);
> +	page_cache_release(page);
> +
>  	return retval;
>  }

The page_cache_get/release here aren't needed: lock_page suffices.

Are you sure the page refcounting is right if the `goto UnlockPage'
happens?

Can that goto actually happen??

  reply	other threads:[~2007-02-16 20:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-15 14:44 [PATCH] 9p: add write-cache support to loose cache mode (take 2) Eric Van Hensbergen
2007-02-15 19:19 ` Josef Sipek
2007-02-16 15:37 ` [PATCH] 9p: add write-cache support to loose cache mode (take 3) Eric Van Hensbergen
2007-02-16 20:12   ` Andrew Morton [this message]
2007-02-16 22:28     ` Eric Van Hensbergen
2007-02-17  0:46   ` [PATCH] 9p: add write-cache support to loose cache mode (take 4) Eric Van Hensbergen
2007-02-17  1:01     ` Andrew Morton
2007-02-17  6:03       ` Eric Van Hensbergen

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=20070216121226.f2382a17.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ericvh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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).