The Samba-Bugzilla – Attachment 15955 Details for
Bug 14361
vfs_io_uring sometimes cause data corruption with Windows clients
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for debugging
tmp.diff.txt (text/plain), 4.37 KB, created by
Stefan Metzmacher
on 2020-05-06 10:27:09 UTC
(
hide
)
Description:
Patch for debugging
Filename:
MIME Type:
Creator:
Stefan Metzmacher
Created:
2020-05-06 10:27:09 UTC
Size:
4.37 KB
patch
obsolete
>From 81626165ada62e660cfc0eaa80dfe0a6f53dba38 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Wed, 6 May 2020 03:12:24 -0700 >Subject: [PATCH] HACK vfs_io_uring: add debugging for bug 14361 > >--- > source3/modules/vfs_io_uring.c | 93 +++++++++++++++++++++++++++++++++- > 1 file changed, 92 insertions(+), 1 deletion(-) > >diff --git a/source3/modules/vfs_io_uring.c b/source3/modules/vfs_io_uring.c >index b409d0753379..1a9b8e442213 100644 >--- a/source3/modules/vfs_io_uring.c >+++ b/source3/modules/vfs_io_uring.c >@@ -35,6 +35,8 @@ struct vfs_io_uring_config { > struct tevent_fd *fde; > struct vfs_io_uring_request *queue; > struct vfs_io_uring_request *pending; >+ bool check_ff; >+ size_t truncate_pread; > }; > > struct vfs_io_uring_request { >@@ -48,6 +50,11 @@ struct vfs_io_uring_request { > struct timespec start_time; > struct timespec end_time; > SMBPROFILE_BYTES_ASYNC_STATE(profile_bytes); >+ const char *opname; >+ struct files_struct *fsp; >+ uint8_t *data; >+ size_t len; >+ off_t ofs; > }; > > static void vfs_io_uring_finish_req(struct vfs_io_uring_request *cur, >@@ -69,6 +76,77 @@ static void vfs_io_uring_finish_req(struct vfs_io_uring_request *cur, > SMBPROFILE_BYTES_ASYNC_SET_IDLE(cur->profile_bytes); > cur->end_time = end_time; > >+ if (cur->opname == NULL) { >+ goto done; >+ } >+ >+ if (cqe->res < 0) { >+ goto done; >+ } >+ >+ if ((size_t)cqe->res != (size_t)cur->len) { >+ DBG_ERR("Invalid %s ofs=%zu (0x%zx) len=%zu (0x%zx) nread=%zu (0x%zu) eof=%zu (0x%zx) blks=%zu blocks=%zu %s %s\n", >+ cur->opname, >+ (size_t)cur->ofs, >+ (size_t)cur->ofs, >+ (size_t)cur->len, >+ (size_t)cur->len, >+ (size_t)cqe->res, >+ (size_t)cqe->res, >+ (size_t)cur->fsp->fsp_name->st.st_ex_size, >+ (size_t)cur->fsp->fsp_name->st.st_ex_size, >+ (size_t)cur->fsp->fsp_name->st.st_ex_blksize, >+ (size_t)cur->fsp->fsp_name->st.st_ex_blocks, >+ fsp_str_dbg(cur->fsp), >+ fsp_fnum_dbg(cur->fsp)); >+ } else { >+ DBG_WARNING("%s ofs=%zu (0x%zx) len=%zu (0x%zx) nread=%zu (0x%zu) eof=%zu (0x%zx) blks=%zu blocks=%zu %s %s\n", >+ cur->opname, >+ (size_t)cur->ofs, >+ (size_t)cur->ofs, >+ (size_t)cur->len, >+ (size_t)cur->len, >+ (size_t)cqe->res, >+ (size_t)cqe->res, >+ (size_t)cur->fsp->fsp_name->st.st_ex_size, >+ (size_t)cur->fsp->fsp_name->st.st_ex_size, >+ (size_t)cur->fsp->fsp_name->st.st_ex_blksize, >+ (size_t)cur->fsp->fsp_name->st.st_ex_blocks, >+ fsp_str_dbg(cur->fsp), >+ fsp_fnum_dbg(cur->fsp)); >+ } >+ >+ if (cur->config->check_ff) { >+ size_t i; >+ size_t len = MIN(cur->len, ((size_t)cqe->res)); >+ for (i = 0; i < len; i++) { >+ size_t fofs; >+ if (cur->data[i] == 0xff) { >+ continue; >+ } >+ >+ fofs = cur->ofs + i; >+ DBG_ERR("%s invalid byte[0x%x] at fofs=%zu (0x%zx) ofs=%zu (0x%zx) len=%zu (0x%zx) nread=%zu (0x%zu) eof=%zu (0x%zx) blks=%zu blocks=%zu %s %s\n", >+ cur->opname, >+ cur->data[i], >+ (size_t)fofs, >+ (size_t)fofs, >+ (size_t)cur->ofs, >+ (size_t)cur->ofs, >+ (size_t)cur->len, >+ (size_t)cur->len, >+ (size_t)cqe->res, >+ (size_t)cqe->res, >+ (size_t)cur->fsp->fsp_name->st.st_ex_size, >+ (size_t)cur->fsp->fsp_name->st.st_ex_size, >+ (size_t)cur->fsp->fsp_name->st.st_ex_blksize, >+ (size_t)cur->fsp->fsp_name->st.st_ex_blocks, >+ fsp_str_dbg(cur->fsp), >+ fsp_fnum_dbg(cur->fsp)); >+ break; >+ } >+ } >+done: > /* > * We rely on being inside the _send() function > * or tevent_req_defer_callback() being called >@@ -216,6 +294,14 @@ static int vfs_io_uring_connect(vfs_handle_struct *handle, const char *service, > return -1; > } > >+ config->check_ff = lp_parm_bool(SNUM(handle->conn), >+ "io_uring", >+ "check_ff", >+ false); >+ config->truncate_pread = lp_parm_ulonglong(SNUM(handle->conn), >+ "io_uring", >+ "truncate_pread", >+ UINT64_MAX); > return 0; > } > >@@ -319,13 +405,18 @@ static struct tevent_req *vfs_io_uring_pread_send(struct vfs_handle_struct *hand > state->ur.config = config; > state->ur.req = req; > state->ur.state = state; >+ state->ur.opname = "pread"; >+ state->ur.fsp = fsp; >+ state->ur.data = data; >+ state->ur.len = n; >+ state->ur.ofs = offset; > > SMBPROFILE_BYTES_ASYNC_START(syscall_asys_pread, profile_p, > state->ur.profile_bytes, n); > SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->ur.profile_bytes); > > state->iov.iov_base = (void *)data; >- state->iov.iov_len = n; >+ state->iov.iov_len = MIN(n, config->truncate_pread); > io_uring_prep_readv(&state->ur.sqe, > fsp->fh->fd, > &state->iov, 1, >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 14361
:
15947
|
15955
|
15960
|
15961
|
15962
|
15964
|
15965
|
15969
|
15971
|
15976