aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2009-04-28 10:56:37 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2009-04-28 10:56:37 -0400
commitc7b7143c6342b8751d47b03a025ac5c0ac1ae809 (patch)
tree9bb528e90ba682b96f5a34ff5ee777ab3c260aef
parent2106cb18930312af9325d3418e138569c5b903cc (diff)
fuse: clean up args in fuse_finish_open() and fuse_release_fill()
Move setting ff->fh, ff->nodeid and file->private_data outside fuse_finish_open(). Add ->open_flags member to struct fuse_file. This simplifies the argument passing to fuse_finish_open() and fuse_release_fill(), and paves the way for creating an open helper that doesn't need an inode pointer. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
-rw-r--r--fs/fuse/dir.c16
-rw-r--r--fs/fuse/file.c28
-rw-r--r--fs/fuse/fuse_i.h9
3 files changed, 30 insertions, 23 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 222584b34ce4..da87a3d8a8ea 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -365,9 +365,9 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
365 * Synchronous release for the case when something goes wrong in CREATE_OPEN 365 * Synchronous release for the case when something goes wrong in CREATE_OPEN
366 */ 366 */
367static void fuse_sync_release(struct fuse_conn *fc, struct fuse_file *ff, 367static void fuse_sync_release(struct fuse_conn *fc, struct fuse_file *ff,
368 u64 nodeid, int flags) 368 int flags)
369{ 369{
370 fuse_release_fill(ff, nodeid, flags, FUSE_RELEASE); 370 fuse_release_fill(ff, flags, FUSE_RELEASE);
371 ff->reserved_req->force = 1; 371 ff->reserved_req->force = 1;
372 fuse_request_send(fc, ff->reserved_req); 372 fuse_request_send(fc, ff->reserved_req);
373 fuse_put_request(fc, ff->reserved_req); 373 fuse_put_request(fc, ff->reserved_req);
@@ -445,12 +445,14 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
445 goto out_free_ff; 445 goto out_free_ff;
446 446
447 fuse_put_request(fc, req); 447 fuse_put_request(fc, req);
448 ff->fh = outopen.fh;
449 ff->nodeid = outentry.nodeid;
450 ff->open_flags = outopen.open_flags;
448 inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation, 451 inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
449 &outentry.attr, entry_attr_timeout(&outentry), 0); 452 &outentry.attr, entry_attr_timeout(&outentry), 0);
450 if (!inode) { 453 if (!inode) {
451 flags &= ~(O_CREAT | O_EXCL | O_TRUNC); 454 flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
452 ff->fh = outopen.fh; 455 fuse_sync_release(fc, ff, flags);
453 fuse_sync_release(fc, ff, outentry.nodeid, flags);
454 fuse_send_forget(fc, forget_req, outentry.nodeid, 1); 456 fuse_send_forget(fc, forget_req, outentry.nodeid, 1);
455 return -ENOMEM; 457 return -ENOMEM;
456 } 458 }
@@ -460,11 +462,11 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode,
460 fuse_invalidate_attr(dir); 462 fuse_invalidate_attr(dir);
461 file = lookup_instantiate_filp(nd, entry, generic_file_open); 463 file = lookup_instantiate_filp(nd, entry, generic_file_open);
462 if (IS_ERR(file)) { 464 if (IS_ERR(file)) {
463 ff->fh = outopen.fh; 465 fuse_sync_release(fc, ff, flags);
464 fuse_sync_release(fc, ff, outentry.nodeid, flags);
465 return PTR_ERR(file); 466 return PTR_ERR(file);
466 } 467 }
467 fuse_finish_open(inode, file, ff, &outopen); 468 file->private_data = fuse_file_get(ff);
469 fuse_finish_open(inode, file);
468 return 0; 470 return 0;
469 471
470 out_free_ff: 472 out_free_ff:
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index aa4a3876ca37..d9458cace425 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -79,7 +79,7 @@ void fuse_file_free(struct fuse_file *ff)
79 kfree(ff); 79 kfree(ff);
80} 80}
81 81
82static struct fuse_file *fuse_file_get(struct fuse_file *ff) 82struct fuse_file *fuse_file_get(struct fuse_file *ff)
83{ 83{
84 atomic_inc(&ff->count); 84 atomic_inc(&ff->count);
85 return ff; 85 return ff;
@@ -102,18 +102,16 @@ static void fuse_file_put(struct fuse_file *ff)
102 } 102 }
103} 103}
104 104
105void fuse_finish_open(struct inode *inode, struct file *file, 105void fuse_finish_open(struct inode *inode, struct file *file)
106 struct fuse_file *ff, struct fuse_open_out *outarg)
107{ 106{
108 if (outarg->open_flags & FOPEN_DIRECT_IO) 107 struct fuse_file *ff = file->private_data;
108
109 if (ff->open_flags & FOPEN_DIRECT_IO)
109 file->f_op = &fuse_direct_io_file_operations; 110 file->f_op = &fuse_direct_io_file_operations;
110 if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) 111 if (!(ff->open_flags & FOPEN_KEEP_CACHE))
111 invalidate_inode_pages2(inode->i_mapping); 112 invalidate_inode_pages2(inode->i_mapping);
112 if (outarg->open_flags & FOPEN_NONSEEKABLE) 113 if (ff->open_flags & FOPEN_NONSEEKABLE)
113 nonseekable_open(inode, file); 114 nonseekable_open(inode, file);
114 ff->fh = outarg->fh;
115 ff->nodeid = get_node_id(inode);
116 file->private_data = fuse_file_get(ff);
117} 115}
118 116
119int fuse_open_common(struct inode *inode, struct file *file, int isdir) 117int fuse_open_common(struct inode *inode, struct file *file, int isdir)
@@ -141,13 +139,17 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir)
141 else { 139 else {
142 if (isdir) 140 if (isdir)
143 outarg.open_flags &= ~FOPEN_DIRECT_IO; 141 outarg.open_flags &= ~FOPEN_DIRECT_IO;
144 fuse_finish_open(inode, file, ff, &outarg); 142 ff->fh = outarg.fh;
143 ff->nodeid = get_node_id(inode);
144 ff->open_flags = outarg.open_flags;
145 file->private_data = fuse_file_get(ff);
146 fuse_finish_open(inode, file);
145 } 147 }
146 148
147 return err; 149 return err;
148} 150}
149 151
150void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode) 152void fuse_release_fill(struct fuse_file *ff, int flags, int opcode)
151{ 153{
152 struct fuse_req *req = ff->reserved_req; 154 struct fuse_req *req = ff->reserved_req;
153 struct fuse_release_in *inarg = &req->misc.release.in; 155 struct fuse_release_in *inarg = &req->misc.release.in;
@@ -155,7 +157,7 @@ void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode)
155 inarg->fh = ff->fh; 157 inarg->fh = ff->fh;
156 inarg->flags = flags; 158 inarg->flags = flags;
157 req->in.h.opcode = opcode; 159 req->in.h.opcode = opcode;
158 req->in.h.nodeid = nodeid; 160 req->in.h.nodeid = ff->nodeid;
159 req->in.numargs = 1; 161 req->in.numargs = 1;
160 req->in.args[0].size = sizeof(struct fuse_release_in); 162 req->in.args[0].size = sizeof(struct fuse_release_in);
161 req->in.args[0].value = inarg; 163 req->in.args[0].value = inarg;
@@ -174,7 +176,7 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir)
174 fc = get_fuse_conn(inode); 176 fc = get_fuse_conn(inode);
175 req = ff->reserved_req; 177 req = ff->reserved_req;
176 178
177 fuse_release_fill(ff, get_node_id(inode), file->f_flags, 179 fuse_release_fill(ff, file->f_flags,
178 isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); 180 isdir ? FUSE_RELEASEDIR : FUSE_RELEASE);
179 181
180 /* Hold vfsmount and dentry until release is finished */ 182 /* Hold vfsmount and dentry until release is finished */
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index a51f63c7d423..ce46c120f48a 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -119,6 +119,9 @@ struct fuse_file {
119 /** Refcount */ 119 /** Refcount */
120 atomic_t count; 120 atomic_t count;
121 121
122 /** FOPEN_* flags returned by open */
123 u32 open_flags;
124
122 /** Entry on inode's write_files list */ 125 /** Entry on inode's write_files list */
123 struct list_head write_entry; 126 struct list_head write_entry;
124 127
@@ -528,12 +531,12 @@ void fuse_read_fill(struct fuse_req *req, struct file *file,
528int fuse_open_common(struct inode *inode, struct file *file, int isdir); 531int fuse_open_common(struct inode *inode, struct file *file, int isdir);
529 532
530struct fuse_file *fuse_file_alloc(struct fuse_conn *fc); 533struct fuse_file *fuse_file_alloc(struct fuse_conn *fc);
534struct fuse_file *fuse_file_get(struct fuse_file *ff);
531void fuse_file_free(struct fuse_file *ff); 535void fuse_file_free(struct fuse_file *ff);
532void fuse_finish_open(struct inode *inode, struct file *file, 536void fuse_finish_open(struct inode *inode, struct file *file);
533 struct fuse_file *ff, struct fuse_open_out *outarg);
534 537
535/** Fill in ff->reserved_req with a RELEASE request */ 538/** Fill in ff->reserved_req with a RELEASE request */
536void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode); 539void fuse_release_fill(struct fuse_file *ff, int flags, int opcode);
537 540
538/** 541/**
539 * Send RELEASE or RELEASEDIR request 542 * Send RELEASE or RELEASEDIR request