Skip to content

Commit

Permalink
kill struct opendata
Browse files Browse the repository at this point in the history
Just pass struct file *.  Methods are happier that way...
There's no need to return struct file * from finish_open() now,
so let it return int.  Next: saner prototypes for parts in
namei.c

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jul 14, 2012
1 parent a4a3bdd commit 30d9049
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Documentation/filesystems/Locking
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ata *);
int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
void (*update_time)(struct inode *, struct timespec *, int);
int (*atomic_open)(struct inode *, struct dentry *,
struct opendata *, unsigned open_flag,
struct file *, unsigned open_flag,
umode_t create_mode, int *opened);

locking rules:
Expand Down
2 changes: 1 addition & 1 deletion Documentation/filesystems/vfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ struct inode_operations {
int (*removexattr) (struct dentry *, const char *);
void (*update_time)(struct inode *, struct timespec *, int);
int (*atomic_open)(struct inode *, struct dentry *,
struct opendata *, unsigned open_flag,
struct file *, unsigned open_flag,
umode_t create_mode, int *opened);
};

Expand Down
15 changes: 6 additions & 9 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,12 +858,11 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,

static int
v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
struct opendata *od, unsigned flags, umode_t mode,
struct file *file, unsigned flags, umode_t mode,
int *opened)
{
int err;
u32 perm;
struct file *filp;
struct v9fs_inode *v9inode;
struct v9fs_session_info *v9ses;
struct p9_fid *fid, *inode_fid;
Expand All @@ -880,7 +879,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,

/* Only creates */
if (!(flags & O_CREAT) || dentry->d_inode) {
finish_no_open(od, res);
finish_no_open(file, res);
return 1;
}

Expand Down Expand Up @@ -918,16 +917,14 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
v9inode->writeback_fid = (void *) inode_fid;
}
mutex_unlock(&v9inode->v_mutex);
filp = finish_open(od, dentry, generic_file_open, opened);
if (IS_ERR(filp)) {
err = PTR_ERR(filp);
err = finish_open(file, dentry, generic_file_open, opened);
if (err)
goto error;
}

filp->private_data = fid;
file->private_data = fid;
#ifdef CONFIG_9P_FSCACHE
if (v9ses->cache)
v9fs_cache_inode_set_cookie(dentry->d_inode, filp);
v9fs_cache_inode_set_cookie(dentry->d_inode, file);
#endif

*opened |= FILE_CREATED;
Expand Down
15 changes: 6 additions & 9 deletions fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,13 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,

static int
v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
struct opendata *od, unsigned flags, umode_t omode,
struct file *file, unsigned flags, umode_t omode,
int *opened)
{
int err = 0;
gid_t gid;
umode_t mode;
char *name = NULL;
struct file *filp;
struct p9_qid qid;
struct inode *inode;
struct p9_fid *fid = NULL;
Expand All @@ -270,7 +269,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,

/* Only creates */
if (!(flags & O_CREAT) || dentry->d_inode) {
finish_no_open(od, res);
finish_no_open(file, res);
return 1;
}

Expand Down Expand Up @@ -357,15 +356,13 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
}
mutex_unlock(&v9inode->v_mutex);
/* Since we are opening a file, assign the open fid to the file */
filp = finish_open(od, dentry, generic_file_open, opened);
if (IS_ERR(filp)) {
err = PTR_ERR(filp);
err = finish_open(file, dentry, generic_file_open, opened);
if (err)
goto err_clunk_old_fid;
}
filp->private_data = ofid;
file->private_data = ofid;
#ifdef CONFIG_9P_FSCACHE
if (v9ses->cache)
v9fs_cache_inode_set_cookie(inode, filp);
v9fs_cache_inode_set_cookie(inode, file);
#endif
*opened |= FILE_CREATED;
out:
Expand Down
8 changes: 4 additions & 4 deletions fs/ceph/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
}

int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
struct opendata *od, unsigned flags, umode_t mode,
struct file *file, unsigned flags, umode_t mode,
int *opened)
{
int err;
Expand All @@ -649,7 +649,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
if (err < 0)
return err;

return ceph_lookup_open(dir, dentry, od, flags, mode, opened);
return ceph_lookup_open(dir, dentry, file, flags, mode, opened);
}

