linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cachefiles: Fix the volume coherency check
@ 2022-01-31 17:52 David Howells
  2022-01-31 18:43 ` Jeff Layton
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2022-01-31 17:52 UTC (permalink / raw)
  To: smfrench
  Cc: Jeff Layton, linux-cifs, linux-cachefs, dhowells, linux-fsdevel,
	linux-kernel

Fix the cache volume coherency attribute check.  It was copied from the
file coherency check which uses as struct to lay out the xattr, and so
needs to add a bit on to find the coherency data - but the volume coherency
attribute only contains the coherency data, so we shouldn't be using the
layout struct for it.

This has passed unnoticed so far because it only affects cifs at the
moment, and cifs had its fscache component disabled.

This can now be checked by enabling CONFIG_CIFS_FSCACHE, enabling the
following tracepoint:

	/sys/kernel/debug/tracing/events/cachefiles/cachefiles_vol_coherency/enable

and making a cifs mount.  Without this change, the trace shows a
cachefiles_vol_coherency line with "VOL BAD cmp" in it; with this change it
shows "VOL OK" instead.

Fixes: 32e150037dce ("fscache, cachefiles: Store the volume coherency data")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: Steve French <smfrench@gmail.com>
cc: linux-cifs@vger.kernel.org
cc: linux-cachefs@redhat.com
---

 fs/cachefiles/xattr.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c
index 83f41bd0c3a9..c6171e818a7c 100644
--- a/fs/cachefiles/xattr.c
+++ b/fs/cachefiles/xattr.c
@@ -218,10 +218,10 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
  */
 int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 {
-	struct cachefiles_xattr *buf;
 	struct dentry *dentry = volume->dentry;
 	unsigned int len = volume->vcookie->coherency_len;
 	const void *p = volume->vcookie->coherency;
+	void *buf;
 	enum cachefiles_coherency_trace why;
 	ssize_t xlen;
 	int ret = -ESTALE;
@@ -245,7 +245,7 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 					"Failed to read xattr with error %zd", xlen);
 		}
 		why = cachefiles_coherency_vol_check_xattr;
-	} else if (memcmp(buf->data, p, len) != 0) {
+	} else if (memcmp(buf, p, len) != 0) {
 		why = cachefiles_coherency_vol_check_cmp;
 	} else {
 		why = cachefiles_coherency_vol_check_ok;



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

* Re: [PATCH] cachefiles: Fix the volume coherency check
  2022-01-31 17:52 [PATCH] cachefiles: Fix the volume coherency check David Howells
@ 2022-01-31 18:43 ` Jeff Layton
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2022-01-31 18:43 UTC (permalink / raw)
  To: David Howells, smfrench
  Cc: linux-cifs, linux-cachefs, linux-fsdevel, linux-kernel

On Mon, 2022-01-31 at 17:52 +0000, David Howells wrote:
> Fix the cache volume coherency attribute check.  It was copied from the
> file coherency check which uses as struct to lay out the xattr, and so
> needs to add a bit on to find the coherency data - but the volume coherency
> attribute only contains the coherency data, so we shouldn't be using the
> layout struct for it.
> 
> This has passed unnoticed so far because it only affects cifs at the
> moment, and cifs had its fscache component disabled.
> 
> This can now be checked by enabling CONFIG_CIFS_FSCACHE, enabling the
> following tracepoint:
> 
> 	/sys/kernel/debug/tracing/events/cachefiles/cachefiles_vol_coherency/enable
> 
> and making a cifs mount.  Without this change, the trace shows a
> cachefiles_vol_coherency line with "VOL BAD cmp" in it; with this change it
> shows "VOL OK" instead.
> 
> Fixes: 32e150037dce ("fscache, cachefiles: Store the volume coherency data")
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Jeff Layton <jlayton@kernel.org>
> cc: Steve French <smfrench@gmail.com>
> cc: linux-cifs@vger.kernel.org
> cc: linux-cachefs@redhat.com
> ---
> 
>  fs/cachefiles/xattr.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c
> index 83f41bd0c3a9..c6171e818a7c 100644
> --- a/fs/cachefiles/xattr.c
> +++ b/fs/cachefiles/xattr.c
> @@ -218,10 +218,10 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
>   */
>  int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
>  {
> -	struct cachefiles_xattr *buf;
>  	struct dentry *dentry = volume->dentry;
>  	unsigned int len = volume->vcookie->coherency_len;
>  	const void *p = volume->vcookie->coherency;
> +	void *buf;
>  	enum cachefiles_coherency_trace why;
>  	ssize_t xlen;
>  	int ret = -ESTALE;
> @@ -245,7 +245,7 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
>  					"Failed to read xattr with error %zd", xlen);
>  		}
>  		why = cachefiles_coherency_vol_check_xattr;
> -	} else if (memcmp(buf->data, p, len) != 0) {
> +	} else if (memcmp(buf, p, len) != 0) {
>  		why = cachefiles_coherency_vol_check_cmp;
>  	} else {
>  		why = cachefiles_coherency_vol_check_ok;
> 
> 

Reviewed-by: Jeff Layton <jlayton@kernel.org>

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

end of thread, other threads:[~2022-01-31 18:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-31 17:52 [PATCH] cachefiles: Fix the volume coherency check David Howells
2022-01-31 18:43 ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).