David Howells wrote:
(*) http://people.redhat.com/~dhowells/cachefs/fscache-nfs-2612mm1-10.diff
Cached NFS changes.
Attached is an update to David's patch that adds back the barriers
that stops calls into the fscache routines on filesystems that
are not mounted with the 'fsc' flag. Now, it can be argued that
these barriers are overkill, due to the designed of the
fscache interface, but having these barriers will guarantee the
stability of NFS will not be compromise by new and untested
code paths... I do think these barriers should be temporary,
but, again, to maintain the the stability of "normal" code
paths, I think they should be added....
The patch also does some general clean up and reworks
some of the debugging statements, tying them to NFSDBG_FSCACHE
steved.
This patch adds back the barriers that stop calls into the fscache
routines on filesystems that are not mounted with the 'fsc' flag.
Signed-off-by: Steve Dickson <[EMAIL PROTECTED]>
=========================================
--- 2.6.12-mm1/fs/nfs/nfs-fscache.h.orig 2005-07-06 09:12:07.000000000 -0400
+++ 2.6.12-mm1/fs/nfs/nfs-fscache.h 2005-07-06 11:17:34.000000000 -0400
@@ -17,9 +17,6 @@
#include <linux/fscache.h>
#ifdef CONFIG_NFS_FSCACHE
-#ifndef CONFIG_FSCACHE
-#error "CONFIG_NFS_FSCACHE is defined but not CONFIG_FSCACHE"
-#endif
extern struct fscache_netfs nfs_cache_netfs;
extern struct fscache_cookie_def nfs_cache_server_index_def;
@@ -34,6 +31,9 @@ nfs_renew_fscookie(struct nfs_server *se
{
struct fscache_cookie *old = nfsi->fscache;
+ if (!(server->flags & NFS_MOUNT_FSCACHE))
+ return;
+
/* retire the current fscache cache and get a new one */
fscache_relinquish_cookie(nfsi->fscache, 1);
nfsi->fscache = fscache_acquire_cookie(server->fscache, NULL, nfsi);
@@ -90,6 +90,9 @@ nfs_fhget_fscookie(struct super_block *s
{
struct nfs_server *server = NFS_SB(sb);
+ if (!(server->flags & NFS_MOUNT_FSCACHE))
+ return;
+
nfsi->fscache = fscache_acquire_cookie(server->fscache,
&nfs_cache_fh_index_def, nfsi);
if (server->fscache == FSCACHE_NEGATIVE_COOKIE)
@@ -105,6 +108,9 @@ nfs_fhget_fscookie(struct super_block *s
static inline void nfs_kill_fscookie(struct nfs_server *server)
{
+ if (!(server->flags & NFS_MOUNT_FSCACHE))
+ return;
+
dfprintk(FSCACHE,"NFS: killing cookie (0x%p/0x%p)\n",
server, server->fscache);
@@ -114,8 +120,12 @@ static inline void nfs_kill_fscookie(str
return;
}
-static inline void nfs_clear_fscookie(struct nfs_inode *nfsi)
+static inline void nfs_clear_fscookie(struct nfs_server *server,
+ struct nfs_inode *nfsi)
{
+ if (!(server->flags & NFS_MOUNT_FSCACHE))
+ return;
+
dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n",
nfsi, nfsi->fscache);
@@ -125,8 +135,12 @@ static inline void nfs_clear_fscookie(st
return;
}
-static inline void nfs_zap_fscookie(struct nfs_inode *nfsi)
+static inline void nfs_zap_fscookie(struct nfs_server *server,
+ struct nfs_inode *nfsi)
{
+ if (!(server->flags & NFS_MOUNT_FSCACHE))
+ return;
+
dfprintk(FSCACHE,"NFS: zapping cookie (0x%p/0x%p)\n",
nfsi, nfsi->fscache);
@@ -156,8 +170,8 @@ static inline void nfs_fill_fscookie(str
static inline void nfs_fhget_fscookie(struct super_block *sb, struct nfs_inode *nfsi) {}
static inline void nfs4_fill_fscookie(struct super_block *sb) {}
static inline void nfs_kill_fscookie(struct nfs_server *server) {}
-static inline void nfs_clear_fscookie(struct nfs_inode *nfsi) {}
-static inline void nfs_zap_fscookie(struct nfs_inode *nfsi) {}
+static inline void nfs_clear_fscookie(struct nfs_server *server, struct nfs_inode *nfsi) {}
+static inline void nfs_zap_fscookie(struct nfs_server *server, struct nfs_inode *nfsi) {}
static inline void
nfs_renew_fscookie(struct nfs_server *server, struct nfs_inode *nfsi) {}
static inline int nfs_register_netfs(void) { return 0; }
--- 2.6.12-mm1/fs/nfs/inode.c.orig 2005-07-06 09:12:07.000000000 -0400
+++ 2.6.12-mm1/fs/nfs/inode.c 2005-07-06 11:15:27.000000000 -0400
@@ -172,7 +172,7 @@ nfs_clear_inode(struct inode *inode)
if (cred)
put_rpccred(cred);
- nfs_clear_fscookie(nfsi);
+ nfs_clear_fscookie(NFS_SERVER(inode), nfsi);
BUG_ON(atomic_read(&nfsi->data_updates) != 0);
}
@@ -586,7 +586,7 @@ static int nfs_show_options(struct seq_f
{ NFS_MOUNT_NOAC, ",noac", "" },
{ NFS_MOUNT_NONLM, ",nolock", ",lock" },
{ NFS_MOUNT_NOACL, ",noacl", "" },
- { NFS_MOUNT_FSCACHE, ",fscache", "" },
+ { NFS_MOUNT_FSCACHE, ",fsc", "" },
{ 0, NULL, NULL }
};
struct proc_nfs_info *nfs_infop;
@@ -632,7 +632,7 @@ nfs_zap_caches(struct inode *inode)
else
nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
- nfs_zap_fscookie(nfsi);
+ nfs_zap_fscookie(NFS_SERVER(inode), nfsi);
}
static void nfs_zap_acl_cache(struct inode *inode)
@@ -841,7 +841,9 @@ nfs_setattr(struct dentry *dentry, struc
inode->i_gid = attr->ia_gid;
if ((attr->ia_valid & ATTR_SIZE) != 0) {
inode->i_size = attr->ia_size;
+#ifdef CONFIG_NFS_FSCACHE
fscache_set_i_size(nfsi->fscache, inode->i_size);
+#endif
vmtruncate(inode, attr->ia_size);
}
}
@@ -1324,12 +1326,16 @@ static int nfs_update_inode(struct inode
if (S_ISREG(inode->i_mode) && data_unstable) {
if (new_isize > cur_isize) {
inode->i_size = new_isize;
+#ifdef CONFIG_NFS_FSCACHE
fscache_set_i_size(nfsi->fscache, inode->i_size);
+#endif
invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
}
} else {
inode->i_size = new_isize;
+#ifdef CONFIG_NFS_FSCACHE
fscache_set_i_size(nfsi->fscache, inode->i_size);
+#endif
invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
}
}
--- 2.6.12-mm1/fs/nfs/write.c.orig 2005-07-06 09:12:07.000000000 -0400
+++ 2.6.12-mm1/fs/nfs/write.c 2005-07-06 11:15:39.000000000 -0400
@@ -124,7 +124,9 @@ static void nfs_grow_file(struct page *p
if (i_size >= end)
return;
i_size_write(inode, end);
+#ifdef CONFIG_NFS_FSCACHE
fscache_set_i_size(nfsi->fscache, end);
+#endif
}
/* We can set the PG_uptodate flag if we see that a write request
@@ -270,15 +272,20 @@ nfs_writepage_to_fscache(struct inode *i
{
int ret;
+ if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_FSCACHE))
+ return;
+
if (PagePrivate(page)) {
- dprintk("NFS: writepage_to_fscache (0x%p/0x%p/0x%p)\n",
+ dfprintk(FSCACHE,
+ "NFS: writepage_to_fscache (0x%p/0x%p/0x%p)\n",
NFS_I(inode)->fscache, page, inode);
ret = fscache_write_page(NFS_I(inode)->fscache, page,
nfs_writepage_to_fscache_complete,
NULL, GFP_KERNEL);
if (ret != 0) {
- dprintk("NFS: fscache_write_page error %d\n", ret);
+ dfprintk(FSCACHE,
+ "NFS: fscache_write_page error %d\n", ret);
fscache_uncache_page(NFS_I(inode)->fscache, page);
}
}
--- 2.6.12-mm1/fs/nfs/read.c.orig 2005-07-06 10:07:00.000000000 -0400
+++ 2.6.12-mm1/fs/nfs/read.c 2005-07-06 10:59:20.000000000 -0400
@@ -543,7 +543,7 @@ void nfs_readpage_result(struct rpc_task
static void
nfs_readpage_from_fscache_complete(struct page *page, void *data, int error)
{
- dprintk("NFS: readpage_from_fscache_complete (0x%p/0x%p/%d)\n",
+ dfprintk(FSCACHE, "NFS: readpage_from_fscache_complete (0x%p/0x%p/%d)\n",
page, data, error);
if (error)
@@ -559,7 +559,10 @@ nfs_readpage_from_fscache(struct inode *
{
int ret;
- dprintk("NFS: readpage_from_fscache(0x%p/0x%p/0x%p)\n",
+ if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_FSCACHE))
+ return 1;
+
+ dfprintk(FSCACHE, "NFS: readpage_from_fscache(0x%p/0x%p/0x%p)\n",
NFS_I(inode)->fscache, page, inode);
ret = fscache_read_or_alloc_page(NFS_I(inode)->fscache,
@@ -581,6 +584,27 @@ nfs_readpage_from_fscache(struct inode *
return ret;
}
}
+static inline
+int nfs_get_fcspages(struct inode *inode,
+ struct address_space *mapping,
+ struct list_head *pages,
+ unsigned *nr_pages,
+ fscache_rw_complete_t end_io_func,
+ void *end_io_data,
+ unsigned long gfp)
+{
+ int ret;
+
+ if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_FSCACHE))
+ return 1;
+
+ ret = fscache_read_or_alloc_pages(NFS_I(inode)->fscache,
+ mapping, pages, nr_pages,
+ nfs_readpage_from_fscache_complete,
+ NULL, mapping_gfp_mask(mapping));
+
+ return ret;
+}
#else
static inline int
nfs_readpage_from_fscache(struct inode *inode, struct page *page) { return 1; }
@@ -690,13 +714,10 @@ int nfs_readpages(struct file *filp, str
/* attempt to read as many of the pages as possible from the cache
* - this returns -ENOBUFS immediately if the cookie is negative
*/
- ret = fscache_read_or_alloc_pages(NFS_I(inode)->fscache,
- mapping,
- pages,
- &nr_pages,
- nfs_readpage_from_fscache_complete,
- NULL,
- mapping_gfp_mask(mapping));
+ ret = nfs_get_fcspages(inode, mapping, pages, &nr_pages,
+ nfs_readpage_from_fscache_complete,
+ NULL, mapping_gfp_mask(mapping));
+
if (ret == 0)
return ret; /* all read */
#endif
@@ -756,7 +777,7 @@ int nfs_invalidatepage(struct page *page
BUG_ON(nfsi->fscache == FSCACHE_NEGATIVE_COOKIE);
- dfprintk(PAGECACHE,"NFS: fscache invalidatepage (0x%p/0x%p/0x%p)\n",
+ dfprintk(FSCACHE, "NFS: fscache invalidatepage (0x%p/0x%p/0x%p)\n",
nfsi->fscache, page, nfsi);
if (offset == 0) {
@@ -776,7 +797,7 @@ int nfs_releasepage(struct page *page, i
BUG_ON(nfsi->fscache == FSCACHE_NEGATIVE_COOKIE);
- dfprintk(PAGECACHE,"NFS: fscache releasepage (0x%p/0x%p/0x%p)\n",
+ dfprintk(FSCACHE, "NFS: fscache releasepage (0x%p/0x%p/0x%p)\n",
nfsi->fscache, page, nfsi);
wait_on_page_fs_misc(page);