if (d_unhashed(dentry)) {
Expand All @@ -663,12 +663,12 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,

/* We don't deal with positive dentries here */
if (dentry->d_inode) {
finish_no_open(od, res);
finish_no_open(file, res);
return 1;
}

*opened |= FILE_CREATED;
err = ceph_lookup_open(dir, dentry, od, flags, mode, opened);
err = ceph_lookup_open(dir, dentry, file, flags, mode, opened);
dput(res);

return err;
Expand Down
7 changes: 2 additions & 5 deletions fs/ceph/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,11 @@ int ceph_open(struct inode *inode, struct file *file)
* ceph_release gets called). So fear not!
*/
int ceph_lookup_open(struct inode *dir, struct dentry *dentry,
struct opendata *od, unsigned flags, umode_t mode,
struct file *file, unsigned flags, umode_t mode,
int *opened)
{
struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb);
struct ceph_mds_client *mdsc = fsc->mdsc;
struct file *file = NULL;
struct ceph_mds_request *req;
struct dentry *ret;
int err;
Expand Down Expand Up @@ -248,9 +247,7 @@ int ceph_lookup_open(struct inode *dir, struct dentry *dentry,
err = ceph_handle_notrace_create(dir, dentry);
if (err)
goto out;
file = finish_open(od, req->r_dentry, ceph_open, opened);
if (IS_ERR(file))
err = PTR_ERR(file);
err = finish_open(file, req->r_dentry, ceph_open, opened);
out:
ret = ceph_finish_lookup(req, dentry, err);
ceph_mdsc_put_request(req);
Expand Down
2 changes: 1 addition & 1 deletion fs/ceph/super.h
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ extern int ceph_copy_from_page_vector(struct page **pages,
extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags);
extern int ceph_open(struct inode *inode, struct file *file);
extern int ceph_lookup_open(struct inode *dir, struct dentry *dentry,
struct opendata *od, unsigned flags,
struct file *od, unsigned flags,
umode_t mode, int *opened);
extern int ceph_release(struct inode *inode, struct file *filp);

Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern struct inode *cifs_root_iget(struct super_block *);
extern int cifs_create(struct inode *, struct dentry *, umode_t,
struct nameidata *);
extern int cifs_atomic_open(struct inode *, struct dentry *,
struct opendata *, unsigned, umode_t,
struct file *, unsigned, umode_t,
int *);
extern struct dentry *cifs_lookup(struct inode *, struct dentry *,
struct nameidata *);
Expand Down
9 changes: 4 additions & 5 deletions fs/cifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry,

int
cifs_atomic_open(struct inode *inode, struct dentry *direntry,
struct opendata *od, unsigned oflags, umode_t mode,
struct file *file, unsigned oflags, umode_t mode,
int *opened)
{
int rc;
Expand All @@ -405,7 +405,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
if (IS_ERR(res))
return PTR_ERR(res);

finish_no_open(od, res);
finish_no_open(file, res);
return 1;
}

Expand All @@ -431,9 +431,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
if (rc)
goto out;

filp = finish_open(od, direntry, generic_file_open, opened);
if (IS_ERR(filp)) {
rc = PTR_ERR(filp);
rc = finish_open(file, direntry, generic_file_open, opened);
if (rc) {
CIFSSMBClose(xid, tcon, fileHandle);
goto out;
}
Expand Down
15 changes: 6 additions & 9 deletions fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
* 'mknod' + 'open' requests.
*/
static int fuse_create_open(struct inode *dir, struct dentry *entry,
struct opendata *od, unsigned flags,
struct file *file, unsigned flags,
umode_t mode, int *opened)
{
int err;
Expand All @@ -382,7 +382,6 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
struct fuse_open_out outopen;
struct fuse_entry_out outentry;
struct fuse_file *ff;
struct file *file;

forget = fuse_alloc_forget();
err = -ENOMEM;
Expand Down Expand Up @@ -450,14 +449,12 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,
d_instantiate(entry, inode);
fuse_change_entry_timeout(entry, &outentry);
fuse_invalidate_attr(dir);
file = finish_open(od, entry, generic_file_open, opened);
if (IS_ERR(file)) {
err = PTR_ERR(file);
err = finish_open(file, entry, generic_file_open, opened);
if (err) {
fuse_sync_release(ff, flags);
} else {
file->private_data = fuse_file_get(ff);
fuse_finish_open(inode, file);
err = 0;
}
return err;

Expand All @@ -473,7 +470,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,

static int fuse_mknod(struct inode *, struct dentry *, umode_t, dev_t);
static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
struct opendata *od, unsigned flags,
struct file *file, unsigned flags,
umode_t mode, int *opened)
{
int err;
Expand All @@ -498,7 +495,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
if (fc->no_create)
goto mknod;

err = fuse_create_open(dir, entry, od, flags, mode, opened);
err = fuse_create_open(dir, entry, file, flags, mode, opened);
if (err == -ENOSYS) {
fc->no_create = 1;
goto mknod;
Expand All @@ -512,7 +509,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
if (err)
goto out_dput;
no_open:
finish_no_open(od, res);
finish_no_open(file, res);
return 1;
}

Expand Down
3 changes: 0 additions & 3 deletions fs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ extern struct super_block *user_get_super(dev_t);
/*
* open.c
*/
struct opendata {
struct file *filp;
};
struct open_flags {
int open_flag;
umode_t mode;
Expand Down
Loading

0 comments on commit 30d9049

Please sign in to comment.