diff options
author | M. Mohan Kumar <mohan@in.ibm.com> | 2010-09-27 02:04:24 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2010-10-28 10:08:47 -0400 |
commit | a099027c779068b834f335cfdc3f2bf10f531dd9 (patch) | |
tree | eee43443cce85a03c13b1cfdd25bf451445cf78f /net/9p | |
parent | 920e65dc6911da28a58e17f4b683302636fc6d8e (diff) |
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>
Diffstat (limited to 'net/9p')
-rw-r--r-- | net/9p/client.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 30c4a1b224f..fbd2b195801 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -1803,3 +1803,36 @@ error: | |||
1803 | 1803 | ||
1804 | } | 1804 | } |
1805 | EXPORT_SYMBOL(p9_client_mkdir_dotl); | 1805 | EXPORT_SYMBOL(p9_client_mkdir_dotl); |
1806 | |||
1807 | int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status) | ||
1808 | { | ||
1809 | int err; | ||
1810 | struct p9_client *clnt; | ||
1811 | struct p9_req_t *req; | ||
1812 | |||
1813 | err = 0; | ||
1814 | clnt = fid->clnt; | ||
1815 | P9_DPRINTK(P9_DEBUG_9P, ">>> TLOCK fid %d type %i flags %d " | ||
1816 | "start %lld length %lld proc_id %d client_id %s\n", | ||
1817 | fid->fid, flock->type, flock->flags, flock->start, | ||
1818 | flock->length, flock->proc_id, flock->client_id); | ||
1819 | |||
1820 | req = p9_client_rpc(clnt, P9_TLOCK, "dbdqqds", fid->fid, flock->type, | ||
1821 | flock->flags, flock->start, flock->length, | ||
1822 | flock->proc_id, flock->client_id); | ||
1823 | |||
1824 | if (IS_ERR(req)) | ||
1825 | return PTR_ERR(req); | ||
1826 | |||
1827 | err = p9pdu_readf(req->rc, clnt->proto_version, "b", status); | ||
1828 | if (err) { | ||
1829 | p9pdu_dump(1, req->rc); | ||
1830 | goto error; | ||
1831 | } | ||
1832 | P9_DPRINTK(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status); | ||
1833 | error: | ||
1834 | p9_free_req(clnt, req); | ||
1835 | return err; | ||
1836 | |||
1837 | } | ||
1838 | EXPORT_SYMBOL(p9_client_lock_dotl); | ||