Skip to content

Commit eb79f3a

Browse files
neilbrownakpm00
authored andcommitted
nfs: rename nfs_direct_IO and use as ->swap_rw
The nfs_direct_IO() exists to support SWAP IO, but hasn't worked for a while. We now need a ->swap_rw function which behaves slightly differently, returning zero for success rather than a byte count. So modify nfs_direct_IO accordingly, rename it, and use it as the ->swap_rw function. Link: https://lkml.kernel.org/r/165119301493.15698.7491285551903597618.stgit@noble.brown Signed-off-by: NeilBrown <neilb@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> (on Renesas RSK+RZA1 with 32 MiB of SDRAM) Cc: David Howells <dhowells@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Miaohe Lin <linmiaohe@huawei.com> Cc: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent e1209d3 commit eb79f3a

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

fs/nfs/direct.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,25 @@ nfs_direct_count_bytes(struct nfs_direct_req *dreq,
153153
}
154154

155155
/**
156-
* nfs_direct_IO - NFS address space operation for direct I/O
156+
* nfs_swap_rw - NFS address space operation for swap I/O
157157
* @iocb: target I/O control block
158158
* @iter: I/O buffer
159159
*
160-
* The presence of this routine in the address space ops vector means
161-
* the NFS client supports direct I/O. However, for most direct IO, we
162-
* shunt off direct read and write requests before the VFS gets them,
163-
* so this method is only ever called for swap.
160+
* Perform IO to the swap-file. This is much like direct IO.
164161
*/
165-
ssize_t nfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
162+
int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter)
166163
{
167-
struct inode *inode = iocb->ki_filp->f_mapping->host;
168-
169-
/* we only support swap file calling nfs_direct_IO */
170-
if (!IS_SWAPFILE(inode))
171-
return 0;
164+
ssize_t ret;
172165

173166
VM_BUG_ON(iov_iter_count(iter) != PAGE_SIZE);
174167

175168
if (iov_iter_rw(iter) == READ)
176-
return nfs_file_direct_read(iocb, iter, true);
177-
return nfs_file_direct_write(iocb, iter, true);
169+
ret = nfs_file_direct_read(iocb, iter, true);
170+
else
171+
ret = nfs_file_direct_write(iocb, iter, true);
172+
if (ret < 0)
173+
return ret;
174+
return 0;
178175
}
179176

180177
static void nfs_direct_release_pages(struct page **pages, unsigned int npages)

fs/nfs/file.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,6 @@ static int nfs_swap_activate(struct swap_info_struct *sis, struct file *file,
488488
struct rpc_clnt *clnt = NFS_CLIENT(inode);
489489
struct nfs_client *cl = NFS_SERVER(inode)->nfs_client;
490490

491-
if (!file->f_mapping->a_ops->swap_rw)
492-
/* Cannot support swap */
493-
return -EINVAL;
494-
495491
spin_lock(&inode->i_lock);
496492
blocks = inode->i_blocks;
497493
isize = inode->i_size;
@@ -549,6 +545,7 @@ const struct address_space_operations nfs_file_aops = {
549545
.error_remove_page = generic_error_remove_page,
550546
.swap_activate = nfs_swap_activate,
551547
.swap_deactivate = nfs_swap_deactivate,
548+
.swap_rw = nfs_swap_rw,
552549
};
553550

554551
/*

include/linux/nfs_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static inline const struct cred *nfs_file_cred(struct file *file)
507507
/*
508508
* linux/fs/nfs/direct.c
509509
*/
510-
extern ssize_t nfs_direct_IO(struct kiocb *, struct iov_iter *);
510+
int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter);
511511
ssize_t nfs_file_direct_read(struct kiocb *iocb,
512512
struct iov_iter *iter, bool swap);
513513
ssize_t nfs_file_direct_write(struct kiocb *iocb,

0 commit comments

Comments
 (0)