All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] cifs: Allow using O_DIRECT with cache=loose
@ 2015-12-02 14:46 Ross Lagerwall
       [not found] ` <1449067568-23038-1-git-send-email-ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Ross Lagerwall @ 2015-12-02 14:46 UTC (permalink / raw)
  To: linux-cifs-u79uwXL29TY76Z2rM5mHXA; +Cc: Steve French, Ross Lagerwall

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-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/cifsfs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index cbc0f4b..e6e7013 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -752,6 +752,9 @@ cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 	ssize_t rc;
 	struct inode *inode = file_inode(iocb->ki_filp);
 
+	if (iocb->ki_filp->f_flags & O_DIRECT)
+		return cifs_user_readv(iocb, iter);
+
 	rc = cifs_revalidate_mapping(inode);
 	if (rc)
 		return rc;
@@ -766,6 +769,18 @@ static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	ssize_t written;
 	int rc;
 
+	if (iocb->ki_filp->f_flags & O_DIRECT) {
+		written = cifs_user_writev(iocb, from);
+		if (written > 0 && CIFS_CACHE_READ(cinode)) {
+			cifs_zap_mapping(inode);
+			cifs_dbg(FYI,
+				 "Set no oplock for inode=%p after a write operation\n",
+				 inode);
+			cinode->oplock = 0;
+		}
+		return written;
+	}
+
 	written = cifs_get_writer(cinode);
 	if (written)
 		return written;
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] cifs: Check uniqueid for SMB2+ and return -ESTALE if necessary
       [not found] ` <1449067568-23038-1-git-send-email-ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
@ 2015-12-02 14:46   ` Ross Lagerwall
       [not found]     ` <1449067568-23038-2-git-send-email-ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
  2015-12-18 19:06   ` [PATCH v2 1/2] cifs: Allow using O_DIRECT with cache=loose Steve French
  1 sibling, 1 reply; 4+ messages in thread
From: Ross Lagerwall @ 2015-12-02 14:46 UTC (permalink / raw)
  To: linux-cifs-u79uwXL29TY76Z2rM5mHXA; +Cc: Steve French, Ross Lagerwall

Commit 7196ac113a4f ("Fix to check Unique id and FileType when client
refer file directly.") checks whether the uniqueid of an inode has
changed when getting the inode info, but only when using the UNIX
extensions. Add a similar check for SMB2+, since this can be done
without an extra network roundtrip.

Signed-off-by: Ross Lagerwall <ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
---
v2:
Changed to not do an extra network roundtrip to get the uniqueid.

 fs/cifs/inode.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 6b66dd5..d14c05b 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -814,8 +814,21 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
 			}
 		} else
 			fattr.cf_uniqueid = iunique(sb, ROOT_I);
-	} else
-		fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
+	} else {
+		if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&
+		    validinum == false && server->ops->get_srv_inum) {
+			/*
+			 * Pass a NULL tcon to ensure we don't make a round
+			 * trip to the server. This only works for SMB2+.
+			 */
+			tmprc = server->ops->get_srv_inum(xid,
+				NULL, cifs_sb, full_path,
+				&fattr.cf_uniqueid, data);
+			if (tmprc)
+				fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
+		} else
+			fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
+	}
 
 	/* query for SFU type info if supported and needed */
 	if (fattr.cf_cifsattrs & ATTR_SYSTEM &&
@@ -856,6 +869,13 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
 	} else {
 		/* we already have inode, update it */
 
+		/* if uniqueid is different, return error */
+		if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM &&
+		    CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) {
+			rc = -ESTALE;
+			goto cgii_exit;
+		}
+
 		/* if filetype is different, return error */
 		if (unlikely(((*inode)->i_mode & S_IFMT) !=
 		    (fattr.cf_mode & S_IFMT))) {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] cifs: Check uniqueid for SMB2+ and return -ESTALE if necessary
       [not found]     ` <1449067568-23038-2-git-send-email-ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
