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>
This commit is contained in:
committed by
Miklos Szeredi
parent
e0a43ddcc0
commit
3b463ae0c6
@@ -849,6 +849,81 @@ err:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int fuse_notify_inval_inode(struct fuse_conn *fc, unsigned int size,
|
||||
struct fuse_copy_state *cs)
|
||||
{
|
||||
struct fuse_notify_inval_inode_out outarg;
|
||||
int err = -EINVAL;
|
||||
|
||||
if (size != sizeof(outarg))
|
||||
goto err;
|
||||
|
||||
err = fuse_copy_one(cs, &outarg, sizeof(outarg));
|
||||
if (err)
|
||||
goto err;
|
||||
fuse_copy_finish(cs);
|
||||
|
||||
down_read(&fc->killsb);
|
||||
err = -ENOENT;
|
||||
if (!fc->sb)
|
||||
goto err_unlock;
|
||||
|
||||
err = fuse_reverse_inval_inode(fc->sb, outarg.ino,
|
||||
outarg.off, outarg.len);
|
||||
|
||||
err_unlock:
|
||||
up_read(&fc->killsb);
|
||||
return err;
|
||||
|
||||
err:
|
||||
fuse_copy_finish(cs);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size,
|
||||
struct fuse_copy_state *cs)
|
||||
{
|
||||
struct fuse_notify_inval_entry_out outarg;
|
||||
int err = -EINVAL;
|
||||
char buf[FUSE_NAME_MAX+1];
|
||||
struct qstr name;
|
||||
|
||||
if (size < sizeof(outarg))
|
||||
goto err;
|
||||
|
||||
err = fuse_copy_one(cs, &outarg, sizeof(outarg));
|
||||
if (err)
|
||||
goto err;
|
||||
|
||||
err = -ENAMETOOLONG;
|
||||
if (outarg.namelen > FUSE_NAME_MAX)
|
||||
goto err;
|
||||
|
||||
name.name = buf;
|
||||
name.len = outarg.namelen;
|
||||
err = fuse_copy_one(cs, buf, outarg.namelen + 1);
|
||||
if (err)
|
||||
goto err;
|
||||
fuse_copy_finish(cs);
|
||||
buf[outarg.namelen] = 0;
|
||||
name.hash = full_name_hash(name.name, name.len);
|
||||
|
||||
down_read(&fc->killsb);
|
||||
err = -ENOENT;
|
||||
if (!fc->sb)
|
||||
goto err_unlock;
|
||||
|
||||
err = fuse_reverse_inval_entry(fc->sb, outarg.parent, &name);
|
||||
|
||||
err_unlock:
|
||||
up_read(&fc->killsb);
|
||||
return err;
|
||||
|
||||
err:
|
||||
fuse_copy_finish(cs);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
|
||||
unsigned int size, struct fuse_copy_state *cs)
|
||||
{
|
||||
@@ -856,6 +931,12 @@ static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
|
||||
case FUSE_NOTIFY_POLL:
|
||||
return fuse_notify_poll(fc, size, cs);
|
||||
|
||||
case FUSE_NOTIFY_INVAL_INODE:
|
||||
return fuse_notify_inval_inode(fc, size, cs);
|
||||
|
||||
case FUSE_NOTIFY_INVAL_ENTRY:
|
||||
return fuse_notify_inval_entry(fc, size, cs);
|
||||
|
||||
default:
|
||||
fuse_copy_finish(cs);
|
||||
return -EINVAL;
|
||||
|
Reference in New Issue
Block a user