2019-05-29 00:57:16 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2007-07-11 06:57:28 +08:00
|
|
|
/*
|
|
|
|
* 9P Client Definitions
|
|
|
|
*
|
2008-02-07 09:25:03 +08:00
|
|
|
* Copyright (C) 2008 by Eric Van Hensbergen <ericvh@gmail.com>
|
2007-07-11 06:57:28 +08:00
|
|
|
* Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NET_9P_CLIENT_H
|
|
|
|
#define NET_9P_CLIENT_H
|
|
|
|
|
2013-08-22 01:24:47 +08:00
|
|
|
#include <linux/utsname.h>
|
2018-07-12 05:02:22 +08:00
|
|
|
#include <linux/idr.h>
|
2022-06-13 07:32:06 +08:00
|
|
|
#include <linux/tracepoint-defs.h>
|
2013-08-22 01:24:47 +08:00
|
|
|
|
2008-10-14 07:45:23 +08:00
|
|
|
/* Number of requests per row */
|
|
|
|
#define P9_ROW_MAXTAG 255
|
|
|
|
|
2010-03-06 02:49:11 +08:00
|
|
|
/** enum p9_proto_versions - 9P protocol versions
|
|
|
|
* @p9_proto_legacy: 9P Legacy mode, pre-9P2000.u
|
|
|
|
* @p9_proto_2000u: 9P2000.u extension
|
2010-03-09 01:33:04 +08:00
|
|
|
* @p9_proto_2000L: 9P2000.L extension
|
2010-03-06 02:49:11 +08:00
|
|
|
*/
|
|
|
|
|
2021-11-02 21:16:43 +08:00
|
|
|
enum p9_proto_versions {
|
2011-05-06 21:05:32 +08:00
|
|
|
p9_proto_legacy,
|
|
|
|
p9_proto_2000u,
|
|
|
|
p9_proto_2000L,
|
2010-03-06 02:49:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-14 07:45:25 +08:00
|
|
|
/**
|
|
|
|
* enum p9_trans_status - different states of underlying transports
|
|
|
|
* @Connected: transport is connected and healthy
|
|
|
|
* @Disconnected: transport has been disconnected
|
|
|
|
* @Hung: transport is connected by wedged
|
|
|
|
*
|
|
|
|
* This enumeration details the various states a transport
|
|
|
|
* instatiation can be in.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum p9_trans_status {
|
|
|
|
Connected,
|
2010-03-30 07:13:59 +08:00
|
|
|
BeginDisconnect,
|
2008-10-14 07:45:25 +08:00
|
|
|
Disconnected,
|
|
|
|
Hung,
|
|
|
|
};
|
|
|
|
|
2008-10-14 07:45:23 +08:00
|
|
|
/**
|
2011-05-09 02:46:38 +08:00
|
|
|
* enum p9_req_status_t - status of a request
|
2008-10-14 07:45:23 +08:00
|
|
|
* @REQ_STATUS_ALLOC: request has been allocated but not sent
|
2008-10-14 07:45:22 +08:00
|
|
|
* @REQ_STATUS_UNSENT: request waiting to be sent
|
2008-10-14 07:45:23 +08:00
|
|
|
* @REQ_STATUS_SENT: request sent to server
|
|
|
|
* @REQ_STATUS_RCVD: response received from server
|
|
|
|
* @REQ_STATUS_FLSHD: request has been flushed
|
2008-10-14 07:45:22 +08:00
|
|
|
* @REQ_STATUS_ERROR: request encountered an error on the client side
|
2008-10-14 07:45:23 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
enum p9_req_status_t {
|
|
|
|
REQ_STATUS_ALLOC,
|
2008-10-14 07:45:22 +08:00
|
|
|
REQ_STATUS_UNSENT,
|
2008-10-14 07:45:23 +08:00
|
|
|
REQ_STATUS_SENT,
|
|
|
|
REQ_STATUS_RCVD,
|
|
|
|
REQ_STATUS_FLSHD,
|
|
|
|
REQ_STATUS_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct p9_req_t - request slots
|
|
|
|
* @status: status of this request slot
|
|
|
|
* @t_err: transport error
|
|
|
|
* @wq: wait_queue for the client to block on for this request
|
|
|
|
* @tc: the request fcall structure
|
|
|
|
* @rc: the response fcall structure
|
2008-10-14 07:45:22 +08:00
|
|
|
* @req_list: link for higher level objects to chain requests
|
2008-10-14 07:45:23 +08:00
|
|
|
*/
|
|
|
|
struct p9_req_t {
|
|
|
|
int status;
|
|
|
|
int t_err;
|
2022-07-04 09:02:49 +08:00
|
|
|
refcount_t refcount;
|
2018-07-12 05:02:23 +08:00
|
|
|
wait_queue_head_t wq;
|
2018-07-30 13:55:19 +08:00
|
|
|
struct p9_fcall tc;
|
|
|
|
struct p9_fcall rc;
|
2008-10-14 07:45:22 +08:00
|
|
|
struct list_head req_list;
|
2008-10-14 07:45:23 +08:00
|
|
|
};
|
|
|
|
|
2008-03-05 21:08:09 +08:00
|
|
|
/**
|
|
|
|
* struct p9_client - per client instance state
|
2018-07-12 05:02:24 +08:00
|
|
|
* @lock: protect @fids and @reqs
|
2008-03-05 21:08:09 +08:00
|
|
|
* @msize: maximum data size negotiated by protocol
|
2010-03-06 02:49:11 +08:00
|
|
|
* @proto_version: 9P protocol version to use
|
2008-03-05 21:08:09 +08:00
|
|
|
* @trans_mod: module API instantiated with this client
|
2018-07-12 05:02:24 +08:00
|
|
|
* @status: connection state
|
2008-03-05 21:08:09 +08:00
|
|
|
* @trans: tranport instance state and API
|
2018-07-12 05:02:22 +08:00
|
|
|
* @fids: All active FID handles
|
2018-07-12 05:02:24 +08:00
|
|
|
* @reqs: All active requests.
|
|
|
|
* @name: node name used as client id
|
2008-03-05 21:08:09 +08:00
|
|
|
*
|
|
|
|
* The client structure is used to keep track of various per-client
|
|
|
|
* state that has been instantiated.
|
|
|
|
*/
|
2007-07-11 06:57:28 +08:00
|
|
|
struct p9_client {
|
2018-07-12 05:02:24 +08:00
|
|
|
spinlock_t lock;
|
2011-08-27 00:57:40 +08:00
|
|
|
unsigned int msize;
|
2010-03-06 02:49:11 +08:00
|
|
|
unsigned char proto_version;
|
2008-02-07 09:25:03 +08:00
|
|
|
struct p9_trans_module *trans_mod;
|
2008-10-14 07:45:25 +08:00
|
|
|
enum p9_trans_status status;
|
|
|
|
void *trans;
|
2018-07-30 14:14:37 +08:00
|
|
|
struct kmem_cache *fcall_cache;
|
2007-07-11 06:57:28 +08:00
|
|
|
|
2017-07-05 23:25:37 +08:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int rfd;
|
|
|
|
int wfd;
|
|
|
|
} fd;
|
|
|
|
struct {
|
|
|
|
u16 port;
|
|
|
|
bool privport;
|
|
|
|
|
|
|
|
} tcp;
|
|
|
|
} trans_opts;
|
|
|
|
|
2018-07-12 05:02:22 +08:00
|
|
|
struct idr fids;
|
2018-07-12 05:02:24 +08:00
|
|
|
struct idr reqs;
|
2013-08-22 01:24:47 +08:00
|
|
|
|
|
|
|
char name[__NEW_UTS_LEN + 1];
|
2007-07-11 06:57:28 +08:00
|
|
|
};
|
|
|
|
|
2008-03-05 21:08:09 +08:00
|
|
|
/**
|
|
|
|
* struct p9_fid - file system entity handle
|
|
|
|
* @clnt: back pointer to instantiating &p9_client
|
|
|
|
* @fid: numeric identifier for this handle
|
|
|
|
* @mode: current mode of this fid (enum?)
|
|
|
|
* @qid: the &p9_qid server identifier this handle points to
|
|
|
|
* @iounit: the server reported maximum transaction size for this file
|
|
|
|
* @uid: the numeric uid of the local user who owns this handle
|
2009-11-02 22:39:28 +08:00
|
|
|
* @rdir: readdir accounting structure (allocated on demand)
|
2008-03-05 21:08:09 +08:00
|
|
|
* @dlist: per-dentry fid tracking
|
|
|
|
*
|
|
|
|
* TODO: This needs lots of explanation.
|
|
|
|
*/
|
2020-09-23 22:11:46 +08:00
|
|
|
enum fid_source {
|
|
|
|
FID_FROM_OTHER,
|
|
|
|
FID_FROM_INODE,
|
|
|
|
FID_FROM_DENTRY,
|
|
|
|
};
|
2008-03-05 21:08:09 +08:00
|
|
|
|
2007-07-11 06:57:28 +08:00
|
|
|
struct p9_fid {
|
|
|
|
struct p9_client *clnt;
|
|
|
|
u32 fid;
|
2020-11-03 16:35:57 +08:00
|
|
|
refcount_t count;
|
2007-07-11 06:57:28 +08:00
|
|
|
int mode;
|
|
|
|
struct p9_qid qid;
|
|
|
|
u32 iounit;
|
2013-01-31 03:48:53 +08:00
|
|
|
kuid_t uid;
|
2007-07-11 06:57:28 +08:00
|
|
|
|
2009-11-02 22:39:28 +08:00
|
|
|
void *rdir;
|
|
|
|
|
2013-02-28 11:51:08 +08:00
|
|
|
struct hlist_node dlist; /* list of all fids attached to a dentry */
|
2020-09-23 22:11:44 +08:00
|
|
|
struct hlist_node ilist;
|
2007-07-11 06:57:28 +08:00
|
|
|
};
|
|
|
|
|
2010-06-04 21:41:26 +08:00
|
|
|
/**
|
|
|
|
* struct p9_dirent - directory entry structure
|
|
|
|
* @qid: The p9 server qid for this dirent
|
|
|
|
* @d_off: offset to the next dirent
|
|
|
|
* @d_type: type of file
|
|
|
|
* @d_name: file name
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct p9_dirent {
|
|
|
|
struct p9_qid qid;
|
|
|
|
u64 d_off;
|
|
|
|
unsigned char d_type;
|
|
|
|
char d_name[256];
|
|
|
|
};
|
|
|
|
|
2015-04-02 08:17:51 +08:00
|
|
|
struct iov_iter;
|
|
|
|
|
2017-07-05 23:25:37 +08:00
|
|
|
int p9_show_client_options(struct seq_file *m, struct p9_client *clnt);
|
2010-03-25 20:45:30 +08:00
|
|
|
int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb);
|
2011-06-28 18:11:16 +08:00
|
|
|
int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid,
|
|
|
|
const char *name);
|
|
|
|
int p9_client_renameat(struct p9_fid *olddirfid, const char *old_name,
|
|
|
|
struct p9_fid *newdirfid, const char *new_name);
|
2008-02-07 09:25:03 +08:00
|
|
|
struct p9_client *p9_client_create(const char *dev_name, char *options);
|
2007-07-11 06:57:28 +08:00
|
|
|
void p9_client_destroy(struct p9_client *clnt);
|
|
|
|
void p9_client_disconnect(struct p9_client *clnt);
|
2010-03-30 07:13:59 +08:00
|
|
|
void p9_client_begin_disconnect(struct p9_client *clnt);
|
2007-07-11 06:57:28 +08:00
|
|
|
struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
|
2017-01-12 17:01:17 +08:00
|
|
|
const char *uname, kuid_t n_uname, const char *aname);
|
2011-03-31 18:19:39 +08:00
|
|
|
struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
|
2017-01-12 17:01:17 +08:00
|
|
|
const unsigned char * const *wnames, int clone);
|
2007-07-11 06:57:28 +08:00
|
|
|
int p9_client_open(struct p9_fid *fid, int mode);
|
2017-01-12 17:01:17 +08:00
|
|
|
int p9_client_fcreate(struct p9_fid *fid, const char *name, u32 perm, int mode,
|
2007-07-11 06:57:28 +08:00
|
|
|
char *extension);
|
2017-01-12 17:01:17 +08:00
|
|
|
int p9_client_link(struct p9_fid *fid, struct p9_fid *oldfid, const char *newname);
|
|
|
|
int p9_client_symlink(struct p9_fid *fid, const char *name, const char *symname,
|
|
|
|
kgid_t gid, struct p9_qid *qid);
|
|
|
|
int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags, u32 mode,
|
2013-01-30 08:09:41 +08:00
|
|
|
kgid_t gid, struct p9_qid *qid);
|
2007-07-11 06:57:28 +08:00
|
|
|
int p9_client_clunk(struct p9_fid *fid);
|
2010-10-23 01:13:12 +08:00
|
|
|
int p9_client_fsync(struct p9_fid *fid, int datasync);
|
2007-07-11 06:57:28 +08:00
|
|
|
int p9_client_remove(struct p9_fid *fid);
|
2011-06-28 18:11:18 +08:00
|
|
|
int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags);
|
2015-04-02 11:42:28 +08:00
|
|
|
int p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err);
|
2020-02-06 04:40:53 +08:00
|
|
|
int p9_client_read_once(struct p9_fid *fid, u64 offset, struct iov_iter *to,
|
|
|
|
int *err);
|
2015-04-02 08:17:51 +08:00
|
|
|
int p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err);
|
2010-06-04 21:41:26 +08:00
|
|
|
int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset);
|
2011-08-07 03:16:59 +08:00
|
|
|
int p9dirent_read(struct p9_client *clnt, char *buf, int len,
|
|
|
|
struct p9_dirent *dirent);
|
2008-10-16 21:30:07 +08:00
|
|
|
struct p9_wstat *p9_client_stat(struct p9_fid *fid);
|
2007-07-11 06:57:28 +08:00
|
|
|
int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
|
9p: Implement client side of setattr for 9P2000.L protocol.
SYNOPSIS
size[4] Tsetattr tag[2] attr[n]
size[4] Rsetattr tag[2]
DESCRIPTION
The setattr command changes some of the file status information.
attr resembles the iattr structure used in Linux kernel. It
specifies which status parameter is to be changed and to what
value. It is laid out as follows:
valid[4]
specifies which status information is to be changed. Possible
values are:
ATTR_MODE (1 << 0)
ATTR_UID (1 << 1)
ATTR_GID (1 << 2)
ATTR_SIZE (1 << 3)
ATTR_ATIME (1 << 4)
ATTR_MTIME (1 << 5)
ATTR_ATIME_SET (1 << 7)
ATTR_MTIME_SET (1 << 8)
The last two bits represent whether the time information
is being sent by the client's user space. In the absense
of these bits the server always uses server's time.
mode[4]
File permission bits
uid[4]
Owner id of file
gid[4]
Group id of the file
size[8]
File size
atime_sec[8]
Time of last file access, seconds
atime_nsec[8]
Time of last file access, nanoseconds
mtime_sec[8]
Time of last file modification, seconds
mtime_nsec[8]
Time of last file modification, nanoseconds
Explanation of the patches:
--------------------------
*) The kernel just copies relevent contents of iattr structure to
p9_iattr_dotl structure and passes it down to the client. The
only check it has is calling inode_change_ok()
*) The p9_iattr_dotl structure does not have ctime and ia_file
parameters because I don't think these are needed in our case.
The client user space can request updating just ctime by calling
chown(fd, -1, -1). This is handled on server side without a need
for putting ctime on the wire.
*) The server currently supports changing mode, time, ownership and
size of the file.
*) 9P RFC says "Either all the changes in wstat request happen, or
none of them does: if the request succeeds, all changes were made;
if it fails, none were."
I have not done anything to implement this specifically because I
don't see a reason.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
2010-06-18 14:20:10 +08:00
|
|
|
int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr);
|
2007-07-11 06:57:28 +08:00
|
|
|
|
9p: getattr client implementation for 9P2000.L protocol.
SYNOPSIS
size[4] Tgetattr tag[2] fid[4] request_mask[8]
size[4] Rgetattr tag[2] lstat[n]
DESCRIPTION
The getattr transaction inquires about the file identified by fid.
request_mask is a bit mask that specifies which fields of the
stat structure is the client interested in.
The reply will contain a machine-independent directory entry,
laid out as follows:
st_result_mask[8]
Bit mask that indicates which fields in the stat structure
have been populated by the server
qid.type[1]
the type of the file (directory, etc.), represented as a bit
vector corresponding to the high 8 bits of the file's mode
word.
qid.vers[4]
version number for given path
qid.path[8]
the file server's unique identification for the file
st_mode[4]
Permission and flags
st_uid[4]
User id of owner
st_gid[4]
Group ID of owner
st_nlink[8]
Number of hard links
st_rdev[8]
Device ID (if special file)
st_size[8]
Size, in bytes
st_blksize[8]
Block size for file system IO
st_blocks[8]
Number of file system blocks allocated
st_atime_sec[8]
Time of last access, seconds
st_atime_nsec[8]
Time of last access, nanoseconds
st_mtime_sec[8]
Time of last modification, seconds
st_mtime_nsec[8]
Time of last modification, nanoseconds
st_ctime_sec[8]
Time of last status change, seconds
st_ctime_nsec[8]
Time of last status change, nanoseconds
st_btime_sec[8]
Time of creation (birth) of file, seconds
st_btime_nsec[8]
Time of creation (birth) of file, nanoseconds
st_gen[8]
Inode generation
st_data_version[8]
Data version number
request_mask and result_mask bit masks contain the following bits
#define P9_STATS_MODE 0x00000001ULL
#define P9_STATS_NLINK 0x00000002ULL
#define P9_STATS_UID 0x00000004ULL
#define P9_STATS_GID 0x00000008ULL
#define P9_STATS_RDEV 0x00000010ULL
#define P9_STATS_ATIME 0x00000020ULL
#define P9_STATS_MTIME 0x00000040ULL
#define P9_STATS_CTIME 0x00000080ULL
#define P9_STATS_INO 0x00000100ULL
#define P9_STATS_SIZE 0x00000200ULL
#define P9_STATS_BLOCKS 0x00000400ULL
#define P9_STATS_BTIME 0x00000800ULL
#define P9_STATS_GEN 0x00001000ULL
#define P9_STATS_DATA_VERSION 0x00002000ULL
#define P9_STATS_BASIC 0x000007ffULL
#define P9_STATS_ALL 0x00003fffULL
This patch implements the client side of getattr implementation for
9P2000.L. It introduces a new structure p9_stat_dotl for getting
Linux stat information along with QID. The data layout is similar to
stat structure in Linux user space with the following major
differences:
inode (st_ino) is not part of data. Instead qid is.
device (st_dev) is not part of data because this doesn't make sense
on the client.
All time variables are 64 bit wide on the wire. The kernel seems to use
32 bit variables for these variables. However, some of the architectures
have used 64 bit variables and glibc exposes 64 bit variables to user
space on some architectures. Hence to be on the safer side we have made
these 64 bit in the protocol. Refer to the comments in
include/asm-generic/stat.h
There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
st_data_version apart from the bitmask, st_result_mask. The bit mask
is filled by the server to indicate which stat fields have been
populated by the server. Currently there is no clean way for the
server to obtain these additional fields, so it sends back just the
basic fields.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbegren <ericvh@gmail.com>
2010-07-12 22:37:23 +08:00
|
|
|
struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
|
|
|
|
u64 request_mask);
|
|
|
|
|
2017-01-12 17:01:17 +08:00
|
|
|
int p9_client_mknod_dotl(struct p9_fid *oldfid, const char *name, int mode,
|
2021-11-02 21:16:43 +08:00
|
|
|
dev_t rdev, kgid_t gid, struct p9_qid *qid);
|
2017-01-12 17:01:17 +08:00
|
|
|
int p9_client_mkdir_dotl(struct p9_fid *fid, const char *name, int mode,
|
2021-11-02 21:16:43 +08:00
|
|
|
kgid_t gid, struct p9_qid *qid);
|
9p: Implement TLOCK
Synopsis
size[4] TLock tag[2] fid[4] flock[n]
size[4] RLock tag[2] status[1]
Description
Tlock is used to acquire/release byte range posix locks on a file
identified by given fid. The reply contains status of the lock request
flock structure:
type[1] - Type of lock: F_RDLCK, F_WRLCK, F_UNLCK
flags[4] - Flags could be either of
P9_LOCK_FLAGS_BLOCK - Blocked lock request, if there is a
conflicting lock exists, wait for that lock to be released.
P9_LOCK_FLAGS_RECLAIM - Reclaim lock request, used when client is
trying to reclaim a lock after a server restrart (due to crash)
start[8] - Starting offset for lock
length[8] - Number of bytes to lock
If length is 0, lock all bytes starting at the location 'start'
through to the end of file
pid[4] - PID of the process that wants to take lock
client_id[4] - Unique client id
status[1] - Status of the lock request, can be
P9_LOCK_SUCCESS(0), P9_LOCK_BLOCKED(1), P9_LOCK_ERROR(2) or
P9_LOCK_GRACE(3)
P9_LOCK_SUCCESS - Request was successful
P9_LOCK_BLOCKED - A conflicting lock is held by another process
P9_LOCK_ERROR - Error while processing the lock request
P9_LOCK_GRACE - Server is in grace period, it can't accept new lock
requests in this period (except locks with
P9_LOCK_FLAGS_RECLAIM flag set)
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
2010-09-27 14:04:24 +08:00
|
|
|
int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status);
|
2010-09-27 14:52:13 +08:00
|
|
|
int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl);
|
2018-07-30 13:55:19 +08:00
|
|
|
void p9_fcall_fini(struct p9_fcall *fc);
|
2021-11-02 21:16:43 +08:00
|
|
|
struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag);
|
2018-08-15 01:43:42 +08:00
|
|
|
|
|
|
|
static inline void p9_req_get(struct p9_req_t *r)
|
|
|
|
{
|
2022-07-04 09:02:49 +08:00
|
|
|
refcount_inc(&r->refcount);
|
2018-08-15 01:43:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int p9_req_try_get(struct p9_req_t *r)
|
|
|
|
{
|
2022-07-04 09:02:49 +08:00
|
|
|
return refcount_inc_not_zero(&r->refcount);
|
2018-08-15 01:43:42 +08:00
|
|
|
}
|
|
|
|
|
2022-07-04 09:08:18 +08:00
|
|
|
int p9_req_put(struct p9_client *c, struct p9_req_t *r);
|
2018-08-15 01:43:42 +08:00
|
|
|
|
2022-06-13 07:32:06 +08:00
|
|
|
/* We cannot have the real tracepoints in header files,
|
|
|
|
* use a wrapper function */
|
|
|
|
DECLARE_TRACEPOINT(9p_fid_ref);
|
|
|
|
void do_trace_9p_fid_get(struct p9_fid *fid);
|
|
|
|
void do_trace_9p_fid_put(struct p9_fid *fid);
|
|
|
|
|
2022-06-12 12:42:32 +08:00
|
|
|
/* fid reference counting helpers:
|
|
|
|
* - fids used for any length of time should always be referenced through
|
|
|
|
* p9_fid_get(), and released with p9_fid_put()
|
|
|
|
* - v9fs_fid_lookup() or similar will automatically call get for you
|
|
|
|
* and also require a put
|
|
|
|
* - the *_fid_add() helpers will stash the fid in the inode,
|
|
|
|
* at which point it is the responsibility of evict_inode()
|
|
|
|
* to call the put
|
|
|
|
* - the last put will automatically send a clunk to the server
|
|
|
|
*/
|
|
|
|
static inline struct p9_fid *p9_fid_get(struct p9_fid *fid)
|
|
|
|
{
|
2022-06-13 07:32:06 +08:00
|
|
|
if (tracepoint_enabled(9p_fid_ref))
|
|
|
|
do_trace_9p_fid_get(fid);
|
|
|
|
|
2022-06-12 12:42:32 +08:00
|
|
|
refcount_inc(&fid->count);
|
|
|
|
|
|
|
|
return fid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int p9_fid_put(struct p9_fid *fid)
|
|
|
|
{
|
|
|
|
if (!fid || IS_ERR(fid))
|
|
|
|
return 0;
|
|
|
|
|
2022-06-13 07:32:06 +08:00
|
|
|
if (tracepoint_enabled(9p_fid_ref))
|
|
|
|
do_trace_9p_fid_put(fid);
|
|
|
|
|
2022-06-12 12:42:32 +08:00
|
|
|
if (!refcount_dec_and_test(&fid->count))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return p9_client_clunk(fid);
|
|
|
|
}
|
|
|
|
|
2014-01-18 01:31:00 +08:00
|
|
|
void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status);
|
2008-10-14 07:45:23 +08:00
|
|
|
|
2021-11-02 21:16:43 +08:00
|
|
|
int p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type,
|
|
|
|
int16_t *tag, int rewind);
|
|
|
|
int p9stat_read(struct p9_client *clnt, char *buf, int len,
|
|
|
|
struct p9_wstat *st);
|
|
|
|
void p9stat_free(struct p9_wstat *stbuf);
|
2008-10-16 21:30:07 +08:00
|
|
|
|
2010-03-06 02:50:14 +08:00
|
|
|
int p9_is_proto_dotu(struct p9_client *clnt);
|
|
|
|
int p9_is_proto_dotl(struct p9_client *clnt);
|
2021-11-02 21:16:43 +08:00
|
|
|
struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
|
|
|
|
const char *attr_name, u64 *attr_size);
|
|
|
|
int p9_client_xattrcreate(struct p9_fid *fid, const char *name,
|
|
|
|
u64 attr_size, int flags);
|
2010-09-28 22:29:25 +08:00
|
|
|
int p9_client_readlink(struct p9_fid *fid, char **target);
|
2008-10-16 21:29:30 +08:00
|
|
|
|
2018-07-12 05:02:24 +08:00
|
|
|
int p9_client_init(void);
|
|
|
|
void p9_client_exit(void);
|
|
|
|
|
2007-07-11 06:57:28 +08:00
|
|
|
#endif /* NET_9P_CLIENT_H */
|