2019-05-28 19:57:16 +03:00
// SPDX-License-Identifier: GPL-2.0-only
2005-09-10 00:04:18 +04:00
/*
* This file contians vfs file ops for 9 P2000 .
*
* Copyright ( C ) 2004 by Eric Van Hensbergen < ericvh @ gmail . com >
* Copyright ( C ) 2002 by Ron Minnich < rminnich @ lanl . gov >
*/
# include <linux/module.h>
# include <linux/errno.h>
# include <linux/fs.h>
2022-11-20 17:15:34 +03:00
# include <linux/filelock.h>
2006-10-18 21:55:46 +04:00
# include <linux/sched.h>
2005-09-10 00:04:18 +04:00
# include <linux/file.h>
# include <linux/stat.h>
# include <linux/string.h>
# include <linux/list.h>
2009-09-22 20:34:05 +04:00
# include <linux/pagemap.h>
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 10:04:24 +04:00
# include <linux/utsname.h>
2016-12-24 22:46:01 +03:00
# include <linux/uaccess.h>
2015-04-02 03:17:51 +03:00
# include <linux/uio.h>
2015-04-02 19:02:03 +03:00
# include <linux/slab.h>
2007-07-11 02:57:28 +04:00
# include <net/9p/9p.h>
# include <net/9p/client.h>
2005-09-10 00:04:18 +04:00
# include "v9fs.h"
# include "v9fs_vfs.h"
# include "fid.h"
2009-09-23 22:00:27 +04:00
# include "cache.h"
2005-09-10 00:04:18 +04:00
2014-01-10 16:44:09 +04:00
static const struct vm_operations_struct v9fs_mmap_file_vm_ops ;
2011-02-28 14:33:58 +03:00
2005-09-10 00:04:18 +04:00
/**
* v9fs_file_open - open a file ( or directory )
* @ inode : inode to be opened
* @ file : file being opened
*
*/
int v9fs_file_open ( struct inode * inode , struct file * file )
{
2006-03-02 13:54:30 +03:00
int err ;
2007-07-11 02:57:28 +04:00
struct v9fs_session_info * v9ses ;
2023-03-27 05:06:37 +03:00
struct p9_fid * fid ;
2007-07-11 02:57:28 +04:00
int omode ;
2005-09-10 00:04:18 +04:00
2011-11-28 22:40:46 +04:00
p9_debug ( P9_DEBUG_VFS , " inode: %p file: %p \n " , inode , file ) ;
2007-07-11 02:57:28 +04:00
v9ses = v9fs_inode2v9ses ( inode ) ;
2010-06-22 18:17:50 +04:00
if ( v9fs_proto_dotl ( v9ses ) )
2011-08-03 18:25:32 +04:00
omode = v9fs_open_to_dotl_flags ( file - > f_flags ) ;
2010-06-22 18:17:50 +04:00
else
omode = v9fs_uflags2omode ( file - > f_flags ,
v9fs_proto_dotu ( v9ses ) ) ;
2007-07-11 02:57:28 +04:00
fid = file - > private_data ;
if ( ! fid ) {
2016-06-29 11:54:23 +03:00
fid = v9fs_fid_clone ( file_dentry ( file ) ) ;
2007-07-11 02:57:28 +04:00
if ( IS_ERR ( fid ) )
return PTR_ERR ( fid ) ;
2023-03-27 04:53:10 +03:00
if ( ( v9ses - > cache & CACHE_WRITEBACK ) & & ( omode & P9_OWRITE ) ) {
2023-03-27 05:06:37 +03:00
int writeback_omode = ( omode & ~ P9_OWRITE ) | P9_ORDWR ;
p9_debug ( P9_DEBUG_CACHE , " write-only file with writeback enabled, try opening O_RDWR \n " ) ;
err = p9_client_open ( fid , writeback_omode ) ;
if ( err < 0 ) {
p9_debug ( P9_DEBUG_CACHE , " could not open O_RDWR, disabling caches \n " ) ;
err = p9_client_open ( fid , omode ) ;
fid - > mode | = P9L_DIRECT ;
}
} else {
err = p9_client_open ( fid , omode ) ;
}
2007-07-13 22:01:27 +04:00
if ( err < 0 ) {
2022-06-12 07:42:32 +03:00
p9_fid_put ( fid ) ;
2007-07-11 02:57:28 +04:00
return err ;
}
2010-06-22 18:17:50 +04:00
if ( ( file - > f_flags & O_APPEND ) & &
( ! v9fs_proto_dotu ( v9ses ) & & ! v9fs_proto_dotl ( v9ses ) ) )
2008-06-25 02:39:39 +04:00
generic_file_llseek ( file , 0 , SEEK_END ) ;
2022-06-12 10:05:39 +03:00
file - > private_data = fid ;
2006-03-02 13:54:30 +03:00
}
2005-09-10 00:04:18 +04:00
2022-12-08 05:03:32 +03:00
# ifdef CONFIG_9P_FSCACHE
2023-03-27 04:53:10 +03:00
if ( v9ses - > cache & CACHE_FSCACHE )
fscache_use_cookie ( v9fs_inode_cookie ( V9FS_I ( inode ) ) ,
2020-11-18 12:06:42 +03:00
file - > f_mode & FMODE_WRITE ) ;
2022-12-08 05:03:32 +03:00
# endif
2023-03-27 05:06:37 +03:00
v9fs_fid_add_modes ( fid , v9ses - > flags , v9ses - > cache , file - > f_flags ) ;
2022-06-12 10:05:39 +03:00
v9fs_open_fid_add ( inode , & fid ) ;
2006-03-02 13:54:30 +03:00
return 0 ;
2005-09-10 00:04:18 +04:00
}
/**
* v9fs_file_lock - lock a file ( or directory )
2008-03-05 16:08:09 +03:00
* @ filp : file to be locked
* @ cmd : lock command
* @ fl : file lock structure
2005-09-10 00:04:18 +04:00
*
2008-03-05 16:08:09 +03:00
* Bugs : this looks like a local only lock , we should extend into 9 P
2005-09-10 00:04:18 +04:00
* by using open exclusive
*/
static int v9fs_file_lock ( struct file * filp , int cmd , struct file_lock * fl )
{
2013-01-24 02:07:38 +04:00
struct inode * inode = file_inode ( filp ) ;
2005-09-10 00:04:18 +04:00
2011-11-28 22:40:46 +04:00
p9_debug ( P9_DEBUG_VFS , " filp: %p lock: %p \n " , filp , fl ) ;
2005-09-10 00:04:18 +04:00
2024-02-01 02:02:15 +03:00
if ( ( IS_SETLK ( cmd ) | | IS_SETLKW ( cmd ) ) & & fl - > c . flc_type ! = F_UNLCK ) {
[PATCH] Fix and add EXPORT_SYMBOL(filemap_write_and_wait)
This patch add EXPORT_SYMBOL(filemap_write_and_wait) and use it.
See mm/filemap.c:
And changes the filemap_write_and_wait() and filemap_write_and_wait_range().
Current filemap_write_and_wait() doesn't wait if filemap_fdatawrite()
returns error. However, even if filemap_fdatawrite() returned an
error, it may have submitted the partially data pages to the device.
(e.g. in the case of -ENOSPC)
<quotation>
Andrew Morton writes,
If filemap_fdatawrite() returns an error, this might be due to some
I/O problem: dead disk, unplugged cable, etc. Given the generally
crappy quality of the kernel's handling of such exceptions, there's a
good chance that the filemap_fdatawait() will get stuck in D state
forever.
</quotation>
So, this patch doesn't wait if filemap_fdatawrite() returns the -EIO.
Trond, could you please review the nfs part? Especially I'm not sure,
nfs must use the "filemap_fdatawrite(inode->i_mapping) == 0", or not.
Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-08 12:02:14 +03:00
filemap_write_and_wait ( inode - > i_mapping ) ;
2007-02-10 12:45:39 +03:00
invalidate_mapping_pages ( & inode - > i_data , 0 , - 1 ) ;
2005-09-10 00:04:18 +04:00
}
2021-11-09 14:43:43 +03:00
return 0 ;
2005-09-10 00:04:18 +04:00
}
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 10:04:24 +04:00
static int v9fs_file_do_lock ( struct file * filp , int cmd , struct file_lock * fl )
{
struct p9_flock flock ;
struct p9_fid * fid ;
2015-01-09 14:56:07 +03:00
uint8_t status = P9_LOCK_ERROR ;
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 10:04:24 +04:00
int res = 0 ;
2018-09-05 10:44:12 +03:00
struct v9fs_session_info * v9ses ;
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 10:04:24 +04:00
fid = filp - > private_data ;
BUG_ON ( fid = = NULL ) ;
2024-02-01 02:02:15 +03:00
BUG_ON ( ( fl - > c . flc_flags & FL_POSIX ) ! = FL_POSIX ) ;
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 10:04:24 +04:00
2015-10-22 20:38:14 +03:00
res = locks_lock_file_wait ( filp , fl ) ;
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 10:04:24 +04:00
if ( res < 0 )
goto out ;
/* convert posix lock to p9 tlock args */
memset ( & flock , 0 , sizeof ( flock ) ) ;
2011-08-20 22:51:18 +04:00
/* map the lock type */
2024-02-01 02:02:15 +03:00
switch ( fl - > c . flc_type ) {
2011-08-20 22:51:18 +04:00
case F_RDLCK :
flock . type = P9_LOCK_TYPE_RDLCK ;
break ;
case F_WRLCK :
flock . type = P9_LOCK_TYPE_WRLCK ;
break ;
case F_UNLCK :
flock . type = P9_LOCK_TYPE_UNLCK ;
break ;
}
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 10:04:24 +04:00
flock . start = fl - > fl_start ;
if ( fl - > fl_end = = OFFSET_MAX )
flock . length = 0 ;
else
flock . length = fl - > fl_end - fl - > fl_start + 1 ;
2024-02-01 02:02:15 +03:00
flock . proc_id = fl - > c . flc_pid ;
2013-08-21 21:24:47 +04:00
flock . client_id = fid - > clnt - > name ;
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 10:04:24 +04:00
if ( IS_SETLKW ( cmd ) )
flock . flags = P9_LOCK_FLAGS_BLOCK ;
2018-09-05 10:44:12 +03:00
v9ses = v9fs_inode2v9ses ( file_inode ( filp ) ) ;
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 10:04:24 +04:00
/*
* if its a blocked request and we get P9_LOCK_BLOCKED as the status
* for lock request , keep on trying
*/
for ( ; ; ) {
res = p9_client_lock_dotl ( fid , & flock , & status ) ;
if ( res < 0 )
2014-12-29 16:00:18 +03:00
goto out_unlock ;
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 10:04:24 +04:00
if ( status ! = P9_LOCK_BLOCKED )
break ;
if ( status = = P9_LOCK_BLOCKED & & ! IS_SETLKW ( cmd ) )
break ;
2018-09-05 10:44:12 +03:00
if ( schedule_timeout_interruptible ( v9ses - > session_lock_timeout )
! = 0 )
2012-01-04 01:27:50 +04:00
break ;
2018-09-07 19:18:43 +03:00
/*
* p9_client_lock_dotl overwrites flock . client_id with the
* server message , free and reuse the client name
*/
if ( flock . client_id ! = fid - > clnt - > name ) {
kfree ( flock . client_id ) ;
flock . client_id = fid - > clnt - > name ;
}
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 10:04:24 +04:00
}
/* map 9p status to VFS status */
switch ( status ) {
case P9_LOCK_SUCCESS :
res = 0 ;
break ;
case P9_LOCK_BLOCKED :
res = - EAGAIN ;
break ;
2014-12-29 16:00:19 +03:00
default :
WARN_ONCE ( 1 , " unknown lock status code: %d \n " , status ) ;
2020-08-24 01:36:59 +03:00
fallthrough ;
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 10:04:24 +04:00
case P9_LOCK_ERROR :
case P9_LOCK_GRACE :
res = - ENOLCK ;
break ;
}
2014-12-29 16:00:18 +03:00
out_unlock :
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 10:04:24 +04:00
/*
* incase server returned error for lock request , revert
* it locally
*/
2024-02-01 02:02:15 +03:00
if ( res < 0 & & fl - > c . flc_type ! = F_UNLCK ) {
unsigned char type = fl - > c . flc_type ;
2024-02-01 02:01:46 +03:00
2024-02-01 02:02:15 +03:00
fl - > c . flc_type = F_UNLCK ;
2015-11-06 05:44:21 +03:00
/* Even if this fails we want to return the remote error */
2015-11-06 10:10:54 +03:00
locks_lock_file_wait ( filp , fl ) ;
2024-02-01 02:02:15 +03:00
fl - > c . flc_type = type ;
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 10:04:24 +04:00
}
2018-09-07 19:18:43 +03:00
if ( flock . client_id ! = fid - > clnt - > name )
kfree ( flock . client_id ) ;
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 10:04:24 +04:00
out :
return res ;
}
2010-09-27 10:52:13 +04:00
static int v9fs_file_getlock ( struct file * filp , struct file_lock * fl )
{
struct p9_getlock glock ;
struct p9_fid * fid ;
int res = 0 ;
fid = filp - > private_data ;
BUG_ON ( fid = = NULL ) ;
posix_test_lock ( filp , fl ) ;
/*
* if we have a conflicting lock locally , no need to validate
* with server
*/
2024-02-01 02:02:15 +03:00
if ( fl - > c . flc_type ! = F_UNLCK )
2010-09-27 10:52:13 +04:00
return res ;
/* convert posix lock to p9 tgetlock args */
memset ( & glock , 0 , sizeof ( glock ) ) ;
2011-08-20 22:51:18 +04:00
glock . type = P9_LOCK_TYPE_UNLCK ;
2010-09-27 10:52:13 +04:00
glock . start = fl - > fl_start ;
if ( fl - > fl_end = = OFFSET_MAX )
glock . length = 0 ;
else
glock . length = fl - > fl_end - fl - > fl_start + 1 ;
2024-02-01 02:02:15 +03:00
glock . proc_id = fl - > c . flc_pid ;
2013-08-21 21:24:47 +04:00
glock . client_id = fid - > clnt - > name ;
2010-09-27 10:52:13 +04:00
res = p9_client_getlock_dotl ( fid , & glock ) ;
if ( res < 0 )
2018-09-07 19:18:43 +03:00
goto out ;
2011-08-20 22:51:18 +04:00
/* map 9p lock type to os lock type */
switch ( glock . type ) {
case P9_LOCK_TYPE_RDLCK :
2024-02-01 02:02:15 +03:00
fl - > c . flc_type = F_RDLCK ;
2011-08-20 22:51:18 +04:00
break ;
case P9_LOCK_TYPE_WRLCK :
2024-02-01 02:02:15 +03:00
fl - > c . flc_type = F_WRLCK ;
2011-08-20 22:51:18 +04:00
break ;
case P9_LOCK_TYPE_UNLCK :
2024-02-01 02:02:15 +03:00
fl - > c . flc_type = F_UNLCK ;
2011-08-20 22:51:18 +04:00
break ;
}
if ( glock . type ! = P9_LOCK_TYPE_UNLCK ) {
2010-09-27 10:52:13 +04:00
fl - > fl_start = glock . start ;
if ( glock . length = = 0 )
fl - > fl_end = OFFSET_MAX ;
else
fl - > fl_end = glock . start + glock . length - 1 ;
2024-02-01 02:02:15 +03:00
fl - > c . flc_pid = - glock . proc_id ;
2011-08-20 22:51:18 +04:00
}
2018-09-07 19:18:43 +03:00
out :
if ( glock . client_id ! = fid - > clnt - > name )
kfree ( glock . client_id ) ;
2010-09-27 10:52:13 +04:00
return res ;
}
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 10:04:24 +04:00
/**
* v9fs_file_lock_dotl - lock a file ( or directory )
* @ filp : file to be locked
* @ cmd : lock command
* @ fl : file lock structure
*
*/
static int v9fs_file_lock_dotl ( struct file * filp , int cmd , struct file_lock * fl )
{
2013-01-24 02:07:38 +04:00
struct inode * inode = file_inode ( filp ) ;
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 10:04:24 +04:00
int ret = - ENOLCK ;
2014-08-20 04:17:38 +04:00
p9_debug ( P9_DEBUG_VFS , " filp: %p cmd:%d lock: %p name: %pD \n " ,
filp , cmd , fl , filp ) ;
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 10:04:24 +04:00
2024-02-01 02:02:15 +03:00
if ( ( IS_SETLK ( cmd ) | | IS_SETLKW ( cmd ) ) & & fl - > c . flc_type ! = F_UNLCK ) {
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 10:04:24 +04:00
filemap_write_and_wait ( inode - > i_mapping ) ;
invalidate_mapping_pages ( & inode - > i_data , 0 , - 1 ) ;
}
if ( IS_SETLK ( cmd ) | | IS_SETLKW ( cmd ) )
ret = v9fs_file_do_lock ( filp , cmd , fl ) ;
2010-09-27 10:52:13 +04:00
else if ( IS_GETLK ( cmd ) )
ret = v9fs_file_getlock ( filp , fl ) ;
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 10:04:24 +04:00
else
ret = - EINVAL ;
return ret ;
}
/**
* v9fs_file_flock_dotl - lock a file
* @ filp : file to be locked
* @ cmd : lock command
* @ fl : file lock structure
*
*/
static int v9fs_file_flock_dotl ( struct file * filp , int cmd ,
struct file_lock * fl )
{
2013-01-24 02:07:38 +04:00
struct inode * inode = file_inode ( filp ) ;
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 10:04:24 +04:00
int ret = - ENOLCK ;
2014-08-20 04:17:38 +04:00
p9_debug ( P9_DEBUG_VFS , " filp: %p cmd:%d lock: %p name: %pD \n " ,
filp , cmd , fl , filp ) ;
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 10:04:24 +04:00
2024-02-01 02:02:15 +03:00
if ( ! ( fl - > c . flc_flags & FL_FLOCK ) )
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 10:04:24 +04:00
goto out_err ;
2024-02-01 02:02:15 +03:00
if ( ( IS_SETLK ( cmd ) | | IS_SETLKW ( cmd ) ) & & fl - > c . flc_type ! = F_UNLCK ) {
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 10:04:24 +04:00
filemap_write_and_wait ( inode - > i_mapping ) ;
invalidate_mapping_pages ( & inode - > i_data , 0 , - 1 ) ;
}
/* Convert flock to posix lock */
2024-02-01 02:02:15 +03:00
fl - > c . flc_flags | = FL_POSIX ;
fl - > c . flc_flags ^ = FL_FLOCK ;
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 10:04:24 +04:00
if ( IS_SETLK ( cmd ) | IS_SETLKW ( cmd ) )
ret = v9fs_file_do_lock ( filp , cmd , fl ) ;
else
ret = - EINVAL ;
out_err :
return ret ;
}
2008-10-14 05:36:16 +04:00
/**
2021-10-05 00:07:22 +03:00
* v9fs_file_read_iter - read from a file
* @ iocb : The operation parameters
* @ to : The buffer to read into
2008-10-14 05:36:16 +04:00
*
*/
2005-09-10 00:04:18 +04:00
static ssize_t
2015-04-02 06:59:57 +03:00
v9fs_file_read_iter ( struct kiocb * iocb , struct iov_iter * to )
2005-09-10 00:04:18 +04:00
{
2015-04-02 06:59:57 +03:00
struct p9_fid * fid = iocb - > ki_filp - > private_data ;
2005-09-10 00:04:18 +04:00
2023-03-27 05:06:37 +03:00
p9_debug ( P9_DEBUG_VFS , " fid %d count %zu offset %lld \n " ,
fid - > fid , iov_iter_count ( to ) , iocb - > ki_pos ) ;
2008-10-14 05:36:16 +04:00
2023-12-06 15:48:56 +03:00
if ( fid - > mode & P9L_DIRECT )
return netfs_unbuffered_read_iter ( iocb , to ) ;
2005-09-10 00:04:18 +04:00
2023-12-06 15:48:56 +03:00
p9_debug ( P9_DEBUG_VFS , " (cached) \n " ) ;
return netfs_file_read_iter ( iocb , to ) ;
2005-09-10 00:04:18 +04:00
}
2023-05-22 16:50:01 +03:00
/*
* v9fs_file_splice_read - splice - read from a file
* @ in : The 9 p file to read from
* @ ppos : Where to find / update the file position
* @ pipe : The pipe to splice into
* @ len : The maximum amount of data to splice
* @ flags : SPLICE_F_ * flags
*/
static ssize_t v9fs_file_splice_read ( struct file * in , loff_t * ppos ,
struct pipe_inode_info * pipe ,
size_t len , unsigned int flags )
{
struct p9_fid * fid = in - > private_data ;
p9_debug ( P9_DEBUG_VFS , " fid %d count %zu offset %lld \n " ,
fid - > fid , len , * ppos ) ;
if ( fid - > mode & P9L_DIRECT )
return copy_splice_read ( in , ppos , pipe , len , flags ) ;
return filemap_splice_read ( in , ppos , pipe , len , flags ) ;
}
2011-02-28 14:33:56 +03:00
/**
2021-10-05 00:07:22 +03:00
* v9fs_file_write_iter - write to a file
* @ iocb : The operation parameters
* @ from : The data to write
2011-02-28 14:33:56 +03:00
*
*/
static ssize_t
2015-04-02 06:59:57 +03:00
v9fs_file_write_iter ( struct kiocb * iocb , struct iov_iter * from )
2011-02-28 14:33:56 +03:00
{
2015-04-02 06:59:57 +03:00
struct file * file = iocb - > ki_filp ;
2023-03-27 05:06:37 +03:00
struct p9_fid * fid = file - > private_data ;
2022-12-08 05:40:37 +03:00
2023-03-27 05:06:37 +03:00
p9_debug ( P9_DEBUG_VFS , " fid %d \n " , fid - > fid ) ;
2023-12-06 15:48:56 +03:00
if ( fid - > mode & ( P9L_DIRECT | P9L_NOWRITECACHE ) )
return netfs_unbuffered_write_iter ( iocb , from ) ;
2011-02-28 14:33:56 +03:00
2023-12-06 15:48:56 +03:00
p9_debug ( P9_DEBUG_CACHE , " (cached) \n " ) ;
return netfs_file_write_iter ( iocb , from ) ;
2005-09-10 00:04:18 +04:00
}
2011-07-17 04:44:56 +04:00
static int v9fs_file_fsync ( struct file * filp , loff_t start , loff_t end ,
int datasync )
2010-02-09 00:36:48 +03:00
{
struct p9_fid * fid ;
2011-07-17 04:44:56 +04:00
struct inode * inode = filp - > f_mapping - > host ;
2010-02-09 00:36:48 +03:00
struct p9_wstat wstat ;
int retval ;
2017-07-07 22:20:52 +03:00
retval = file_write_and_wait_range ( filp , start , end ) ;
2011-07-17 04:44:56 +04:00
if ( retval )
return retval ;
2016-01-22 23:40:57 +03:00
inode_lock ( inode ) ;
2011-11-28 22:40:46 +04:00
p9_debug ( P9_DEBUG_VFS , " filp %p datasync %x \n " , filp , datasync ) ;
2010-02-09 00:36:48 +03:00
fid = filp - > private_data ;
v9fs_blank_wstat ( & wstat ) ;
retval = p9_client_wstat ( fid , & wstat ) ;
2016-01-22 23:40:57 +03:00
inode_unlock ( inode ) ;
2011-07-17 04:44:56 +04:00
2010-02-09 00:36:48 +03:00
return retval ;
}
2011-07-17 04:44:56 +04:00
int v9fs_file_fsync_dotl ( struct file * filp , loff_t start , loff_t end ,
int datasync )
2010-09-23 04:19:19 +04:00
{
struct p9_fid * fid ;
2011-07-17 04:44:56 +04:00
struct inode * inode = filp - > f_mapping - > host ;
2010-09-23 04:19:19 +04:00
int retval ;
2017-07-07 22:20:52 +03:00
retval = file_write_and_wait_range ( filp , start , end ) ;
2011-07-17 04:44:56 +04:00
if ( retval )
return retval ;
2016-01-22 23:40:57 +03:00
inode_lock ( inode ) ;
2011-11-28 22:40:46 +04:00
p9_debug ( P9_DEBUG_VFS , " filp %p datasync %x \n " , filp , datasync ) ;
2010-09-23 04:19:19 +04:00
fid = filp - > private_data ;
2010-10-22 21:13:12 +04:00
retval = p9_client_fsync ( fid , datasync ) ;
2016-01-22 23:40:57 +03:00
inode_unlock ( inode ) ;
2011-07-17 04:44:56 +04:00
2010-09-23 04:19:19 +04:00
return retval ;
}
2011-02-28 14:33:58 +03:00
static int
2014-01-10 16:44:09 +04:00
v9fs_file_mmap ( struct file * filp , struct vm_area_struct * vma )
2011-02-28 14:33:58 +03:00
{
int retval ;
2022-12-08 05:40:37 +03:00
struct inode * inode = file_inode ( filp ) ;
struct v9fs_session_info * v9ses = v9fs_inode2v9ses ( inode ) ;
2023-03-27 05:06:37 +03:00
p9_debug ( P9_DEBUG_MMAP , " filp :%p \n " , filp ) ;
2014-01-10 16:44:09 +04:00
2023-03-27 04:53:10 +03:00
if ( ! ( v9ses - > cache & CACHE_WRITEBACK ) ) {
2023-07-19 19:22:30 +03:00
p9_debug ( P9_DEBUG_CACHE , " (read-only mmap mode) " ) ;
2022-12-08 05:40:37 +03:00
return generic_file_readonly_mmap ( filp , vma ) ;
}
2014-01-10 16:44:09 +04:00
retval = generic_file_mmap ( filp , vma ) ;
if ( ! retval )
vma - > vm_ops = & v9fs_mmap_file_vm_ops ;
return retval ;
}
2018-07-18 05:14:35 +03:00
static vm_fault_t
2017-02-25 01:56:41 +03:00
v9fs_vm_page_mkwrite ( struct vm_fault * vmf )
2011-02-28 14:33:58 +03:00
{
2023-12-06 15:48:56 +03:00
return netfs_page_mkwrite ( vmf , NULL ) ;
2011-02-28 14:33:58 +03:00
}
2014-01-10 16:44:09 +04:00
static void v9fs_mmap_vm_close ( struct vm_area_struct * vma )
{
struct inode * inode ;
struct writeback_control wbc = {
. nr_to_write = LONG_MAX ,
. sync_mode = WB_SYNC_ALL ,
2020-10-04 21:04:22 +03:00
. range_start = ( loff_t ) vma - > vm_pgoff * PAGE_SIZE ,
2014-01-10 16:44:09 +04:00
/* absolute end, byte at end included */
2020-10-04 21:04:22 +03:00
. range_end = ( loff_t ) vma - > vm_pgoff * PAGE_SIZE +
2014-01-10 16:44:09 +04:00
( vma - > vm_end - vma - > vm_start - 1 ) ,
} ;
2019-08-20 13:03:25 +03:00
if ( ! ( vma - > vm_flags & VM_SHARED ) )
return ;
2014-01-10 16:44:09 +04:00
p9_debug ( P9_DEBUG_VFS , " 9p VMA close, %p, flushing " , vma ) ;
inode = file_inode ( vma - > vm_file ) ;
2021-07-14 21:47:24 +03:00
filemap_fdatawrite_wbc ( inode - > i_mapping , & wbc ) ;
2014-01-10 16:44:09 +04:00
}
static const struct vm_operations_struct v9fs_mmap_file_vm_ops = {
. close = v9fs_mmap_vm_close ,
. fault = filemap_fault ,
2014-04-08 02:37:19 +04:00
. map_pages = filemap_map_pages ,
2014-01-10 16:44:09 +04:00
. page_mkwrite = v9fs_vm_page_mkwrite ,
} ;
2006-03-28 13:56:42 +04:00
const struct file_operations v9fs_file_operations = {
2005-09-10 00:04:18 +04:00
. llseek = generic_file_llseek ,
2015-04-02 06:59:57 +03:00
. read_iter = v9fs_file_read_iter ,
. write_iter = v9fs_file_write_iter ,
2005-09-10 00:04:18 +04:00
. open = v9fs_file_open ,
. release = v9fs_dir_release ,
. lock = v9fs_file_lock ,
2008-02-07 04:25:05 +03:00
. mmap = generic_file_readonly_mmap ,
2023-05-22 16:50:01 +03:00
. splice_read = v9fs_file_splice_read ,
2020-12-01 18:09:37 +03:00
. splice_write = iter_file_splice_write ,
2010-02-09 00:36:48 +03:00
. fsync = v9fs_file_fsync ,
2024-03-19 19:34:45 +03:00
. setlease = simple_nosetlease ,
2005-09-10 00:04:18 +04:00
} ;
2010-03-25 15:41:54 +03:00
const struct file_operations v9fs_file_operations_dotl = {
. llseek = generic_file_llseek ,
2015-04-02 06:59:57 +03:00
. read_iter = v9fs_file_read_iter ,
. write_iter = v9fs_file_write_iter ,
2010-03-25 15:41:54 +03:00
. open = v9fs_file_open ,
. release = v9fs_dir_release ,
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 10:04:24 +04:00
. lock = v9fs_file_lock_dotl ,
. flock = v9fs_file_flock_dotl ,
2022-12-08 05:40:37 +03:00
. mmap = v9fs_file_mmap ,
2023-05-22 16:50:01 +03:00
. splice_read = v9fs_file_splice_read ,
2020-12-01 18:09:37 +03:00
. splice_write = iter_file_splice_write ,
2014-01-10 16:44:09 +04:00
. fsync = v9fs_file_fsync_dotl ,
2024-03-19 19:34:45 +03:00
. setlease = simple_nosetlease ,
2014-01-10 16:44:09 +04:00
} ;