Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e50a5e4 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Gerrit - the friendly Code Review server
Browse files

fuse: Linking file to inode helper



When writeback is ON every writeable file should be in per-inode write list,
not only mmap-ed ones. Thus introduce a helper for this linkage.

Change-Id: I9c4df97354b8f7c14de1106ccad24a3fb78319c4
Signed-off-by: default avatarMaxim Patlasov <MPatlasov@parallels.com>
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Git-commit:  650b22b941fa03590c4a3671e79ec2c96ea59e9a
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git


Signed-off-by: default avatarNikhilesh Reddy <reddyn@codeaurora.org>
parent 28fa51ae
Loading
Loading
Loading
Loading
+19 −14
Original line number Diff line number Diff line
@@ -171,6 +171,22 @@ int fuse_do_open(struct fuse_conn *fc, u64 nodeid, struct file *file,
}
EXPORT_SYMBOL_GPL(fuse_do_open);

static void fuse_link_write_file(struct file *file)
{
	struct inode *inode = file_inode(file);
	struct fuse_conn *fc = get_fuse_conn(inode);
	struct fuse_inode *fi = get_fuse_inode(inode);
	struct fuse_file *ff = file->private_data;
	/*
	 * file may be written through mmap, so chain it onto the
	 * inodes's write_file list
	 */
	spin_lock(&fc->lock);
	if (list_empty(&ff->write_entry))
		list_add(&ff->write_entry, &fi->write_files);
	spin_unlock(&fc->lock);
}

void fuse_finish_open(struct inode *inode, struct file *file)
{
	struct fuse_file *ff = file->private_data;
@@ -1660,20 +1676,9 @@ static const struct vm_operations_struct fuse_file_vm_ops = {

static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
{
	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) {
		struct inode *inode = file_inode(file);
		struct fuse_conn *fc = get_fuse_conn(inode);
		struct fuse_inode *fi = get_fuse_inode(inode);
		struct fuse_file *ff = file->private_data;
		/*
		 * file may be written through mmap, so chain it onto the
		 * inodes's write_file list
		 */
		spin_lock(&fc->lock);
		if (list_empty(&ff->write_entry))
			list_add(&ff->write_entry, &fi->write_files);
		spin_unlock(&fc->lock);
	}
	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
		fuse_link_write_file(file);

	file_accessed(file);
	vma->vm_ops = &fuse_file_vm_ops;
	return 0;