aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/inode.c
diff options
context:
space:
mode:
authorJohn Muir <muirj@nortel.com>2009-05-31 11:13:57 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2009-06-30 14:12:24 -0400
commit3b463ae0c6264f70e5d4c0a9c46af20fed43c96e (patch)
tree03c6abdd0671d74452cbd1f6fc6d637363eb6389 /fs/fuse/inode.c
parente0a43ddcc08c34dbd666d93600fd23914505f4aa (diff)
fuse: invalidation reverse calls
Add notification messages that allow the filesystem to invalidate VFS caches. Two notifications are added: 1) inode invalidation - invalidate cached attributes - invalidate a range of pages in the page cache (this is optional) 2) dentry invalidation - try to invalidate a subtree in the dentry cache Care must be taken while accessing the 'struct super_block' for the mount, as it can go away while an invalidation is in progress. To prevent this, introduce a rw-semaphore, that is taken for read during the invalidation and taken for write in the ->kill_sb callback. Cc: Csaba Henk <csaba@gluster.com> Cc: Anand Avati <avati@zresearch.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/fuse/inode.c')
-rw-r--r--fs/fuse/inode.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 6cc501bd0187..f91ccc4a189d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -206,7 +206,7 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr)
206 BUG(); 206 BUG();
207} 207}
208 208
209static int fuse_inode_eq(struct inode *inode, void *_nodeidp) 209int fuse_inode_eq(struct inode *inode, void *_nodeidp)
210{ 210{
211 u64 nodeid = *(u64 *) _nodeidp; 211 u64 nodeid = *(u64 *) _nodeidp;
212 if (get_node_id(inode) == nodeid) 212 if (get_node_id(inode) == nodeid)
@@ -257,6 +257,31 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
257 return inode; 257 return inode;
258} 258}
259 259
260int fuse_reverse_inval_inode(struct super_block *sb, u64 nodeid,
261 loff_t offset, loff_t len)
262{
263 struct inode *inode;
264 pgoff_t pg_start;
265 pgoff_t pg_end;
266
267 inode = ilookup5(sb, nodeid, fuse_inode_eq, &nodeid);
268 if (!inode)
269 return -ENOENT;
270
271 fuse_invalidate_attr(inode);
272 if (offset >= 0) {
273 pg_start = offset >> PAGE_CACHE_SHIFT;
274 if (len <= 0)
275 pg_end = -1;
276 else
277 pg_end = (offset + len - 1) >> PAGE_CACHE_SHIFT;
278 invalidate_inode_pages2_range(inode->i_mapping,
279 pg_start, pg_end);
280 }
281 iput(inode);
282 return 0;
283}
284
260static void fuse_umount_begin(struct super_block *sb) 285static void fuse_umount_begin(struct super_block *sb)
261{ 286{
262 fuse_abort_conn(get_fuse_conn_super(sb)); 287 fuse_abort_conn(get_fuse_conn_super(sb));
@@ -480,6 +505,7 @@ void fuse_conn_init(struct fuse_conn *fc)
480 memset(fc, 0, sizeof(*fc)); 505 memset(fc, 0, sizeof(*fc));
481 spin_lock_init(&fc->lock); 506 spin_lock_init(&fc->lock);
482 mutex_init(&fc->inst_mutex); 507 mutex_init(&fc->inst_mutex);
508 init_rwsem(&fc->killsb);
483 atomic_set(&fc->count, 1); 509 atomic_set(&fc->count, 1);
484 init_waitqueue_head(&fc->waitq); 510 init_waitqueue_head(&fc->waitq);
485 init_waitqueue_head(&fc->blocked_waitq); 511 init_waitqueue_head(&fc->blocked_waitq);
@@ -862,6 +888,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
862 fuse_conn_init(fc); 888 fuse_conn_init(fc);
863 889
864 fc->dev = sb->s_dev; 890 fc->dev = sb->s_dev;
891 fc->sb = sb;
865 err = fuse_bdi_init(fc, sb); 892 err = fuse_bdi_init(fc, sb);
866 if (err) 893 if (err)
867 goto err_put_conn; 894 goto err_put_conn;
@@ -948,12 +975,25 @@ static int fuse_get_sb(struct file_system_type *fs_type,
948 return get_sb_nodev(fs_type, flags, raw_data, fuse_fill_super, mnt); 975 return get_sb_nodev(fs_type, flags, raw_data, fuse_fill_super, mnt);
949} 976}
950 977
978static void fuse_kill_sb_anon(struct super_block *sb)
979{
980 struct fuse_conn *fc = get_fuse_conn_super(sb);
981
982 if (fc) {
983 down_write(&fc->killsb);
984 fc->sb = NULL;
985 up_write(&fc->killsb);
986 }
987
988 kill_anon_super(sb);
989}
990
951static struct file_system_type fuse_fs_type = { 991static struct file_system_type fuse_fs_type = {
952 .owner = THIS_MODULE, 992 .owner = THIS_MODULE,
953 .name = "fuse", 993 .name = "fuse",
954 .fs_flags = FS_HAS_SUBTYPE, 994 .fs_flags = FS_HAS_SUBTYPE,
955 .get_sb = fuse_get_sb, 995 .get_sb = fuse_get_sb,
956 .kill_sb = kill_anon_super, 996 .kill_sb = fuse_kill_sb_anon,
957}; 997};
958 998
959#ifdef CONFIG_BLOCK 999#ifdef CONFIG_BLOCK
@@ -965,11 +1005,24 @@ static int fuse_get_sb_blk(struct file_system_type *fs_type,
965 mnt); 1005 mnt);
966} 1006}
967 1007
1008static void fuse_kill_sb_blk(struct super_block *sb)
1009{
1010 struct fuse_conn *fc = get_fuse_conn_super(sb);
1011
1012 if (fc) {
1013 down_write(&fc->killsb);
1014 fc->sb = NULL;
1015 up_write(&fc->killsb);
1016 }
1017
1018 kill_block_super(sb);
1019}
1020
968static struct file_system_type fuseblk_fs_type = { 1021static struct file_system_type fuseblk_fs_type = {
969 .owner = THIS_MODULE, 1022 .owner = THIS_MODULE,
970 .name = "fuseblk", 1023 .name = "fuseblk",
971 .get_sb = fuse_get_sb_blk, 1024 .get_sb = fuse_get_sb_blk,
972 .kill_sb = kill_block_super, 1025 .kill_sb = fuse_kill_sb_blk,
973 .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE, 1026 .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE,
974}; 1027};
975 1028