Skip to content

Commit fc71ff8

Browse files
committed
Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
* 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6: NFS: Ensure that writepage respects the nonblock flag NFS: kswapd must not block in nfs_release_page nfs: include space for the NUL in root path
2 parents 1cf66e1 + cfb506e commit fc71ff8

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

fs/nfs/file.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/pagemap.h>
2828
#include <linux/aio.h>
2929
#include <linux/gfp.h>
30+
#include <linux/swap.h>
3031

3132
#include <asm/uaccess.h>
3233
#include <asm/system.h>
@@ -493,11 +494,19 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset)
493494
*/
494495
static int nfs_release_page(struct page *page, gfp_t gfp)
495496
{
497+
struct address_space *mapping = page->mapping;
498+
496499
dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page);
497500

498501
/* Only do I/O if gfp is a superset of GFP_KERNEL */
499-
if ((gfp & GFP_KERNEL) == GFP_KERNEL)
500-
nfs_wb_page(page->mapping->host, page);
502+
if (mapping && (gfp & GFP_KERNEL) == GFP_KERNEL) {
503+
int how = FLUSH_SYNC;
504+
505+
/* Don't let kswapd deadlock waiting for OOM RPC calls */
506+
if (current_is_kswapd())
507+
how = 0;
508+
nfs_commit_inode(mapping->host, how);
509+
}
501510
/* If PagePrivate() is set, then the page is not freeable */
502511
if (PagePrivate(page))
503512
return 0;

fs/nfs/nfsroot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static char nfs_root_name[256] __initdata = "";
105105
static __be32 servaddr __initdata = 0;
106106

107107
/* Name of directory to mount */
108-
static char nfs_export_path[NFS_MAXPATHLEN] __initdata = { 0, };
108+
static char nfs_export_path[NFS_MAXPATHLEN + 1] __initdata = { 0, };
109109

110110
/* NFS-related data */
111111
static struct nfs_mount_data nfs_data __initdata = { 0, };/* NFS mount info */

fs/nfs/write.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void nfs_end_page_writeback(struct page *page)
222222
clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC);
223223
}
224224

225-
static struct nfs_page *nfs_find_and_lock_request(struct page *page)
225+
static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblock)
226226
{
227227
struct inode *inode = page->mapping->host;
228228
struct nfs_page *req;
@@ -241,7 +241,10 @@ static struct nfs_page *nfs_find_and_lock_request(struct page *page)
241241
* request as dirty (in which case we don't care).
242242
*/
243243
spin_unlock(&inode->i_lock);
244-
ret = nfs_wait_on_request(req);
244+
if (!nonblock)
245+
ret = nfs_wait_on_request(req);
246+
else
247+
ret = -EAGAIN;
245248
nfs_release_request(req);
246249
if (ret != 0)
247250
return ERR_PTR(ret);
@@ -256,12 +259,12 @@ static struct nfs_page *nfs_find_and_lock_request(struct page *page)
256259
* May return an error if the user signalled nfs_wait_on_request().
257260
*/
258261
static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
259-
struct page *page)
262+
struct page *page, bool nonblock)
260263
{
261264
struct nfs_page *req;
262265
int ret = 0;
263266

264-
req = nfs_find_and_lock_request(page);
267+
req = nfs_find_and_lock_request(page, nonblock);
265268
if (!req)
266269
goto out;
267270
ret = PTR_ERR(req);
@@ -283,12 +286,20 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
283286
static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
284287
{
285288
struct inode *inode = page->mapping->host;
289+
int ret;
286290

287291
nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
288292
nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
289293

290294
nfs_pageio_cond_complete(pgio, page->index);
291-
return nfs_page_async_flush(pgio, page);
295+
ret = nfs_page_async_flush(pgio, page,
296+
wbc->sync_mode == WB_SYNC_NONE ||
297+
wbc->nonblocking != 0);
298+
if (ret == -EAGAIN) {
299+
redirty_page_for_writepage(wbc, page);
300+
ret = 0;
301+
}
302+
return ret;
292303
}
293304

294305
/*
@@ -1379,7 +1390,7 @@ static const struct rpc_call_ops nfs_commit_ops = {
13791390
.rpc_release = nfs_commit_release,
13801391
};
13811392

1382-
static int nfs_commit_inode(struct inode *inode, int how)
1393+
int nfs_commit_inode(struct inode *inode, int how)
13831394
{
13841395
LIST_HEAD(head);
13851396
int may_wait = how & FLUSH_SYNC;
@@ -1443,7 +1454,7 @@ static int nfs_commit_unstable_pages(struct inode *inode, struct writeback_contr
14431454
return ret;
14441455
}
14451456
#else
1446-
static int nfs_commit_inode(struct inode *inode, int how)
1457+
int nfs_commit_inode(struct inode *inode, int how)
14471458
{
14481459
return 0;
14491460
}
@@ -1546,7 +1557,7 @@ int nfs_migrate_page(struct address_space *mapping, struct page *newpage,
15461557

15471558
nfs_fscache_release_page(page, GFP_KERNEL);
15481559

1549-
req = nfs_find_and_lock_request(page);
1560+
req = nfs_find_and_lock_request(page, false);
15501561
ret = PTR_ERR(req);
15511562
if (IS_ERR(req))
15521563
goto out;

include/linux/nfs_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ extern int nfs_wb_all(struct inode *inode);
493493
extern int nfs_wb_page(struct inode *inode, struct page* page);
494494
extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
495495
#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
496+
extern int nfs_commit_inode(struct inode *, int);
496497
extern struct nfs_write_data *nfs_commitdata_alloc(void);
497498
extern void nfs_commit_free(struct nfs_write_data *wdata);
498499
#endif

0 commit comments

Comments
 (0)