NFS: clean up comments and tab damage in direct.c
Clean up tab damage and comments. Replace "file_offset" with more commonly used "pos". Test plan: Compile with CONFIG_NFS and CONFIG_NFS_DIRECTIO enabled. Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
committed by
Trond Myklebust
parent
9eafa8cc52
commit
88467055f7
@@ -34,6 +34,7 @@
|
|||||||
* 08 Jun 2003 Port to 2.5 APIs --cel
|
* 08 Jun 2003 Port to 2.5 APIs --cel
|
||||||
* 31 Mar 2004 Handle direct I/O without VFS support --cel
|
* 31 Mar 2004 Handle direct I/O without VFS support --cel
|
||||||
* 15 Sep 2004 Parallel async reads --cel
|
* 15 Sep 2004 Parallel async reads --cel
|
||||||
|
* 04 May 2005 support O_DIRECT with aio --cel
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -67,11 +68,11 @@ static kmem_cache_t *nfs_direct_cachep;
|
|||||||
*/
|
*/
|
||||||
struct nfs_direct_req {
|
struct nfs_direct_req {
|
||||||
struct kref kref; /* release manager */
|
struct kref kref; /* release manager */
|
||||||
struct list_head list; /* nfs_read_data structs */
|
struct list_head list; /* nfs_read/write_data structs */
|
||||||
struct file * filp; /* file descriptor */
|
struct file * filp; /* file descriptor */
|
||||||
struct kiocb * iocb; /* controlling i/o request */
|
struct kiocb * iocb; /* controlling i/o request */
|
||||||
wait_queue_head_t wait; /* wait for i/o completion */
|
wait_queue_head_t wait; /* wait for i/o completion */
|
||||||
struct inode * inode; /* target file of I/O */
|
struct inode * inode; /* target file of i/o */
|
||||||
struct page ** pages; /* pages in our buffer */
|
struct page ** pages; /* pages in our buffer */
|
||||||
unsigned int npages; /* count of pages */
|
unsigned int npages; /* count of pages */
|
||||||
atomic_t complete, /* i/os we're waiting for */
|
atomic_t complete, /* i/os we're waiting for */
|
||||||
@@ -110,7 +111,6 @@ static inline int nfs_get_user_pages(int rw, unsigned long user_addr, size_t siz
|
|||||||
size_t array_size;
|
size_t array_size;
|
||||||
|
|
||||||
/* set an arbitrary limit to prevent type overflow */
|
/* set an arbitrary limit to prevent type overflow */
|
||||||
/* XXX: this can probably be as large as INT_MAX */
|
|
||||||
if (size > MAX_DIRECTIO_SIZE) {
|
if (size > MAX_DIRECTIO_SIZE) {
|
||||||
*pages = NULL;
|
*pages = NULL;
|
||||||
return -EFBIG;
|
return -EFBIG;
|
||||||
@@ -294,7 +294,7 @@ static const struct rpc_call_ops nfs_read_direct_ops = {
|
|||||||
* For each nfs_read_data struct that was allocated on the list, dispatch
|
* For each nfs_read_data struct that was allocated on the list, dispatch
|
||||||
* an NFS READ operation
|
* an NFS READ operation
|
||||||
*/
|
*/
|
||||||
static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned long user_addr, size_t count, loff_t file_offset)
|
static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned long user_addr, size_t count, loff_t pos)
|
||||||
{
|
{
|
||||||
struct file *file = dreq->filp;
|
struct file *file = dreq->filp;
|
||||||
struct inode *inode = file->f_mapping->host;
|
struct inode *inode = file->f_mapping->host;
|
||||||
@@ -322,7 +322,7 @@ static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned long
|
|||||||
data->cred = ctx->cred;
|
data->cred = ctx->cred;
|
||||||
data->args.fh = NFS_FH(inode);
|
data->args.fh = NFS_FH(inode);
|
||||||
data->args.context = ctx;
|
data->args.context = ctx;
|
||||||
data->args.offset = file_offset;
|
data->args.offset = pos;
|
||||||
data->args.pgbase = pgbase;
|
data->args.pgbase = pgbase;
|
||||||
data->args.pages = &pages[curpage];
|
data->args.pages = &pages[curpage];
|
||||||
data->args.count = bytes;
|
data->args.count = bytes;
|
||||||
@@ -347,7 +347,7 @@ static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned long
|
|||||||
bytes,
|
bytes,
|
||||||
(unsigned long long)data->args.offset);
|
(unsigned long long)data->args.offset);
|
||||||
|
|
||||||
file_offset += bytes;
|
pos += bytes;
|
||||||
pgbase += bytes;
|
pgbase += bytes;
|
||||||
curpage += pgbase >> PAGE_SHIFT;
|
curpage += pgbase >> PAGE_SHIFT;
|
||||||
pgbase &= ~PAGE_MASK;
|
pgbase &= ~PAGE_MASK;
|
||||||
@@ -356,7 +356,7 @@ static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned long
|
|||||||
} while (count != 0);
|
} while (count != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t nfs_direct_read(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t file_offset, struct page **pages, unsigned int nr_pages)
|
static ssize_t nfs_direct_read(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t pos, struct page **pages, unsigned int nr_pages)
|
||||||
{
|
{
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
sigset_t oldset;
|
sigset_t oldset;
|
||||||
@@ -377,7 +377,7 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, unsigned long user_addr, size
|
|||||||
|
|
||||||
nfs_add_stats(inode, NFSIOS_DIRECTREADBYTES, count);
|
nfs_add_stats(inode, NFSIOS_DIRECTREADBYTES, count);
|
||||||
rpc_clnt_sigmask(clnt, &oldset);
|
rpc_clnt_sigmask(clnt, &oldset);
|
||||||
nfs_direct_read_schedule(dreq, user_addr, count, file_offset);
|
nfs_direct_read_schedule(dreq, user_addr, count, pos);
|
||||||
result = nfs_direct_wait(dreq);
|
result = nfs_direct_wait(dreq);
|
||||||
rpc_clnt_sigunmask(clnt, &oldset);
|
rpc_clnt_sigunmask(clnt, &oldset);
|
||||||
|
|
||||||
@@ -459,7 +459,7 @@ static const struct rpc_call_ops nfs_write_direct_ops = {
|
|||||||
* XXX: For now, support only FILE_SYNC writes. Later we may add
|
* XXX: For now, support only FILE_SYNC writes. Later we may add
|
||||||
* support for UNSTABLE + COMMIT.
|
* support for UNSTABLE + COMMIT.
|
||||||
*/
|
*/
|
||||||
static void nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned long user_addr, size_t count, loff_t file_offset)
|
static void nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned long user_addr, size_t count, loff_t pos)
|
||||||
{
|
{
|
||||||
struct file *file = dreq->filp;
|
struct file *file = dreq->filp;
|
||||||
struct inode *inode = file->f_mapping->host;
|
struct inode *inode = file->f_mapping->host;
|
||||||
@@ -487,7 +487,7 @@ static void nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned long
|
|||||||
data->cred = ctx->cred;
|
data->cred = ctx->cred;
|
||||||
data->args.fh = NFS_FH(inode);
|
data->args.fh = NFS_FH(inode);
|
||||||
data->args.context = ctx;
|
data->args.context = ctx;
|
||||||
data->args.offset = file_offset;
|
data->args.offset = pos;
|
||||||
data->args.pgbase = pgbase;
|
data->args.pgbase = pgbase;
|
||||||
data->args.pages = &pages[curpage];
|
data->args.pages = &pages[curpage];
|
||||||
data->args.count = bytes;
|
data->args.count = bytes;
|
||||||
@@ -513,7 +513,7 @@ static void nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned long
|
|||||||
bytes,
|
bytes,
|
||||||
(unsigned long long)data->args.offset);
|
(unsigned long long)data->args.offset);
|
||||||
|
|
||||||
file_offset += bytes;
|
pos += bytes;
|
||||||
pgbase += bytes;
|
pgbase += bytes;
|
||||||
curpage += pgbase >> PAGE_SHIFT;
|
curpage += pgbase >> PAGE_SHIFT;
|
||||||
pgbase &= ~PAGE_MASK;
|
pgbase &= ~PAGE_MASK;
|
||||||
@@ -522,7 +522,7 @@ static void nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned long
|
|||||||
} while (count != 0);
|
} while (count != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t file_offset, struct page **pages, int nr_pages)
|
static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t pos, struct page **pages, int nr_pages)
|
||||||
{
|
{
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
sigset_t oldset;
|
sigset_t oldset;
|
||||||
@@ -546,7 +546,7 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz
|
|||||||
nfs_begin_data_update(inode);
|
nfs_begin_data_update(inode);
|
||||||
|
|
||||||
rpc_clnt_sigmask(clnt, &oldset);
|
rpc_clnt_sigmask(clnt, &oldset);
|
||||||
nfs_direct_write_schedule(dreq, user_addr, count, file_offset);
|
nfs_direct_write_schedule(dreq, user_addr, count, pos);
|
||||||
result = nfs_direct_wait(dreq);
|
result = nfs_direct_wait(dreq);
|
||||||
rpc_clnt_sigunmask(clnt, &oldset);
|
rpc_clnt_sigunmask(clnt, &oldset);
|
||||||
|
|
||||||
@@ -557,15 +557,15 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz
|
|||||||
* nfs_file_direct_read - file direct read operation for NFS files
|
* nfs_file_direct_read - file direct read operation for NFS files
|
||||||
* @iocb: target I/O control block
|
* @iocb: target I/O control block
|
||||||
* @buf: user's buffer into which to read data
|
* @buf: user's buffer into which to read data
|
||||||
* count: number of bytes to read
|
* @count: number of bytes to read
|
||||||
* pos: byte offset in file where reading starts
|
* @pos: byte offset in file where reading starts
|
||||||
*
|
*
|
||||||
* We use this function for direct reads instead of calling
|
* We use this function for direct reads instead of calling
|
||||||
* generic_file_aio_read() in order to avoid gfar's check to see if
|
* generic_file_aio_read() in order to avoid gfar's check to see if
|
||||||
* the request starts before the end of the file. For that check
|
* the request starts before the end of the file. For that check
|
||||||
* to work, we must generate a GETATTR before each direct read, and
|
* to work, we must generate a GETATTR before each direct read, and
|
||||||
* even then there is a window between the GETATTR and the subsequent
|
* even then there is a window between the GETATTR and the subsequent
|
||||||
* READ where the file size could change. So our preference is simply
|
* READ where the file size could change. Our preference is simply
|
||||||
* to do all reads the application wants, and the server will take
|
* to do all reads the application wants, and the server will take
|
||||||
* care of managing the end of file boundary.
|
* care of managing the end of file boundary.
|
||||||
*
|
*
|
||||||
@@ -621,8 +621,8 @@ out:
|
|||||||
* nfs_file_direct_write - file direct write operation for NFS files
|
* nfs_file_direct_write - file direct write operation for NFS files
|
||||||
* @iocb: target I/O control block
|
* @iocb: target I/O control block
|
||||||
* @buf: user's buffer from which to write data
|
* @buf: user's buffer from which to write data
|
||||||
* count: number of bytes to write
|
* @count: number of bytes to write
|
||||||
* pos: byte offset in file where writing starts
|
* @pos: byte offset in file where writing starts
|
||||||
*
|
*
|
||||||
* We use this function for direct writes instead of calling
|
* We use this function for direct writes instead of calling
|
||||||
* generic_file_aio_write() in order to avoid taking the inode
|
* generic_file_aio_write() in order to avoid taking the inode
|
||||||
@@ -703,6 +703,10 @@ out:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nfs_init_directcache - create a slab cache for nfs_direct_req structures
|
||||||
|
*
|
||||||
|
*/
|
||||||
int nfs_init_directcache(void)
|
int nfs_init_directcache(void)
|
||||||
{
|
{
|
||||||
nfs_direct_cachep = kmem_cache_create("nfs_direct_cache",
|
nfs_direct_cachep = kmem_cache_create("nfs_direct_cache",
|
||||||
@@ -715,6 +719,10 @@ int nfs_init_directcache(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nfs_init_directcache - destroy the slab cache for nfs_direct_req structures
|
||||||
|
*
|
||||||
|
*/
|
||||||
void nfs_destroy_directcache(void)
|
void nfs_destroy_directcache(void)
|
||||||
{
|
{
|
||||||
if (kmem_cache_destroy(nfs_direct_cachep))
|
if (kmem_cache_destroy(nfs_direct_cachep))
|
||||||
|
Reference in New Issue
Block a user