[PATCH] nfs: fix nfs_writepage()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: linux-kernel <linux-kernel@...>, Trond Myklebust <trond.myklebust@...>, Andrew Morton <akpm@...>
Date: Wednesday, October 17, 2007 - 9:40 am

I noticed that ->writepage() didn't actually do anything since it
doesn't generate a write request for the given page.

The below is an attempt at fixing it, and it works for me. Although I'm
not quite sure its the proper fix.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 fs/nfs/write.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Index: linux-2.6/fs/nfs/write.c
===================================================================
--- linux-2.6.orig/fs/nfs/write.c
+++ linux-2.6/fs/nfs/write.c
@@ -332,10 +332,30 @@ static int nfs_page_async_flush(struct n
 static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
 {
 	struct inode *inode = page_file_mapping(page)->host;
+	struct rpc_cred *cred;
+	struct nfs_open_context *ctx;
+	int status;
 
 	nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
 	nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
 
+	cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0);
+	if (IS_ERR(cred))
+		return PTR_ERR(cred);
+
+	ctx = nfs_find_open_context(inode, cred, FMODE_WRITE);
+	if (!ctx)
+		return -EBADF;
+
+	status = nfs_writepage_setup(ctx, page, 0, nfs_page_length(page));
+
+	put_nfs_open_context(ctx);
+
+	if (status < 0) {
+		nfs_set_pageerror(page);
+		return status;
+	}
+
 	nfs_pageio_cond_complete(pgio, page_file_index(page));
 	return nfs_page_async_flush(pgio, page);
 }


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] nfs: fix nfs_writepage(), Peter Zijlstra, (Wed Oct 17, 9:40 am)
Re: [PATCH] nfs: fix nfs_writepage(), Trond Myklebust, (Wed Oct 17, 11:25 am)
Re: [PATCH] nfs: fix nfs_writepage(), Peter Zijlstra, (Wed Oct 17, 11:30 am)
Re: [PATCH] nfs: fix nfs_writepage(), Trond Myklebust, (Wed Oct 17, 11:45 am)
Re: [PATCH] nfs: fix nfs_writepage(), Trond Myklebust, (Wed Oct 17, 11:47 am)
Re: [PATCH] nfs: fix nfs_writepage(), Peter Zijlstra, (Wed Oct 17, 11:57 am)
Re: [PATCH] nfs: fix nfs_writepage(), Trond Myklebust, (Wed Oct 17, 12:24 pm)
Re: [PATCH] nfs: fix nfs_writepage(), Peter Zijlstra, (Wed Oct 17, 12:26 pm)
Re: [PATCH] nfs: fix nfs_writepage(), Peter Zijlstra, (Wed Oct 17, 1:36 pm)
Re: [PATCH] nfs: fix nfs_writepage(), Trond Myklebust, (Wed Oct 17, 2:49 pm)
Re: [PATCH] nfs: fix nfs_writepage(), Christoph Hellwig, (Wed Oct 17, 11:55 am)
Re: [PATCH] nfs: fix nfs_writepage(), Peter Zijlstra, (Wed Oct 17, 12:02 pm)
Re: [PATCH] nfs: fix nfs_writepage(), Christoph Hellwig, (Wed Oct 17, 12:05 pm)