@ 2015-12-18 18:18       ` Steve French
  0 siblings, 0 replies; 4+ messages in thread
From: Steve French @ 2015-12-18 18:18 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA, Steve French

merged into cifs-2.6.git

If any strong preferences about whether it should go to stable let me know

On Wed, Dec 2, 2015 at 8:46 AM, Ross Lagerwall
<ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org> wrote:
> Commit 7196ac113a4f ("Fix to check Unique id and FileType when client
> refer file directly.") checks whether the uniqueid of an inode has
> changed when getting the inode info, but only when using the UNIX
> extensions. Add a similar check for SMB2+, since this can be done
> without an extra network roundtrip.
>
> Signed-off-by: Ross Lagerwall <ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
> ---
> v2:
> Changed to not do an extra network roundtrip to get the uniqueid.
>
>  fs/cifs/inode.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index 6b66dd5..d14c05b 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -814,8 +814,21 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
>                         }
>                 } else
>                         fattr.cf_uniqueid = iunique(sb, ROOT_I);
> -       } else
> -               fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
> +       } else {
> +               if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) &&
> +                   validinum == false && server->ops->get_srv_inum) {
> +                       /*
> +                        * Pass a NULL tcon to ensure we don't make a round
> +                        * trip to the server. This only works for SMB2+.
> +                        */
> +                       tmprc = server->ops->get_srv_inum(xid,
> +                               NULL, cifs_sb, full_path,
> +                               &fattr.cf_uniqueid, data);
> +                       if (tmprc)
> +                               fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
> +               } else
> +                       fattr.cf_uniqueid = CIFS_I(*inode)->uniqueid;
> +       }
>
>         /* query for SFU type info if supported and needed */
>         if (fattr.cf_cifsattrs & ATTR_SYSTEM &&
> @@ -856,6 +869,13 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
>         } else {
>                 /* we already have inode, update it */
>
> +               /* if uniqueid is different, return error */
> +               if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM &&
> +                   CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) {
> +                       rc = -ESTALE;
> +                       goto cgii_exit;
> +               }
> +
>                 /* if filetype is different, return error */
>                 if (unlikely(((*inode)->i_mode & S_IFMT) !=
>                     (fattr.cf_mode & S_IFMT))) {
> --
> 2.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] cifs: Allow using O_DIRECT with cache=loose
       [not found] ` <1449067568-23038-1-git-send-email-ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
  2015-12-02 14:46   ` [PATCH v2 2/2] cifs: Check uniqueid for SMB2+ and return -ESTALE if necessary Ross Lagerwall
@ 2015-12-18 19:06   ` Steve French
  1 sibling, 0 replies; 4+ messages in thread
From: Steve French @ 2015-12-18 19:06 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA

merged into cifs-2.6.git

On Wed, Dec 2, 2015 at 8:46 AM, Ross Lagerwall
<ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org> wrote:
> 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-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
> ---
>  fs/cifs/cifsfs.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index cbc0f4b..e6e7013 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -752,6 +752,9 @@ cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
>         ssize_t rc;
>         struct inode *inode = file_inode(iocb->ki_filp);
>
> +       if (iocb->ki_filp->f_flags & O_DIRECT)
> +               return cifs_user_readv(iocb, iter);
> +
>         rc = cifs_revalidate_mapping(inode);
>         if (rc)
>                 return rc;
> @@ -766,6 +769,18 @@ static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
>         ssize_t written;
>         int rc;
>
> +       if (iocb->ki_filp->f_flags & O_DIRECT) {
> +               written = cifs_user_writev(iocb, from);
> +               if (written > 0 && CIFS_CACHE_READ(cinode)) {
> +                       cifs_zap_mapping(inode);
> +                       cifs_dbg(FYI,
> +                                "Set no oplock for inode=%p after a write operation\n",
> +                                inode);
> +                       cinode->oplock = 0;
> +               }
> +               return written;
> +       }
> +
>         written = cifs_get_writer(cinode);
>         if (written)
>                 return written;
> --
> 2.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-18 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 14:46 [PATCH v2 1/2] cifs: Allow using O_DIRECT with cache=loose Ross Lagerwall
     [not found] ` <1449067568-23038-1-git-send-email-ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
2015-12-02 14:46   ` [PATCH v2 2/2] cifs: Check uniqueid for SMB2+ and return -ESTALE if necessary Ross Lagerwall
     [not found]     ` <1449067568-23038-2-git-send-email-ross.lagerwall-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
2015-12-18 18:18       ` Steve French
2015-12-18 19:06   ` [PATCH v2 1/2] cifs: Allow using O_DIRECT with cache=loose Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.