diff options
| author | Ross Lagerwall <ross.lagerwall@citrix.com> | 2015-12-02 09:46:07 -0500 |
|---|---|---|
| committer | Steve French <sfrench@localhost.localdomain> | 2016-01-14 15:29:34 -0500 |
| commit | 882137c4d64175e2bb38cd842e25d54e6de31da8 (patch) | |
| tree | 1cc5ca4e04c95570e62c0a008dd16600ec9fe2d6 | |
| parent | adfeb3e00e8e1b9fb4ad19eb7367e7c272d16003 (diff) | |
cifs: Allow using O_DIRECT with cache=loose
Currently O_DIRECT is supported with cache=none and cache=strict, but
not cache=loose. Add support for using O_DIRECT when mounted with
cache=loose.
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Steve French <smfrench@gmail.com>
| -rw-r--r-- | fs/cifs/cifsfs.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 53e343d073bb..565a4c0d2ee9 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
| @@ -754,6 +754,9 @@ cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter) | |||
| 754 | ssize_t rc; | 754 | ssize_t rc; |
| 755 | struct inode *inode = file_inode(iocb->ki_filp); | 755 | struct inode *inode = file_inode(iocb->ki_filp); |
| 756 | 756 | ||
| 757 | if (iocb->ki_filp->f_flags & O_DIRECT) | ||
| 758 | return cifs_user_readv(iocb, iter); | ||
| 759 | |||
| 757 | rc = cifs_revalidate_mapping(inode); | 760 | rc = cifs_revalidate_mapping(inode); |
| 758 | if (rc) | 761 | if (rc) |
| 759 | return rc; | 762 | return rc; |
| @@ -768,6 +771,18 @@ static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
| 768 | ssize_t written; | 771 | ssize_t written; |
| 769 | int rc; | 772 | int rc; |
| 770 | 773 | ||
| 774 | if (iocb->ki_filp->f_flags & O_DIRECT) { | ||
| 775 | written = cifs_user_writev(iocb, from); | ||
| 776 | if (written > 0 && CIFS_CACHE_READ(cinode)) { | ||
| 777 | cifs_zap_mapping(inode); | ||
| 778 | cifs_dbg(FYI, | ||
| 779 | "Set no oplock for inode=%p after a write operation\n", | ||
| 780 | inode); | ||
| 781 | cinode->oplock = 0; | ||
| 782 | } | ||
| 783 | return written; | ||
| 784 | } | ||
| 785 | |||
| 771 | written = cifs_get_writer(cinode); | 786 | written = cifs_get_writer(cinode); |
| 772 | if (written) | 787 | if (written) |
| 773 | return written; | 788 | return written; |
