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

Commit d9585277 authored by Al Viro's avatar Al Viro
Browse files

make ->atomic_open() return int



Change of calling conventions:
old		new
NULL		1
file		0
ERR_PTR(-ve)	-ve

Caller *knows* that struct file *; no need to return it.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 3d8a00d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -62,7 +62,7 @@ ata *);
	int (*removexattr) (struct dentry *, const char *);
	int (*removexattr) (struct dentry *, const char *);
	int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
	int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
	void (*update_time)(struct inode *, struct timespec *, int);
	void (*update_time)(struct inode *, struct timespec *, int);
	struct file * (*atomic_open)(struct inode *, struct dentry *,
	int (*atomic_open)(struct inode *, struct dentry *,
				struct opendata *, unsigned open_flag,
				struct opendata *, unsigned open_flag,
				umode_t create_mode, int *opened);
				umode_t create_mode, int *opened);


+3 −3
Original line number Original line Diff line number Diff line
@@ -364,7 +364,7 @@ struct inode_operations {
	ssize_t (*listxattr) (struct dentry *, char *, size_t);
	ssize_t (*listxattr) (struct dentry *, char *, size_t);
	int (*removexattr) (struct dentry *, const char *);
	int (*removexattr) (struct dentry *, const char *);
	void (*update_time)(struct inode *, struct timespec *, int);
	void (*update_time)(struct inode *, struct timespec *, int);
	struct file * (*atomic_open)(struct inode *, struct dentry *,
	int (*atomic_open)(struct inode *, struct dentry *,
				struct opendata *, unsigned open_flag,
				struct opendata *, unsigned open_flag,
				umode_t create_mode, int *opened);
				umode_t create_mode, int *opened);
};
};
@@ -482,8 +482,8 @@ otherwise noted.
  atomic_open: called on the last component of an open.  Using this optional
  atomic_open: called on the last component of an open.  Using this optional
  	method the filesystem can look up, possibly create and open the file in
  	method the filesystem can look up, possibly create and open the file in
  	one atomic operation.  If it cannot perform this (e.g. the file type
  	one atomic operation.  If it cannot perform this (e.g. the file type
  	turned out to be wrong) it may signal this by returning NULL instead of
  	turned out to be wrong) it may signal this by returning 1 instead of
  	an open struct file pointer.  This method is only called if the last
  	usual 0 or -ve .  This method is only called if the last
  	component is negative or needs lookup.  Cached positive dentries are
  	component is negative or needs lookup.  Cached positive dentries are
  	still handled by f_op->open().
  	still handled by f_op->open().


+4 −6
Original line number Original line Diff line number Diff line
@@ -856,7 +856,7 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
	return ERR_PTR(result);
	return ERR_PTR(result);
}
}


static struct file *
static int
v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
		     struct opendata *od, unsigned flags, umode_t mode,
		     struct opendata *od, unsigned flags, umode_t mode,
		     int *opened)
		     int *opened)
@@ -872,7 +872,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
	if (d_unhashed(dentry)) {
	if (d_unhashed(dentry)) {
		res = v9fs_vfs_lookup(dir, dentry, NULL);
		res = v9fs_vfs_lookup(dir, dentry, NULL);
		if (IS_ERR(res))
		if (IS_ERR(res))
			return ERR_CAST(res);
			return PTR_ERR(res);


		if (res)
		if (res)
			dentry = res;
			dentry = res;
@@ -881,7 +881,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
	/* Only creates */
	/* Only creates */
	if (!(flags & O_CREAT) || dentry->d_inode) {
	if (!(flags & O_CREAT) || dentry->d_inode) {
		finish_no_open(od, res);
		finish_no_open(od, res);
		return NULL;
		return 1;
	}
	}


	err = 0;
	err = 0;
@@ -933,13 +933,11 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
	*opened |= FILE_CREATED;
	*opened |= FILE_CREATED;
out:
out:
	dput(res);
	dput(res);
	return filp;
	return err;


error:
error:
	if (fid)
	if (fid)
		p9_client_clunk(fid);
		p9_client_clunk(fid);

	filp = ERR_PTR(err);
	goto out;
	goto out;
}
}


+6 −8
Original line number Original line Diff line number Diff line
@@ -240,7 +240,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
	return v9fs_vfs_mknod_dotl(dir, dentry, omode, 0);
	return v9fs_vfs_mknod_dotl(dir, dentry, omode, 0);
}
}


