9p: use clone_fid()

in a bunch of places it cleans the things up

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2016-08-03 11:12:12 -04:00
parent 797fc16d8f
commit 7d50a29fe4
5 changed files with 8 additions and 31 deletions

View File

@ -257,36 +257,12 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry)
return v9fs_fid_lookup_with_uid(dentry, uid, any); return v9fs_fid_lookup_with_uid(dentry, uid, any);
} }
struct p9_fid *v9fs_fid_clone(struct dentry *dentry)
{
struct p9_fid *fid, *ret;
fid = v9fs_fid_lookup(dentry);
if (IS_ERR(fid))
return fid;
ret = p9_client_walk(fid, 0, NULL, 1);
return ret;
}
static struct p9_fid *v9fs_fid_clone_with_uid(struct dentry *dentry, kuid_t uid)
{
struct p9_fid *fid, *ret;
fid = v9fs_fid_lookup_with_uid(dentry, uid, 0);
if (IS_ERR(fid))
return fid;
ret = p9_client_walk(fid, 0, NULL, 1);
return ret;
}
struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) struct p9_fid *v9fs_writeback_fid(struct dentry *dentry)
{ {
int err; int err;
struct p9_fid *fid; struct p9_fid *fid;
fid = v9fs_fid_clone_with_uid(dentry, GLOBAL_ROOT_UID); fid = clone_fid(v9fs_fid_lookup_with_uid(dentry, GLOBAL_ROOT_UID, 0));
if (IS_ERR(fid)) if (IS_ERR(fid))
goto error_out; goto error_out;
/* /*

View File

@ -28,11 +28,14 @@ static inline struct p9_fid *v9fs_parent_fid(struct dentry *dentry)
{ {
return v9fs_fid_lookup(dentry->d_parent); return v9fs_fid_lookup(dentry->d_parent);
} }
struct p9_fid *v9fs_fid_clone(struct dentry *dentry);
void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); struct p9_fid *v9fs_writeback_fid(struct dentry *dentry);
static inline struct p9_fid *clone_fid(struct p9_fid *fid) static inline struct p9_fid *clone_fid(struct p9_fid *fid)
{ {
return IS_ERR(fid) ? fid : p9_client_walk(fid, 0, NULL, 1); return IS_ERR(fid) ? fid : p9_client_walk(fid, 0, NULL, 1);
} }
static inline struct p9_fid *v9fs_fid_clone(struct dentry *dentry)
{
return clone_fid(v9fs_fid_lookup(dentry));
}
#endif #endif

View File

@ -661,7 +661,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
} }
/* clone a fid to use for creation */ /* clone a fid to use for creation */
ofid = p9_client_walk(dfid, 0, NULL, 1); ofid = clone_fid(dfid);
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);

View File

@ -281,7 +281,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
} }
/* clone a fid to use for creation */ /* clone a fid to use for creation */
ofid = p9_client_walk(dfid, 0, NULL, 1); ofid = clone_fid(dfid);
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);

View File

@ -97,8 +97,6 @@ int v9fs_xattr_set(struct dentry *dentry, const char *name,
const void *value, size_t value_len, int flags) const void *value, size_t value_len, int flags)
{ {
struct p9_fid *fid = v9fs_fid_lookup(dentry); struct p9_fid *fid = v9fs_fid_lookup(dentry);
if (IS_ERR(fid))
return PTR_ERR(fid);
return v9fs_fid_xattr_set(fid, name, value, value_len, flags); return v9fs_fid_xattr_set(fid, name, value, value_len, flags);
} }
@ -115,7 +113,7 @@ int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
name, value_len, flags); name, value_len, flags);
/* Clone it */ /* Clone it */
fid = p9_client_walk(fid, 0, NULL, 1); fid = clone_fid(fid);
if (IS_ERR(fid)) if (IS_ERR(fid))
return PTR_ERR(fid); return PTR_ERR(fid);