Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147953
b: refs/heads/master
c: 8b0797a
h: refs/heads/master
i:
  147951: 9235578
v: v3
  • Loading branch information
Miklos Szeredi committed Apr 28, 2009
1 parent 6dbd6d3 commit bb6a130
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 91fe96b403f8a0a4a8a045a39b1bd549b0da7941
refs/heads/master: 8b0797a4984de4406de25808e1a424344de543e4
21 changes: 5 additions & 16 deletions trunk/fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,6 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
return ERR_PTR(err);
}

/*
* Synchronous release for the case when something goes wrong in CREATE_OPEN
*/
static void fuse_sync_release(struct fuse_conn *fc, struct fuse_file *ff,
int flags)
{
fuse_release_fill(ff, flags, FUSE_RELEASE);
ff->reserved_req->force = 1;
fuse_request_send(fc, ff->reserved_req);
fuse_put_request(fc, ff->reserved_req);
kfree(ff);
}

/*
* Atomic create+open operation
*
Expand Down Expand Up @@ -452,7 +439,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
&outentry.attr, entry_attr_timeout(&outentry), 0);
if (!inode) {
flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
fuse_sync_release(fc, ff, flags);
fuse_sync_release(ff, flags);
fuse_send_forget(fc, forget_req, outentry.nodeid, 1);
return -ENOMEM;
}
Expand All @@ -462,7 +449,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
fuse_invalidate_attr(dir);
file = lookup_instantiate_filp(nd, entry, generic_file_open);
if (IS_ERR(file)) {
fuse_sync_release(fc, ff, flags);
fuse_sync_release(ff, flags);
return PTR_ERR(file);
}
file->private_data = fuse_file_get(ff);
Expand Down Expand Up @@ -1108,7 +1095,9 @@ static int fuse_dir_open(struct inode *inode, struct file *file)

static int fuse_dir_release(struct inode *inode, struct file *file)
{
return fuse_release_common(inode, file, 1);
fuse_release_common(file, FUSE_RELEASEDIR);

return 0;
}

static int fuse_dir_fsync(struct file *file, struct dentry *de, int datasync)
Expand Down
49 changes: 29 additions & 20 deletions trunk/fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ static void fuse_file_put(struct fuse_file *ff)
{
if (atomic_dec_and_test(&ff->count)) {
struct fuse_req *req = ff->reserved_req;
struct inode *inode = req->misc.release.path.dentry->d_inode;
struct fuse_conn *fc = get_fuse_conn(inode);

req->end = fuse_release_end;
fuse_request_send_background(fc, req);
fuse_request_send_background(ff->fc, req);
kfree(ff);
}
}
Expand Down Expand Up @@ -164,11 +163,20 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
return 0;
}

void fuse_release_fill(struct fuse_file *ff, int flags, int opcode)
static void fuse_prepare_release(struct fuse_file *ff, int flags, int opcode)
{
struct fuse_conn *fc = ff->fc;
struct fuse_req *req = ff->reserved_req;
struct fuse_release_in *inarg = &req->misc.release.in;

spin_lock(&fc->lock);
list_del(&ff->write_entry);
if (!RB_EMPTY_NODE(&ff->polled_node))
rb_erase(&ff->polled_node, &fc->polled_files);
spin_unlock(&fc->lock);

wake_up_interruptible_sync(&ff->poll_wait);

inarg->fh = ff->fh;
inarg->flags = flags;
req->in.h.opcode = opcode;
Expand All @@ -178,40 +186,28 @@ void fuse_release_fill(struct fuse_file *ff, int flags, int opcode)
req->in.args[0].value = inarg;
}

int fuse_release_common(struct inode *inode, struct file *file, int isdir)
void fuse_release_common(struct file *file, int opcode)
{
struct fuse_conn *fc;
struct fuse_file *ff;
struct fuse_req *req;

ff = file->private_data;
if (unlikely(!ff))
return 0; /* return value is ignored by VFS */
return;

fc = get_fuse_conn(inode);
req = ff->reserved_req;

fuse_release_fill(ff, file->f_flags,
isdir ? FUSE_RELEASEDIR : FUSE_RELEASE);
fuse_prepare_release(ff, file->f_flags, opcode);

/* Hold vfsmount and dentry until release is finished */
path_get(&file->f_path);
req->misc.release.path = file->f_path;

spin_lock(&fc->lock);
list_del(&ff->write_entry);
if (!RB_EMPTY_NODE(&ff->polled_node))
rb_erase(&ff->polled_node, &fc->polled_files);
spin_unlock(&fc->lock);

wake_up_interruptible_sync(&ff->poll_wait);
/*
* Normally this will send the RELEASE request, however if
* some asynchronous READ or WRITE requests are outstanding,
* the sending will be delayed.
*/
fuse_file_put(ff);
return 0;
}

static int fuse_open(struct inode *inode, struct file *file)
Expand All @@ -221,7 +217,20 @@ static int fuse_open(struct inode *inode, struct file *file)

static int fuse_release(struct inode *inode, struct file *file)
{
return fuse_release_common(inode, file, 0);
fuse_release_common(file, FUSE_RELEASE);

/* return value is ignored by VFS */
return 0;
}

void fuse_sync_release(struct fuse_file *ff, int flags)
{
WARN_ON(atomic_read(&ff->count) > 1);
fuse_prepare_release(ff, flags, FUSE_RELEASE);
ff->reserved_req->force = 1;
fuse_request_send(ff->fc, ff->reserved_req);
fuse_put_request(ff->fc, ff->reserved_req);
kfree(ff);
}

/*
Expand Down
5 changes: 2 additions & 3 deletions trunk/fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,12 @@ struct fuse_file *fuse_file_get(struct fuse_file *ff);
void fuse_file_free(struct fuse_file *ff);
void fuse_finish_open(struct inode *inode, struct file *file);

/** Fill in ff->reserved_req with a RELEASE request */
void fuse_release_fill(struct fuse_file *ff, int flags, int opcode);
void fuse_sync_release(struct fuse_file *ff, int flags);

/**
* Send RELEASE or RELEASEDIR request
*/
int fuse_release_common(struct inode *inode, struct file *file, int isdir);
void fuse_release_common(struct file *file, int opcode);

/**
* Send FSYNC or FSYNCDIR request
Expand Down

0 comments on commit bb6a130

Please sign in to comment.