static struct file *
static int
v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
			  struct opendata *od, unsigned flags, umode_t omode,
			  struct opendata *od, unsigned flags, umode_t omode,
			  int *opened)
			  int *opened)
@@ -262,7 +262,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
	if (d_unhashed(dentry)) {
	if (d_unhashed(dentry)) {
		res = v9fs_vfs_lookup(dir, dentry, NULL);
		res = v9fs_vfs_lookup(dir, dentry, NULL);
		if (IS_ERR(res))
		if (IS_ERR(res))
			return ERR_CAST(res);
			return PTR_ERR(res);


		if (res)
		if (res)
			dentry = res;
			dentry = res;
@@ -271,7 +271,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
	/* Only creates */
	/* Only creates */
	if (!(flags & O_CREAT) || dentry->d_inode) {
	if (!(flags & O_CREAT) || dentry->d_inode) {
		finish_no_open(od, res);
		finish_no_open(od, res);
		return NULL;
		return 1;
	}
	}


	v9ses = v9fs_inode2v9ses(dir);
	v9ses = v9fs_inode2v9ses(dir);
@@ -284,7 +284,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
	if (IS_ERR(dfid)) {
	if (IS_ERR(dfid)) {
		err = PTR_ERR(dfid);
		err = PTR_ERR(dfid);
		p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
		p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
		goto err_return;
		goto out;
	}
	}


	/* clone a fid to use for creation */
	/* clone a fid to use for creation */
@@ -292,7 +292,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
	if (IS_ERR(ofid)) {
	if (IS_ERR(ofid)) {
		err = PTR_ERR(ofid);
		err = PTR_ERR(ofid);
		p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
		p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
		goto err_return;
		goto out;
	}
	}


	gid = v9fs_get_fsgid_for_create(dir);
	gid = v9fs_get_fsgid_for_create(dir);
@@ -370,7 +370,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
	*opened |= FILE_CREATED;
	*opened |= FILE_CREATED;
out:
out:
	dput(res);
	dput(res);
	return filp;
	return err;


error:
error:
	if (fid)
	if (fid)
@@ -379,8 +379,6 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
	if (ofid)
	if (ofid)
		p9_client_clunk(ofid);
		p9_client_clunk(ofid);
	v9fs_set_create_acl(NULL, &dacl, &pacl);
	v9fs_set_create_acl(NULL, &dacl, &pacl);
err_return:
	filp = ERR_PTR(err);
	goto out;
	goto out;
}
}


+9 −10
Original line number Original line Diff line number Diff line
@@ -634,21 +634,20 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
	return dentry;
	return dentry;
}
}


struct file *ceph_atomic_open(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 opendata *od, unsigned flags, umode_t mode,
		     int *opened)
		     int *opened)
{
{
	int err;
	int err;
	struct dentry *res = NULL;
	struct dentry *res = NULL;
	struct file *filp;


	if (!(flags & O_CREAT)) {
	if (!(flags & O_CREAT)) {
		if (dentry->d_name.len > NAME_MAX)
		if (dentry->d_name.len > NAME_MAX)
			return ERR_PTR(-ENAMETOOLONG);
			return -ENAMETOOLONG;


		err = ceph_init_dentry(dentry);
		err = ceph_init_dentry(dentry);
		if (err < 0)
		if (err < 0)
			return ERR_PTR(err);
			return err;


		return ceph_lookup_open(dir, dentry, od, flags, mode, opened);
		return ceph_lookup_open(dir, dentry, od, flags, mode, opened);
	}
	}
@@ -656,7 +655,7 @@ struct file *ceph_atomic_open(struct inode *dir, struct dentry *dentry,
	if (d_unhashed(dentry)) {
	if (d_unhashed(dentry)) {
		res = ceph_lookup(dir, dentry, NULL);
		res = ceph_lookup(dir, dentry, NULL);
		if (IS_ERR(res))
		if (IS_ERR(res))
			return ERR_CAST(res);
			return PTR_ERR(res);


		if (res)
		if (res)
			dentry = res;
			dentry = res;
@@ -665,14 +664,14 @@ struct file *ceph_atomic_open(struct inode *dir, struct dentry *dentry,
	/* We don't deal with positive dentries here */
	/* We don't deal with positive dentries here */
	if (dentry->d_inode) {
	if (dentry->d_inode) {
		finish_no_open(od, res);
		finish_no_open(od, res);
		return NULL;
		return 1;
	}
	}


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


	return filp;
	return err;
}
}


/*
/*
Loading